X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/a62d0d18bbb5926d22df18db5eba53eb21a10817..656dc5a4759b810a632859a32721493e522748a1:/modules/userinfo.py diff --git a/modules/userinfo.py b/modules/userinfo.py index be6e33b..74a70e2 100644 --- a/modules/userinfo.py +++ b/modules/userinfo.py @@ -6,7 +6,7 @@ modinfo = { 'author': 'Erebus Team', 'license': 'public domain', - 'compatible': [1,2], + 'compatible': [2], 'depends': [], 'softdeps': ['help'], } @@ -44,7 +44,7 @@ def getauth(thing): if thing.auth is not None: return "#"+thing.auth elif isinstance(thing, basestring): - if thing[0] == "#": + if thing.startswith("#"): return thing else: if parent.user(thing).auth is not None: @@ -54,11 +54,13 @@ def getauth(thing): 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 def _has(user, key): + key = key.lower() return ( key in db.get(getauth(user), {}) or key in db.get(str(user).lower(), {}) ) def _get(user, key, default=None): + key = key.lower() return ( db.get(getauth(user), {}). #try to get the auth get(key, #try to get the info-key by auth @@ -67,15 +69,16 @@ def _get(user, key, default=None): default #otherwise throw out whatever default ))) def _set(user, key, value): + key = key.lower() if getauth(user) is not None: db.setdefault(getauth(user), {})[key] = value #use auth if we can db.setdefault(str(user).lower(), {})[key] = value #but set nick too #commands -@lib.hook(needchan=False) +@lib.hook(needchan=False, wantchan=True) @lib.help("[]", "lists info items known about someone", " 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 +88,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("[] ", "gets an info item about someone", " 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: