def approve(self, mess, args): """An admin-only command""" admin = str(mess.getFrom()).split('@')[0] in admins if not admin: return 'You are not admin' if len(args.split()) >= 1: if args.lower() in infobits.keys() and not infobits.get(args, ('not found', True))[1]: self.setbit(mess, args) infobits.update({' '.join(args.lower().split('_')): (infobits.get(args, ('not found', True))[0], True)}) return 'InfoBit Approved' return 'Error'
def lookup(self, mess, args): """Look up a word in the very small and useless dictionary This command looks for infobits set with the setbit command Upd8! It also ducks anything not found in the dictionary and W|As anything duckduckgo doesn't know""" admin = str(mess.getFrom()).split('@')[0] in admins if args.lower() in infobits.keys() and infobits.get(args, ('not found', True))[1]: return infobits.get(args.lower(), ('not found', True))[0] elif args.lower() in infobits.keys() and not infobits.get(args, ('not found', True))[1] and admin: return 'This infobit is not yet approved: ' + infobits.get(args.lower(), ('not found', True))[0] res = ddg.query(args.lower()) out = '' abstext = unicode(res.abstract.text) if abstext: out += 'From DuckDuckGo: ' + abstext elif res.related: for resu in res.related: if resu.text: out += resu.text + '\n' if out: return out return self.wa(mess, args) return 'That infobit either doesn\'t exist, or has not been approved'