3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00
PyLink/plugins/hooks.py
James Lu 62e7cc4fca move utils.msg() => classes.Irc.msg()
New function gets an extra (optional) "source" argument for specifying a sender UID. It's also shorter since no IRC object has to be passed to utils.
2015-09-06 22:23:44 -07:00

20 lines
704 B
Python

# hooks.py: test of PyLink hooks
import sys, os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
from log import log
def hook_join(irc, source, command, args):
channel = args['channel']
users = args['users']
log.info('%s joined channel %s (JOIN hook caught)' % (users, channel))
utils.add_hook(hook_join, 'JOIN')
def hook_privmsg(irc, source, command, args):
channel = args['target']
text = args['text']
if utils.isChannel(channel) and irc.pseudoclient.nick in text:
irc.msg(channel, 'hi there!')
log.info('%s said my name on channel %s (PRIVMSG hook caught)' % (source, channel))
utils.add_hook(hook_privmsg, 'PRIVMSG')