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