def load(): global gCommands services.register("auth", group_auth) gCommands = {'group_create':group_create, 'group_delete':group_delete, 'power_create':power_create, 'power_give':power_give, 'power_revoke':power_revoke, 'power_delete':power_delete, 'user_create':user_create, 'user_join':user_join, 'user_leave':user_leave, 'user_delete':user_delete} es.regcmd('gauth', 'examples/auth/group_auth/command_extra', 'Create groups, players, etc, via the group_auth script addon.') es.sql('open','group_auth','|examples/auth/group_auth') test = es.sql('queryvalue', 'group_auth', "SELECT COUNT(name) as num FROM sqlite_master WHERE type='table';") if not int(test): init_db()
def setUp(self): # lets suppress some noise debug = es.ServerVar("eventscripts_debug") olddebug = int(debug) if int(debug) == 0: debug.set(-1) es.regcmd("pycommand", "pyunittest/cmdtest_run", "Stuff") debug.set(olddebug) es.regsaycmd("pycommand","pyunittest/cmdtest_run", "Stuff") es.regclientcmd("pycommand","pyunittest/cmdtest_run", "Stuff")
def setUp(self): # lets suppress some noise debug = es.ServerVar("eventscripts_debug") olddebug = int(debug) if int(debug) == 0: debug.set(-1) es.regcmd("pycommand", "pyunittest/cmdtest_run", "Stuff") debug.set(olddebug) es.regsaycmd("pycommand", "pyunittest/cmdtest_run", "Stuff") es.regclientcmd("pycommand", "pyunittest/cmdtest_run", "Stuff")
def registerServerCommand(self, name, callback, description, skipcheck=False): """ Registeres a server command to a callback function """ self._validateCallback(callback) name = str(name) if name not in self.ex_server_commands: if es.exists('variable', name) or (not skipcheck and es.exists('command', name)): raise NameError(f"'{name}' is in use as a server command or variable") es.regcmd(name, '_cmdlib/server', description) self.server_commands[name] = Command(name, callback) if name in self.ex_server_commands: self.ex_server_commands.remove(name)
def registerServerCommand(self, name, callback, description, skipcheck=False): """ Registeres a server command to a callback function """ self._validateCallback(callback) name = str(name) if name not in self.ex_server_commands: if es.exists('variable', name) or (not skipcheck and es.exists('command', name)): raise NameError, "'%s' is in use as a server command or variable" % name es.regcmd(name, '_cmdlib/server', description) self.server_commands[name] = Command(name, callback) if name in self.ex_server_commands: self.ex_server_commands.remove(name)
def exp_reg(args_dummy): argc = es.getargc() if argc > 3: global funcs global funcsregex global regex1 block = es.getargv(2) func = es.getargv(1) minargs = es.getargv(3) if not func in funcs: if re.match('^.+/.+(/.+)?$', block): if es.exists('block', block): if argc > 4: global funccmds userfunc = '_exp_userfunc' + str(len(funccmds) + 1) es.regcmd(userfunc, block, 'exp user function') funcs[func] = {} funccmds.append(userfunc) funcs[func]['function'] = userfunc funcs[func]['minargs'] = int(minargs) funcs[func]['var'] = es.getargv(4) funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg( 0, 'exp_reg : input variable name must be given for function block' ) else: es.dbgmsg(0, 'exp_reg : invalid block given') elif re.match('^.+\\..+(\\..+)?$', block): temp = block.split('.') exec('temp = callable(' + block + ')') if temp: exec('funcs[func][\'function\'] = ' + block) funcs[func]['minargs'] = minargs funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg(0, 'exp_reg : invalid function given') else: es.dbgmsg(0, 'exp_reg : invalid block/function given') else: es.dbgmsg(0, 'exp_reg : function already registered') else: es.dbgmsg( 0, 'Syntax : exp_reg <function-name> <function/block> <min-args> [var]' )
def load(): dbg( '') dbg( 'XS: Loading...') if not callable(getattr(popuplib,'easylist',None)): es.dbgmsg(0,'XS: Popuplib version too old! Please update!') es.unload('extendedstats') return loadPackages() loadAddons() fillDatabase() loadToplist() saycommands[re.compile('\A%s%s' % (scfg.say_command_prefix,scfg.command_help))] = cmd_help es.addons.registerSayFilter(sayfilter) es.regclientcmd(scfg.command_help,'extendedstats/cmd_help') loadCVARS() loadMenus() es.regcmd('xs_resetlog','extendedstats/resetlog') #es.regcmd('xs_cleandb','extendedstats/cleandb') es.regcmd('xs_checkversion','extendedstats/checkversion') es.regcmd('xs_cfgsync','extendedstats/cfgsync') es.regcmd('xs_dbsync','extendedstats/dbsync') es.server.queuecmd('es_load extendedstats/events/%s' % (game)) dbg('XS: Registered methods:') for method in methods: dbg( ' %s' % method) dcfg.sync() dbg('XS: Loaded successfully (%s)' % (info.version)) dbg(' ')
def exp_reg(args_dummy): argc = es.getargc() if argc > 3: global funcs global funcsregex global regex1 block = es.getargv(2) func = es.getargv(1) minargs = es.getargv(3) if not func in funcs: if re.match("^.+/.+(/.+)?$", block): if es.exists("block", block): if argc > 4: global funccmds userfunc = "_exp_userfunc" + str(len(funccmds) + 1) es.regcmd(userfunc, block, "exp user function") funcs[func] = {} funccmds.append(userfunc) funcs[func]["function"] = userfunc funcs[func]["minargs"] = int(minargs) funcs[func]["var"] = es.getargv(4) funcsregex = "|".join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg(0, "exp_reg : input variable name must be given for function block") else: es.dbgmsg(0, "exp_reg : invalid block given") elif re.match("^.+\\..+(\\..+)?$", block): temp = block.split(".") exec ("temp = callable(" + block + ")") if temp: exec ("funcs[func]['function'] = " + block) funcs[func]["minargs"] = minargs funcsregex = "|".join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg(0, "exp_reg : invalid function given") else: es.dbgmsg(0, "exp_reg : invalid block/function given") else: es.dbgmsg(0, "exp_reg : function already registered") else: es.dbgmsg(0, "Syntax : exp_reg <function-name> <function/block> <min-args> [var]")
def exp_reg(args_dummy): argc = es.getargc() if argc > 3: global funcs global funcsregex global regex1 block = es.getargv(2) func = es.getargv(1) minargs = es.getargv(3) if not func in funcs: if re.match('^.+/.+(/.+)?$', block): if es.exists('block', block): if argc > 4: global funccmds userfunc = '_exp_userfunc' + str(len(funccmds) + 1) es.regcmd(userfunc, block, 'exp user function') funcs[func] = {} funccmds.append(userfunc) funcs[func]['function'] = userfunc funcs[func]['minargs'] = int(minargs) funcs[func]['var'] = es.getargv(4) funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg(0, 'exp_reg : input variable name must be given for function block') else: es.dbgmsg(0, 'exp_reg : invalid block given') elif re.match('^.+\\..+(\\..+)?$', block): temp = block.split('.') exec('temp = callable(' + block + ')') if temp: exec('funcs[func][\'function\'] = ' + block) funcs[func]['minargs'] = minargs funcsregex = '|'.join(funcs) regex1 = re.compile(funcsregex) else: es.dbgmsg(0, 'exp_reg : invalid function given') else: es.dbgmsg(0, 'exp_reg : invalid block/function given') else: es.dbgmsg(0, 'exp_reg : function already registered') else: es.dbgmsg(0, 'Syntax : exp_reg <function-name> <function/block> <min-args> [var]')
def __call__(self, method): if self.con: # TODO: remove when commands ported return self self.method = method self.name = method.__name__ if self.name[ 0] == '_': # Necessary for reserved words in python e.g. can't have a function called 'if' self.name = self.name[1:] params = inspect.getargspec(self.method)[0] self.argv = 'argv' in params self.args = 'args' in params if self.pre: for prefix in ('es_', 'es_x'): commands['%s%s' % (prefix, self.name)] = self else: commands[self.name] = self if self.alt: commands[self.alt] = self self.expname = 'es_%s' % self.name if self.pre else self.name es.addons.registerBlock('esc.cmds', self.name, self.concommand) names = [] if self.pre: names.append('es_%s' % self.name) names.append('es_x%s' % self.name) else: names.append(self.name) if self.alt: names.append(self.alt) if self.reg: for name in names: regcmd(name, '%s/%s' % (self.BLOCK_PREFIX, self.name), self.desc) return self
def __call__(self, method): if self.con: # TODO: remove when commands ported return self self.method = method self.name = method.__name__ if self.name[0] == '_': # Necessary for reserved words in python e.g. can't have a function called 'if' self.name = self.name[1:] params = inspect.getargspec(self.method)[0] self.argv = 'argv' in params self.args = 'args' in params if self.pre: for prefix in ('es_', 'es_x'): commands['%s%s' % (prefix, self.name)] = self else: commands[self.name] = self if self.alt: commands[self.alt] = self self.expname = 'es_%s' % self.name if self.pre else self.name es.addons.registerBlock('esc.cmds', self.name, self.concommand) names = [] if self.pre: names.append('es_%s' % self.name) names.append('es_x%s' % self.name) else: names.append(self.name) if self.alt: names.append(self.alt) if self.reg: for name in names: regcmd(name, '%s/%s' % (self.BLOCK_PREFIX, self.name), self.desc) return self
def load(): global gCommands services.register("auth", group_auth) gCommands = { 'group_create': group_create, 'group_delete': group_delete, 'power_create': power_create, 'power_give': power_give, 'power_revoke': power_revoke, 'power_delete': power_delete, 'user_create': user_create, 'user_join': user_join, 'user_leave': user_leave, 'user_delete': user_delete } es.regcmd('gauth', 'examples/auth/group_auth/command_extra', 'Create groups, players, etc, via the group_auth script addon.') es.sql('open', 'group_auth', '|examples/auth/group_auth') test = es.sql( 'queryvalue', 'group_auth', "SELECT COUNT(name) as num FROM sqlite_master WHERE type='table';") if not int(test): init_db()
def load(): getWeapon() if es.exists("command", "ur_clear") == 0: es.regcmd("ur_clear", "ultirestrict/clearwep", "Clears the restricted list.") if es.exists("command", "ur_add") == 0: es.regcmd("ur_add", "ultirestrict/addwep", "Add a restricted weapon.") if es.exists("command", "ur_del") == 0: es.regcmd("ur_del", "ultirestrict/delwep", "Remove a restricted weapon.") #if es.exists("command", "ur_knivesonly") == 0: # es.regcmd("ur_knivesonly", "ultirestrict/knives", "Set knives only.") weplist = ", ".join(restrictedList) es.addons.registerClientCommandFilter(restrict)
def regcmd(argv): if es.exists('command', argv[0]): raise ValueError('command %s already exists' % argv[0]) es.regcmd(*argv[:3])
def __init__(self, name): self.name = 'alias: %s' % name es.addons.registerBlock(self.BLOCK_PREFIX, name, self) aliases[name] = self regcmd(name, '%s/%s' % (self.BLOCK_PREFIX, name))
def register(self, name, desc): if self.reg: regcmd(name, '%s/%s' % (self.BLOCK_PREFIX, self.name), desc)
def load(): es.regcmd( "services", "corelib/services/services_cmd", "Defines a one-of-a-kind service that requires a specific interface") es.regcmd(":", "corelib/services/services_proxy", "Invoke a service command")
def load(): # Define the global values in this script global serverId, websiteAddy, banAppealMessage, hashCode, teachAdmins, clanName, allowAdminBanning, playersChecked, badAccess, wgetPath gbanLog('###############################################') gbanLog('Global Ban Has Been Loaded') gbanLog('###############################################\n') # make sure the dictionaries are clear playersChecked.clear() badAccess.clear() # Register the necessary commands for this script es.regsaycmd('!banmenu', 'GlobalBan/banReasonList', 'Ban the selected user') es.regcmd('gb_externalBanUser', 'GlobalBan/banExternal', 'Allow other scripts to add to the ban list when executed by an admin') es.regcmd('gb_consoleBanUser', 'GlobalBan/banFromConsole', 'Allow other scripts to add to the ban list automatically') es.regcmd('gb_saveConfig', 'GlobalBan/saveConfig', 'Used to create the GlobalBan.cfg file from the web') es.regcmd('gb_loadConfig', 'GlobalBan/loadConfig', 'Used to load the GlobalBan.cfg file') es.regcmd('gb_refreshAdmins', 'GlobalBan/refreshAdmins', 'Used to get a new admin list from the web') es.regcmd('gb_refreshBanReasons', 'GlobalBan/refreshBanReasons', 'Used to get a new ban reasons from the web') es.regcmd('gb_refreshBanLengths', 'GlobalBan/refreshBanLengths', 'Used to get a new ban lengths from the web') es.regcmd('gb_refreshAdminsMod', 'GlobalBan/updateAdminMod', 'Used to get a new admin Mod list from the web') # Load the config file loadConfig() # If windows, we want the full path to wget.exe if os.name == "nt": wgetPath = es.getAddonPath('GlobalBan') + "/wget.exe" # Get the list of plugins this server is enabled for os.system(wgetPath + " -b --quiet -O " + es.getAddonPath('GlobalBan') + "/plugins.cfg -a " + es.getAddonPath('GlobalBan') + "/gban.log \"" + websiteAddy + "index.php?page=getPluginConfig&es=1&serverId=" + str(serverId) + "\"") gamethread.delayed(10, loadPluginConfig) refreshLists() gamethread.delayed(10, updateAdminModLists) # Wait 10 seconds before refreshing the admin lists
def load(): es.regcmd("services", "corelib/services/services_cmd", "Defines a one-of-a-kind service that requires a specific interface") es.regcmd(":", "corelib/services/services_proxy", "Invoke a service command")
def load(): if not es.exists("command", "setting"): es.regcmd("setting", "setting/consolecmd", "Setting console command")
def regcmd(argv): if es.exists('command', argv[0]): raise ValueError, 'command %s already exists' % argv[0] es.regcmd(*argv[:3])
def load(): if not es.exists("command", "popup"): es.regcmd("popup", "popup/consolecmd", "Popup console command")
def cmdtest_register(): es.regcmd("pycommand2", "pyunittest/sub/cmdtest_run", "Stuff")