# 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'],
}
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': [],
}
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': ['help'],
}
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': ['help'],
}
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))
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)
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
}
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])))
@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")
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': [],
}
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': ['help'],
}
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': ['help'],
}
# 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:
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:
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': ['help'],
}
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': ['userinfo'],
'softdeps': ['help'],
}
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():
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 None: eplyto = chan
else: replyto = user
if len(args) != 0: who = args[0]
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']:
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]
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': [],
}
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1,2],
+ 'compatible': [2],
'depends': [],
'softdeps': ['help'],
}
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:
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: