]> jfr.im git - z_archive/Ophion.git/blame - modules/autoload/adminmsg.py
Initialize repo
[z_archive/Ophion.git] / modules / autoload / adminmsg.py
CommitLineData
b069ba10
JR
1from classes import *
2from util import *
3
4name = 'admin messaging'
5def 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)
9def deinit(cache):
10 cache.currmod = __name__
11 cache.unhookcmd('ADMINSEND')
12 cache.unhookcmd('ADMINACT')
13
14def 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.")
27def 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
42def helpsend(): return ['ADMINSEND <bid> <nick|#channel> <msg>', 'Sends a PRIVMSG (#channel) or NOTICE (nick).']
43def helpact(): return ['ADMINACT <bid> <nick|#channel> <msg>', 'Sends an ACTION (/me).']