return lib.modstop(*args, **kwargs)
# module code
-import json
+import json, sys
+if sys.version_info.major >= 3:
+ import builtins as __builtin__
+ stringbase = str
+else:
+ import __builtin__
+ stringbase = basestring
#setup
def gotParent():
if isinstance(thing, parent.User):
if thing.auth is not None:
return "#"+thing.auth
- elif isinstance(thing, basestring):
+ elif isinstance(thing, stringbase):
if thing.startswith("#"):
return thing
else:
return None
def keys(user):
- return list(set(db.get(_getauth(user), {}).keys() + db.get(str(user).lower(), {}).keys())) #list-to-set-to-list to remove duplicates
+ return list(__builtin__.set(list(db.get(_getauth(user), {}).keys()) + list(db.get(str(user).lower(), {}).keys()))) #list-to-set-to-list to remove duplicates
def has(user, key):
key = key.lower()
return (
@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: replyto = chan
- else: replyto = user
-
if len(args) > 0:
target = args[0]
else:
target = user
- bot.msg(replyto, "%(user)s: %(target)s has the following info items: %(items)s" % {'user':user,'target':target,'items':(', '.join(keys(target)))})
+ return "%(target)s has the following info items: %(items)s" % {'target':target,'items':(', '.join(keys(target)))}
@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: replyto = chan
- else: replyto = user
-
if len(args) > 1:
target = args[0]
item = args[1]
value = get(target, item, None)
if value is None:
- bot.msg(replyto, "%(user)s: %(item)s on %(target)s is not set." % {'user':user,'item':item,'target':target})
+ return "%(item)s on %(target)s is not set." % {'item':item,'target':target}
else:
- bot.msg(replyto, "%(user)s: %(item)s on %(target)s: %(value)s" % {'user':user,'item':item,'target':target,'value':value})
+ return "%(item)s on %(target)s: %(value)s" % {'item':item,'target':target,'value':value}
@lib.hook(needchan=False)
@lib.help("<item> <value>", "sets an info item about you")