]> jfr.im git - erebus.git/blobdiff - modules/msg.py
urls - allow port in url
[erebus.git] / modules / msg.py
index 59082468d74a3f5a612c7f0001953d5f6ea4426f..5261f4cb555b037832f87fb94cd3945531b85b84 100644 (file)
@@ -1,11 +1,13 @@
 # Erebus IRC bot - Author: Erebus Team
+# vim: fileencoding=utf-8
+# Commands to message various destinations
 # This file is released into the public domain; see http://unlicense.org/
 
 # module info
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [0],
        'depends': [],
        'softdeps': ['help'],
 }
@@ -17,25 +19,23 @@ modstart = lib.modstart
 modstop = lib.modstop
 
 # module code
-@lib.hook(clevel=lib.OP)
+import time
+
+@lib.hook(('say','cmsg'), clevel=lib.OP)
 @lib.help('<message>', 'sends message to channel')
 @lib.argsGE(1)
-def cmsg(bot, user, chan, realtarget, *args):
+def say(bot, user, chan, realtarget, *args):
        chan.msg(' '.join(args))
 
 
 def _getbot(bot, user, chan, realtarget, *args):
        target = None
-       if args[0][0] == "#":
+       if args[0].startswith("#"):
                target = bot.parent.channel(args[0])
-               print "target = %s" % (target)
-       if target is not None:
                sendbot = target.bot
-               print "bot = %s" % (sendbot)
        else:
                target = args[0]
                sendbot = bot.parent.randbot()
-               print "bot = random"
        return (target, sendbot)
 
 @lib.hook(glevel=lib.STAFF, needchan=False)
@@ -51,7 +51,13 @@ def pmsg(bot, user, chan, realtarget, *args):
        target, sendbot = _getbot(bot, user, chan, realtarget, *args)
        sendbot.conn.send("PRIVMSG %s :%s" % (args[0], ' '.join(args[1:])))
 
-@lib.hook()
+@lib.hook(glevel=lib.MANAGER, needchan=False)
+@lib.argsEQ(1)
 def moo(bot, user, chan, realtarget, *args):
-       for i in ['          .=     ,        =.\n', "  _  _   /'/    )\\,/,/(_   \\ \\\n", '   `//-.|  (  ,\\\\)\\//\\)\\/_  ) |\n', "   //___\\   `\\\\\\/\\\\/\\/\\\\///'  /\n", ',-"~`-._ `"--\'_   `"""`  _ \\`\'"~-,_\n', '\\       `-.  \'_`.      .\'_` \\ ,-"~`/\n', " `.__.-'`/   (-\\        /-) |-.__,'\n", '   ||   |     \\O)  /^\\ (O/  |\n', '   `\\\\  |         /   `\\    /\n', '     \\\\  \\       /      `\\ /\n', "      `\\\\ `-.  /' .---.--.\\\n", "        `\\\\/`~(, '()      ('\n", '         /(O) \\\\   _,.-.,_)\n', "        //  \\\\ `\\'`      /\n", '       / |  ||   `""""~"`\n', "     /'  |__||\n", '           `o\n']:
-               bot.fastmsg(chan, i.rstrip("\n"))
+       lines= ['          .=     ,        =.', "  _  _   /'/    )\\,/,/(_   \\ \\", '   `//-.|  (  ,\\\\)\\//\\)\\/_  ) |', "   //___\\   `\\\\\\/\\\\/\\/\\\\///'  /", ',-"~`-._ `"--\'_   `"""`  _ \\`\'"~-,_', '\\       `-.  \'_`.      .\'_` \\ ,-"~`/', " `.__.-'`/   (-\\        /-) |-.__,'", '   ||   |     \\O)  /^\\ (O/  |', '   `\\\\  |         /   `\\    /', '     \\\\  \\       /      `\\ /', "      `\\\\ `-.  /' .---.--.\\", "        `\\\\/`~(, '()      ('", '         /(O) \\\\   _,.-.,_)', "        //  \\\\ `\\'`      /", '       / |  ||   `""""~"`', "     /'  |__||", '           `o']
+       bots = list(bot.parent.bots.values())
+       for i in range(len(lines)):
+               sender = bots[i%len(bots)]
+               mylen = len(sender.nick)
+               padding = 15-mylen
+               sender.fastmsg(args[0], " "*padding + lines[i])