]> jfr.im git - erebus.git/blame - modules/msg.py
use new bind_bot, make sure the bot-on-channel sends the replies
[erebus.git] / modules / msg.py
CommitLineData
f717c856 1# Erebus IRC bot - Author: Erebus Team
4477123d 2# vim: fileencoding=utf-8
f717c856 3# This file is released into the public domain; see http://unlicense.org/
4
5# module info
6modinfo = {
7 'author': 'Erebus Team',
8 'license': 'public domain',
fa93b933 9 'compatible': [0],
f717c856 10 'depends': [],
11 'softdeps': ['help'],
12}
13
14# preamble
15import modlib
16lib = modlib.modlib(__name__)
17modstart = lib.modstart
18modstop = lib.modstop
19
20# module code
52e1dab3 21import time
22
adbee2da 23@lib.hook(('say','cmsg'), clevel=lib.OP)
f717c856 24@lib.help('<message>', 'sends message to channel')
25@lib.argsGE(1)
adbee2da 26def say(bot, user, chan, realtarget, *args):
f717c856 27 chan.msg(' '.join(args))
28
29
30def _getbot(bot, user, chan, realtarget, *args):
31 target = None
fd07173d 32 if args[0].startswith("#"):
f717c856 33 target = bot.parent.channel(args[0])
f717c856 34 sendbot = target.bot
f717c856 35 else:
36 target = args[0]
37 sendbot = bot.parent.randbot()
f717c856 38 return (target, sendbot)
39
40@lib.hook(glevel=lib.STAFF, needchan=False)
41@lib.help('<target> <message>', 'send message to target')
42@lib.argsGE(2)
43def msg(bot, user, chan, realtarget, *args):
44 target, sendbot = _getbot(bot, user, chan, realtarget, *args)
45 sendbot.msg(target, ' '.join(args[1:]))
46
47@lib.hook(glevel=lib.STAFF, needchan=False)
48@lib.help('<target> <message>', 'send message to target as PRIVMSG')
49def pmsg(bot, user, chan, realtarget, *args):
50 target, sendbot = _getbot(bot, user, chan, realtarget, *args)
51 sendbot.conn.send("PRIVMSG %s :%s" % (args[0], ' '.join(args[1:])))
52
52e1dab3 53@lib.hook(glevel=lib.MANAGER, needchan=False)
54@lib.argsEQ(1)
f717c856 55def moo(bot, user, chan, realtarget, *args):
52e1dab3 56 lines= [' .= , =.', " _ _ /'/ )\\,/,/(_ \\ \\", ' `//-.| ( ,\\\\)\\//\\)\\/_ ) |', " //___\\ `\\\\\\/\\\\/\\/\\\\///' /", ',-"~`-._ `"--\'_ `"""` _ \\`\'"~-,_', '\\ `-. \'_`. .\'_` \\ ,-"~`/', " `.__.-'`/ (-\\ /-) |-.__,'", ' || | \\O) /^\\ (O/ |', ' `\\\\ | / `\\ /', ' \\\\ \\ / `\\ /', " `\\\\ `-. /' .---.--.\\", " `\\\\/`~(, '() ('", ' /(O) \\\\ _,.-.,_)', " // \\\\ `\\'` /", ' / | || `""""~"`', " /' |__||", ' `o']
6da88962 57 bots = list(bot.parent.bots.values())
52e1dab3 58 for i in range(len(lines)):
6da88962 59 sender = bots[i%len(bots)]
52e1dab3 60 mylen = len(sender.nick)
61 padding = 15-mylen
62 sender.fastmsg(args[0], " "*padding + lines[i])