2015-06-24 04:08:43 +02:00
|
|
|
# hooks.py: test of PyLink hooks
|
|
|
|
import sys, os
|
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
import utils
|
2015-07-05 22:44:48 +02:00
|
|
|
from log import log
|
2015-06-24 04:08:43 +02:00
|
|
|
|
|
|
|
def hook_join(irc, source, command, args):
|
2015-07-05 04:00:29 +02:00
|
|
|
channel = args['channel']
|
|
|
|
users = args['users']
|
2015-07-05 22:44:48 +02:00
|
|
|
log.info('%s joined channel %s (JOIN hook caught)' % (users, channel))
|
2015-07-05 04:00:29 +02:00
|
|
|
utils.add_hook(hook_join, 'JOIN')
|
2015-06-24 04:08:43 +02:00
|
|
|
|
2015-07-05 04:00:29 +02:00
|
|
|
def hook_privmsg(irc, source, command, args):
|
|
|
|
channel = args['target']
|
|
|
|
text = args['text']
|
|
|
|
if utils.isChannel(channel) and irc.pseudoclient.nick in text:
|
2015-09-07 07:23:44 +02:00
|
|
|
irc.msg(channel, 'hi there!')
|
2015-07-05 22:44:48 +02:00
|
|
|
log.info('%s said my name on channel %s (PRIVMSG hook caught)' % (source, channel))
|
2015-07-05 04:00:29 +02:00
|
|
|
utils.add_hook(hook_privmsg, 'PRIVMSG')
|