Skip to content

Instantly share code, notes, and snippets.

@dword4
Created April 28, 2018 04:00
Show Gist options
  • Save dword4/fec4339009d31d0324fe606fc7ea4c3f to your computer and use it in GitHub Desktop.
Save dword4/fec4339009d31d0324fe606fc7ea4c3f to your computer and use it in GitHub Desktop.
say wat one more #$&!@ time, I dare you! this prints West African Time every time someone says just the word wat in any channel
__module_name__ = "wat"
__module_version__ = "1.0"
__module_description__ = "say wat!"
import hexchat
import re
from datetime import datetime
from datetime import timedelta
def count_words(somevar):
s = somevar
words = s.split(' ')
return len(words)
def checkmessage_cb(word, word_eol, userdata):
if len(word) == 4:
msg = re.sub('\:','',word[3])
if msg.lower() == 'wat':
# lets get the time in west africa, need to adjust for difference from local time
wat = datetime.now() + timedelta(hours=5)
chan = hexchat.get_info("channel")
msg = "PRIVMSG %s West African Time: %s" % (chan, wat)
hexchat.command(msg)
return hexchat.EAT_ALL
hexchat.hook_server('PRIVMSG', checkmessage_cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment