def handle_alladd(bot, ievent): """ add a command to the allow all list. """ if not ievent.rest: ievent.missing('<command>') return target = aliasget(ievent.rest) or ievent.rest if not 'OPER' in cmnds.perms(target): bot.state['allowed'].append(target) bot.state.save() ievent.reply('%s command is now allowed for all clients' % target) else: ievent.reply('sorry')
def handle_perm(bot, ievent): """ perm <command> .. get permission of command. """ try: cmnd = ievent.args[0] except IndexError: ievent.missing("<cmnd>") return try: cmnd = aliases.data[cmnd] except KeyError: pass perms = cmnds.perms(cmnd) if perms: ievent.reply("%s command needs %s permission" % (cmnd, perms)) return ievent.reply("can't find perm for %s" % cmnd)
def gendoc(f): base = os.path.basename(f).replace('.py', '') print '=' * (len(base) + 2) print ' %s ' % base.upper() print '=' * (len(base) + 2) print "| \n" print "about" print "-----" print "| \n" try: author = plugins.plugs[base].__author__ print ":author: %s" % author.strip() except AttributeError: print ":author: Bart Thate <*****@*****.**>" print ":contact: IRCNET/#dunkbots" if 'gozerplugs' in f: print ':distribution: core' else: print ":distribution: http://plugins.gozerbot.org" try: license = plugins.plugs[base].__license__ print ":license: %s" % license.strip() except AttributeError: print ":license: Public Domain" print " " print "| \n" data = {'author': 'unknown', 'description': '', 'commands':[], 'examples':{}, \ 'descriptions':{}, 'callbacks': {}, 'aliases': {}, 'permissions': {}} data['description'] = plughelp[base] cmndlist = [] for j, z in cmnds.iteritems(): if j in donot: continue if z.plugname == base: cmndlist.append(j) relist = [] for reitem in rebefore.relist: if reitem.plugname == base: relist.append(reitem) for reitem in reafter.relist: if reitem.plugname == base: relist.append(reitem) cmndlist.sort() try: first = plugins.plugs[base].__gendocfirst__ for i in first[::-1]: try: cmndlist.remove(i) except ValueError: continue cmndlist.insert(0, i) except AttributeError: pass try: first = plugins.plugs[base].__gendoclast__ for i in first[::-1]: try: cmndlist.remove(i) except ValueError: continue cmndlist.append(i) except AttributeError: pass try: skip = plugins.plugs[base].__gendocskip__ for i in skip[::-1]: try: cmndlist.remove(i) except ValueError: continue except AttributeError: pass for command in cmndlist: data['commands'].append(command) alias = aliasreverse(command) if alias: data['aliases'][command] = alias try: ex = examples[command] except Exception, exx: continue try: data['permissions'][command] = cmnds.perms(command) except: pass data['examples'][command] = [] exampleslist = re.split('\d\)', ex.example) for e in exampleslist: data['examples'][command].append(e.strip()) data['descriptions'][command] = ex.descr
def gendoc(f): base = os.path.basename(f).replace(".py", "") print "=" * (len(base) + 2) print " %s " % base.upper() print "=" * (len(base) + 2) print "| \n" print "about" print "-----" print "| \n" try: author = plugins.plugs[base].__author__ print ":author: %s" % author.strip() except AttributeError: print ":author: Bart Thate <*****@*****.**>" print ":contact: IRCNET/#dunkbots" if "gozerplugs" in f: print ":distribution: core" else: print ":distribution: http://plugins.gozerbot.org" try: license = plugins.plugs[base].__license__ print ":license: %s" % license.strip() except AttributeError: print ":license: Public Domain" print " " print "| \n" data = { "author": "unknown", "description": "", "commands": [], "examples": {}, "descriptions": {}, "callbacks": {}, "aliases": {}, "permissions": {}, } data["description"] = plughelp[base] cmndlist = [] for j, z in cmnds.iteritems(): if j in donot: continue if z.plugname == base: cmndlist.append(j) relist = [] for reitem in rebefore.relist: if reitem.plugname == base: relist.append(reitem) for reitem in reafter.relist: if reitem.plugname == base: relist.append(reitem) cmndlist.sort() try: first = plugins.plugs[base].__gendocfirst__ for i in first[::-1]: try: cmndlist.remove(i) except ValueError: continue cmndlist.insert(0, i) except AttributeError: pass try: first = plugins.plugs[base].__gendoclast__ for i in first[::-1]: try: cmndlist.remove(i) except ValueError: continue cmndlist.append(i) except AttributeError: pass try: skip = plugins.plugs[base].__gendocskip__ for i in skip[::-1]: try: cmndlist.remove(i) except ValueError: continue except AttributeError: pass for command in cmndlist: data["commands"].append(command) alias = aliasreverse(command) if alias: data["aliases"][command] = alias try: ex = examples[command] except Exception, exx: continue try: data["permissions"][command] = cmnds.perms(command) except: pass data["examples"][command] = [] exampleslist = re.split("\d\)", ex.example) for e in exampleslist: data["examples"][command].append(e.strip()) data["descriptions"][command] = ex.descr