old_contents: import hexchat
  
  __module_name__ = 'MyMessages'
  __module_author__ = 'TingPing'
  __module_version__ = '1'
  __module_description__ = 'Properly show your messages in znc playback and with privmsg module'
  
  def is_me(nick):
  	if hexchat.nickcmp(nick, hexchat.get_info('nick')) == 0:
  		return True
  	else:
  		return False
  
  def print_cb(word, word_eol, print_type):
  	if is_me(word[0]):
  		hexchat.emit_print(print_type, word[0], word[1])
  		return hexchat.EAT_ALL
  
  # This could use some improvement..
  def privmsg_cb(word, word_eol, userdata):
  	if is_me(word[0].split('!')[0][1:]):
  		hexchat.command('query -nofocus {}'.format(word[2]))
  		ctx = hexchat.find_context(hexchat.get_info('network'), word[2])
  		ctx.emit_print('Your Message', hexchat.get_info('nick'), word_eol[3][1:])
  		return hexchat.EAT_ALL
  
  hexchat.hook_print('Channel Message', print_cb, 'Channel Message')
  hexchat.hook_print('Channel Action', print_cb, 'Channel Action')
  hexchat.hook_server('PRIVMSG', privmsg_cb)
  
new_contents: import hexchat
  
  __module_name__ = 'MyMessages'
  __module_author__ = 'TingPing'
  __module_version__ = '2'
  __module_description__ = 'Properly show your messages in znc playback and with privmsg module'
  
  def privmsg_cb(word, word_eol, userdata, attrs):
  	mynick = hexchat.get_info('nick')
  	sender = word[0].split('!')[0][1:]
  	recipient = word[2]
  	network = hexchat.get_info('network')
  	msg = word_eol[3][1:]
  
  	if hexchat.nickcmp(sender, mynick) == 0:
  		if recipient[0] != '#':
  			hexchat.command('query -nofocus {}'.format(recipient))
  		hexchat.find_context(network, recipient).set()
  
  		if '\001ACTION' in msg:
  			msg = msg.strip('\001ACTION')
  			msg = msg.strip('\001')
  			hexchat.emit_print_at(attrs.time, 'Your Action', mynick, msg.strip())
  		else:
  			hexchat.emit_print_at(attrs.time, 'Your Message', mynick, msg)
  
  		return hexchat.EAT_ALL
  
  hexchat.hook_server_attrs('PRIVMSG', privmsg_cb)
  
subject: Update mymsg.py