]> jfr.im git - erebus.git/commitdiff
fix bug in determining where to send reply
authorzonidjan <redacted>
Mon, 14 Dec 2015 14:00:10 +0000 (08:00 -0600)
committerzonidjan <redacted>
Mon, 14 Dec 2015 14:00:10 +0000 (08:00 -0600)
modules/control.py
modules/eval.py
modules/foo.py
modules/module.py [deleted file]
modules/resources.py

index 0448c49931afca091c7165d831ee4f12c46f684e..3befa4d8d5a3832d1c3b40925eee69b613f32cbe 100644 (file)
@@ -1,5 +1,5 @@
 # Erebus IRC bot - Author: Erebus Team
-# !EVAL and !EXEC commands
+# Various highly recommended "control" commands.
 # This file is released into the public domain; see http://unlicense.org/
 
 # module info
@@ -25,3 +25,38 @@ import ctlmod
 def cmd_die(bot, user, chan, realtarget, *args):
        sys.exit(0)
        os._exit(0)
+
+@lib.hook('modload', needchan=False, glevel=lib.MANAGER)
+@lib.argsEQ(1)
+def cmd_modload(bot, user, chan, realtarget, *args):
+       okay = ctlmod.load(bot.parent, args[0])
+       if okay:
+               bot.msg(user, "Loaded %s" % (args[0]))
+       else:
+               bot.msg(user, "Error loading %s: %r" % (args[0], okay))
+
+@lib.hook('modunload', needchan=False, glevel=lib.MANAGER)
+@lib.argsEQ(1)
+def cmd_modunload(bot, user, chan, realtarget, *args):
+       okay = ctlmod.unload(bot.parent, args[0])
+       if okay:
+               bot.msg(user, "Unloaded %s" % (args[0]))
+       else:
+               bot.msg(user, "Error unloading %s: %r" % (args[0], okay))
+
+@lib.hook('modreload', needchan=False, glevel=lib.MANAGER)
+@lib.argsEQ(1)
+def cmd_modreload(bot, user, chan, realtarget, *args):
+       okay = ctlmod.reloadmod(bot.parent, args[0])
+       if okay:
+               bot.msg(user, "Reloaded %s" % (args[0]))
+       else:
+               bot.msg(user, "Error occurred: %r" % (okay))
+
+@lib.hook('modlist', needchan=False, glevel=lib.STAFF)
+@lib.argsEQ(0)
+def cmd_modlist(bot, user, chan, realtarget, *args):
+       mods = ctlmod.modules
+       for mod in mods.itervalues():
+               bot.msg(user, "- %s %r" % (mod.__name__, mod))
+       bot.msg(user, "Done.")
index 61344688479301ec66e2f294f6c351efbbe468a2..d248b5396b4f16c35aa828c42964fa03c5ca198c 100644 (file)
@@ -27,7 +27,7 @@ def module(name):
 @lib.hook('eval', needchan=False, glevel=lib.MANAGER)
 @lib.argsGE(1)
 def cmd_eval(bot, user, chan, realtarget, *args):
-       if chan is not None: replyto = chan
+       if realtarget == chan.name: replyto = chan
        else: replyto = user
 
        try: ret = eval(' '.join(args))
@@ -39,7 +39,7 @@ def cmd_eval(bot, user, chan, realtarget, *args):
 @lib.hook('exec', needchan=False, glevel=lib.MANAGER)
 @lib.argsGE(1)
 def cmd_exec(bot, user, chan, realtarget, *args):
-       if chan is not None: replyto = chan
+       if realtarget == chan.name: replyto = chan
        else: replyto = user
 
        try: exec ' '.join(args)
index 8063afb5e22d44e158b381cda1a73dbe97b4f3ed..9dbf29f7e5327b5a1edbb74576665c6e39f77e22 100644 (file)
@@ -19,7 +19,7 @@ modstop = lib.modstop
 # module code
 @lib.hook('test', needchan=False)
 def cmd_gtest(bot, user, chan, realtarget, *args):
-       if chan is not None: replyto = chan
+       if realtarget == chan.name: replyto = chan
        else: replyto = user
 
        bot.msg(replyto, "You said: %s" % (' '.join([str(arg) for arg in args])))
diff --git a/modules/module.py b/modules/module.py
deleted file mode 100644 (file)
index bcccaa2..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-# Erebus IRC bot - Author: Erebus Team
-# module control through irc
-# This file is released into the public domain; see http://unlicense.org/
-
-# module info
-modinfo = {
-       'author': 'Erebus Team',
-       'license': 'public domain',
-       'compatible': [1], # compatible module API versions
-       'depends': [], # other modules required to work properly?
-}
-
-# preamble
-import modlib
-lib = modlib.modlib(__name__)
-modstart = lib.modstart
-modstop = lib.modstop
-
-# module code
-import ctlmod
-
-@lib.hook('modload', needchan=False, glevel=lib.MANAGER)
-@lib.argsEQ(1)
-def cmd_modload(bot, user, chan, realtarget, *args):
-       okay = ctlmod.load(bot.parent, args[0])
-       if okay:
-               bot.msg(user, "Loaded %s" % (args[0]))
-       else:
-               bot.msg(user, "Error loading %s: %r" % (args[0], okay))
-
-@lib.hook('modunload', needchan=False, glevel=lib.MANAGER)
-@lib.argsEQ(1)
-def cmd_modunload(bot, user, chan, realtarget, *args):
-       okay = ctlmod.unload(bot.parent, args[0])
-       if okay:
-               bot.msg(user, "Unloaded %s" % (args[0]))
-       else:
-               bot.msg(user, "Error unloading %s: %r" % (args[0], okay))
-
-@lib.hook('modreload', needchan=False, glevel=lib.MANAGER)
-@lib.argsEQ(1)
-def cmd_modreload(bot, user, chan, realtarget, *args):
-       okay = ctlmod.reloadmod(bot.parent, args[0])
-       if okay:
-               bot.msg(user, "Reloaded %s" % (args[0]))
-       else:
-               bot.msg(user, "Error occurred: %r" % (okay))
-
-@lib.hook('modlist', needchan=False, glevel=lib.STAFF)
-@lib.argsEQ(0)
-def cmd_modlist(bot, user, chan, realtarget, *args):
-       mods = ctlmod.modules
-       for mod in mods.itervalues():
-               bot.msg(user, "- %s %r" % (mod.__name__, mod))
-       bot.msg(user, "Done.")
index 110b4d55024df076f269f227a1b267d51fbd6f78..1a4e3c5ed902156efea58aedb695fc098cb611c2 100644 (file)
@@ -21,7 +21,7 @@ import resource
 
 @lib.hook('ram', needchan=False, glevel=lib.MANAGER)
 def cmd_ram(bot, user, chan, realtarget, *args):
-       if chan is not None: replyto = chan
+       if realtarget == chan.name: replyto = chan
        else: replyto = user
 
        try:
@@ -33,7 +33,7 @@ def cmd_ram(bot, user, chan, realtarget, *args):
 
 @lib.hook('resources', needchan=False, glevel=lib.MANAGER)
 def cmd_resources(bot, user, chan, realtarget, *args):
-       if chan is not None: replyto = chan
+       if realtarget == chan.name: replyto = chan
        else: replyto = user
 
        try: