]> jfr.im git - erebus.git/commitdiff
module cleanup
authorzonidjan <redacted>
Thu, 5 Oct 2017 02:16:48 +0000 (21:16 -0500)
committerzonidjan <redacted>
Thu, 5 Oct 2017 02:16:48 +0000 (21:16 -0500)
12 files changed:
modules/chanops.py
modules/coins.py
modules/control.py
modules/eval.py
modules/foo.py
modules/help.py
modules/msg.py
modules/resources.py
modules/sms.py
modules/trivia.py
modules/urls.py
modules/userinfo.py

index 7d8f40ceb840b1bd9fc4dcef50f4756075d386e1..bf73449e1ed02a2973a3c35763aba56cd5901311 100644 (file)
@@ -1,12 +1,12 @@
 # Erebus IRC bot - Author: Erebus Team
-# !EVAL and !EXEC commands
+# chanop commands
 # 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': [2],
        'depends': [],
        'softdeps': ['help'],
 }
index 5b3d663a34b090b2cbe60e97d409f695859cd0bf..b48982132b238ab529ae87bc3e176a5657264b36 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': [],
 }
index c4caaf3089052f3303c46f6112d226e65460012e..e00d013d283f186dd05f1da5128e7dc71c7d6c3f 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': ['help'],
 }
index d2b82c83567e2005d5936e8d714b8139790b72d0..0ebb5ac146e8091581da209d501afba9056561cb 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': ['help'],
 }
@@ -25,11 +25,11 @@ import ctlmod
 def module(name):
        return lib.mod(name)
 
-@lib.hook('eval', needchan=False, glevel=lib.MANAGER)
+@lib.hook('eval', needchan=False, wantchan=True, glevel=lib.MANAGER)
 @lib.help("<python>", "eval")
 @lib.argsGE(1)
 def cmd_eval(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        try: ret = eval(' '.join(args))
@@ -37,11 +37,11 @@ def cmd_eval(bot, user, chan, realtarget, *args):
        else: bot.msg(replyto, "Done: %r" % (ret,))
 
 
-@lib.hook('exec', needchan=False, glevel=lib.MANAGER)
+@lib.hook('exec', needchan=False, wantchan=True, glevel=lib.MANAGER)
 @lib.help("<python>", "exec")
 @lib.argsGE(1)
 def cmd_exec(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        try: exec ' '.join(args)
index bb56be0944e2b3f506bde9a299268b512c0c5a3b..54e1b5192fe912d9402a6a2ef4e29d8c716d7c81 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2], # compatible module API versions
+       'compatible': [2], # compatible module API versions
        'depends': [], # other modules required to work properly?
        'softdeps': ['help'], # modules which are preferred but not required
 }
@@ -23,10 +23,10 @@ modstart = lib.modstart
 modstop = lib.modstop
 
 # module code
-@lib.hook(needchan=False) #since no cmd= is provided, defaults to function name
+@lib.hook(needchan=False, wantchan=True) #since no cmd= is provided, defaults to function name
 @lib.help('<args>', 'tells you what you said')
 def test(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        bot.msg(replyto, "You said: %s" % (' '.join([str(arg) for arg in args])))
@@ -40,3 +40,10 @@ def foobar(bot, user, chan, realtarget, *args):
 @lib.help(None, 'a command that does nothing but requires you specify a channel')
 def needchan(bot, user, chan, realtarget, *args):
        bot.msg(user, "You did it!")
+
+@lib.hook(needchan=False, wantchan=True)
+@lib.help(None, 'a command which will consume a channel if given')
+       if chan is not None:
+               bot.msg(user, "Channel provided: %s" % (chan))
+       else:
+               bot.msg(user, "No channel provided")
index 63541f8b4ddd3333b5d0d2d67e8fc9452626685d..27c80b7eafb48a19bb45f887a3966fc5f8e39db8 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': [],
 }
index 1df017c97ef23979b61584af864062c24de04590..4e3b23fae06200686b9f63941864e601144823a5 100644 (file)
@@ -5,7 +5,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': ['help'],
 }
index 016e4bdb85913ada2775615eff5f5b1becc4ffe0..dacda2310e9f677ef9b8008f59ad6540fa13ef1e 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': ['help'],
 }
@@ -20,10 +20,10 @@ modstop = lib.modstop
 # module code
 import resource
 
-@lib.hook(needchan=False, glevel=lib.MANAGER)
+@lib.hook(needchan=False, wantchan=True, glevel=lib.MANAGER)
 @lib.help(None, "show RAM usage")
 def ram(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        try:
@@ -33,10 +33,10 @@ def ram(bot, user, chan, realtarget, *args):
 
        bot.fastmsg(replyto, "Memory usage (MiB): %r" % (res.ru_maxrss/1024.0))
 
-@lib.hook(needchan=False, glevel=lib.MANAGER)
+@lib.hook(needchan=False, wantchan=True, glevel=lib.MANAGER)
 @lib.help(None, "show resource usage")
 def resources(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        try:
index 16077a3244edd61c20b84f77b81d6df333571990..e3884487ca53e9ac451f559ca67d35cbe5dc026f 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': ['help'],
 }
index cba7a72ac7cc56afb80224753700db3d4502dc8c..63143f4dc81b3155767648105d22c871b4e09dc3 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': ['userinfo'],
        'softdeps': ['help'],
 }
@@ -411,10 +411,10 @@ def trivia_checkanswer(bot, user, chan, *args):
                        bot.msg(chan, "\00312%s\003 got an extra point for getting it before the hints! New score: %d." % (user, state.addpoint(user)))
                state.nextquestion()
 
-@lib.hook(glevel=1, needchan=False)
+@lib.hook(glevel=1, needchan=False, wantchan=True)
 @lib.help(None, "saves the trivia database")
 def save(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        if state.savedb():
@@ -422,10 +422,10 @@ def save(bot, user, chan, realtarget, *args):
        else:
                bot.msg(replyto, "Save failed!")
 
-@lib.hook(needchan=False)
+@lib.hook(needchan=False, wantchan=True)
 @lib.help("[<user>]", "shows how many points you or someone has")
 def points(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not Noneeplyto = chan
        else: replyto = user
 
        if len(args) != 0: who = args[0]
@@ -480,10 +480,10 @@ def setnext(bot, user, chan, realtarget, *args):
 def skip(bot, user, chan, realtarget, *args):
        state.nextquestion(qskipped=True, skipwait=True)
 
-@lib.hook(needchan=False)
+@lib.hook(needchan=False, wantchan=True)
 @lib.help(None, "starts the trivia game")
 def start(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        if chan is not None and chan.name != state.db['chan']:
@@ -568,10 +568,10 @@ def delbadq(bot, user, chan, realtarget, *args):
        except:
                bot.msg(user, "Failed!")
 
-@lib.hook(needchan=False)
+@lib.hook(needchan=False, wantchan=True)
 @lib.help("[<user>]", "shows you or someone else's rank")
 def rank(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        if len(args) != 0: who = args[0]
index fc398e26913c87aa1d793ce05fed2467debb2467..10e475b20b19333b3be554020c32885711431502 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': [],
 }
index bd150539bc023daf496ee413d7ae87abdb6cda81..03545a606241ffb7aa936600bf23be02365b278b 100644 (file)
@@ -6,7 +6,7 @@
 modinfo = {
        'author': 'Erebus Team',
        'license': 'public domain',
-       'compatible': [1,2],
+       'compatible': [2],
        'depends': [],
        'softdeps': ['help'],
 }
@@ -72,10 +72,10 @@ def _set(user, key, value):
        db.setdefault(str(user).lower(), {})[key] = value #but set nick too
 
 #commands
-@lib.hook(needchan=False)
+@lib.hook(needchan=False, wantchan=True)
 @lib.help("[<target>]", "lists info items known about someone", "<target> may be a nick, or an auth in format '#auth'", "it defaults to yourself")
 def getitems(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        if len(args) > 0:
@@ -85,11 +85,11 @@ def getitems(bot, user, chan, realtarget, *args):
 
        bot.msg(replyto, "%(user)s: %(target)s has the following info items: %(items)s" % {'user':user,'target':target,'items':(', '.join(_keys(target)))})
 
-@lib.hook(needchan=False)
+@lib.hook(needchan=False, wantchan=True)
 @lib.help("[<target>] <item>", "gets an info item about someone", "<target> may be a nick, or an auth in format '#auth'", "it defaults to yourself")
 @lib.argsGE(1)
 def getinfo(bot, user, chan, realtarget, *args):
-       if chan is not None and realtarget == chan.name: replyto = chan
+       if chan is not None: replyto = chan
        else: replyto = user
 
        if len(args) > 1: