]>
Commit | Line | Data |
---|---|---|
b069ba10 JR |
1 | from classes import * |
2 | from util import * | |
3 | ||
4 | name = 'admin messaging' | |
5 | def init(cache): | |
6 | cache.currmod = __name__ | |
7 | cache.hookcmd('ADMINSEND', 2, send, 3, helpsend, isadmin=True) | |
8 | cache.hookcmd('ADMINACT', 2, act, 3, helpact, isadmin=True) | |
9 | def deinit(cache): | |
10 | cache.currmod = __name__ | |
11 | cache.unhookcmd('ADMINSEND') | |
12 | cache.unhookcmd('ADMINACT') | |
13 | ||
14 | def send(nick, target, params, bot, cache): | |
15 | pieces = params.split() | |
16 | sbid = pieces[0] | |
17 | bid = toint(sbid) | |
18 | target = pieces[1] | |
19 | msg = ' '.join(pieces[2:]) | |
20 | if sbid == "*": | |
21 | for bot in cache.bots.values(): | |
22 | if bot.online: bot.msg(target, msg) | |
23 | elif cache.isonline(bid): | |
24 | cache.bots[bid].msg(target, msg) | |
25 | else: | |
26 | bot.msg(nick, "No such bot, or offline.") | |
27 | def act(nick, target, params, bot, cache): | |
28 | pieces = params.split() | |
29 | sbid = pieces[0] | |
30 | bid = toint(sbid) | |
31 | target = pieces[1] | |
32 | msg = ' '.join(pieces[2:]) | |
33 | if sbid == "*": | |
34 | for bot in cache.bots.values(): | |
35 | if bot.online: bot.raw("PRIVMSG %s :\1ACTION %s\1" % (target, msg)) | |
36 | elif cache.isonline(bid): | |
37 | cache.bots[bid].raw("PRIVMSG %s :\1ACTION %s\1" % (target, msg)) | |
38 | else: | |
39 | bot.msg(nick, "No such bot, or offline.") | |
40 | ||
41 | ||
42 | def helpsend(): return ['ADMINSEND <bid> <nick|#channel> <msg>', 'Sends a PRIVMSG (#channel) or NOTICE (nick).'] | |
43 | def helpact(): return ['ADMINACT <bid> <nick|#channel> <msg>', 'Sends an ACTION (/me).'] |