]> jfr.im git - irc/evilnet/x3.git/blob - src/plugins/annoy/plugin.py
Added new event hooks system and started migrating events to new system
[irc/evilnet/x3.git] / src / plugins / annoy / plugin.py
1 # anoy module
2
3 import _svc
4
5 class Annoy:
6
7 def __init__(self, handler, irc):
8 self.handler = handler
9 self.name = "annoy"
10
11 # These hooks are for testing, and are commented out by default so as not to annoy
12 # us unless we want to test them
13 #handler.addhook("join", self.on_join, "foobar")
14 #handler.addhook("nick_change", self.nick_change, ["Rubin", None], "testing")
15
16 handler.addcommand(self.name, "dance", self.dance)
17 handler.addcommand(self.name, "nickof", self.nickof)
18 self.test = "footest"
19
20 # def on_join(self, irc, channel, nick):
21 # irc.send_target_privmsg("x3", channel, "%s joined %s:%s "%(nick, channel, self.test))
22
23 def nick_change(self, irc, nick, old_nick):
24 svcinfo = _svc.get_info()
25 # opserv pm #theops that someones nick changed
26 irc.send_target_privmsg(svcinfo["opserv"], "#theops", "%s changed nick to %s"%(old_nick, nick) )
27
28 def dance(self, irc, args):
29 nick = irc.caller
30 user = _svc.get_user(nick)
31
32 reply = "Ok,"
33 if(user and "account" in user):
34 reply += " Mr. %s"%user["account"]
35
36 reply += " we can dance"
37 if(len(args)):
38 reply += " "
39 reply += args
40 reply += "."
41
42 irc.reply(reply)
43
44 def nickof(self, irc, bot):
45 info = _svc.get_info()
46
47 if(bot and bot in info.keys()):
48 irc.reply("%s has nick %s"%(bot, info[bot]))
49 else:
50 irc.reply("I dunno. Try %s"%str(info.keys()))
51
52 Class = Annoy