def __init__(self, *args, **kwargs): """ initialize the instance """ self.themelist = "" BasePlugin.__init__(self, *args, **kwargs)
def load(self): """ load the plugins """ BasePlugin.load(self) self.api('setting.add')('enabled', 'True', bool, 'enable triggers') self.api('events.register')('var_%s_echo' % self.sname, self.enablechange) parser = argp.ArgumentParser(add_help=False, description='get details of a trigger') parser.add_argument('trigger', help='the trigger to detail', default=[], nargs='*') self.api('commands.add')('detail', self.cmd_detail, parser=parser) parser = argp.ArgumentParser(add_help=False, description='list triggers') parser.add_argument('match', help='list only triggers that have this argument in them', default='', nargs='?') self.api('commands.add')('list', self.cmd_list, parser=parser) self.api('events.register')('plugin_unloaded', self.pluginunloaded) self.api('events.register')('from_mud_event', self.checktrigger, prio=1)
def load(self): """ load the plugins """ BasePlugin.load(self) #self.api('commands.add')('detail', self.cmd_detail, #shelp='details of an event') self.api('events.register')('io_execute_event', self.checkcmd) parser = argp.ArgumentParser(add_help=False, description='list watches') parser.add_argument('match', help='list only watches that have this argument in them', default='', nargs='?') self.api('commands.add')('list', self.cmd_list, parser=parser) parser = argp.ArgumentParser(add_help=False, description='get details of a watch') parser.add_argument('watch', help='the trigger to detail', default=[], nargs='*') self.api('commands.add')('detail', self.cmd_detail, parser=parser) self.api('events.register')('plugin_unloaded', self.pluginunloaded)
def __init__(self, *args, **kwargs): """ init the class """ BasePlugin.__init__(self, *args, **kwargs) self.canreload = False self.cmds = {} self.nomultiplecmds = {} self.savehistfile = os.path.join(self.savedir, 'history.txt') self.cmdhistorydict = PersistentDict(self.savehistfile, 'c') if 'history' not in self.cmdhistorydict: self.cmdhistorydict['history'] = [] self.cmdhistory = self.cmdhistorydict['history'] self.api('api.add')('add', self.api_addcmd) self.api('api.add')('remove', self.api_removecmd) self.api('api.add')('change', self.api_changecmd) self.api('api.add')('default', self.api_setdefault) self.api('api.add')('removeplugin', self.api_removeplugin) self.api('api.add')('list', self.api_listcmds) self.api('api.add')('run', self.api_run) self.api('api.add')('cmdhelp', self.api_cmdhelp)
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.password = '' self.api.get('api.add')('send', self.api_send)
def __init__(self, *args, **kwargs): """ Iniitialize the class self.gmcpcache - the cache of values for different GMCP modules self.modstates - the current counter for what modules have been enabled self.gmcpqueue - the queue of gmcp commands that the client sent before connected to the server self.gmcpmodqueue - the queue of gmcp modules that were enabled by the client before connected to the server """ BasePlugin.__init__(self, *args, **kwargs) self.canreload = False self.gmcpcache = {} self.modstates = {} self.gmcpqueue = [] self.gmcpmodqueue = [] self.reconnecting = False self.api.get('api.add')('sendpacket', self.api_sendpacket) self.api.get('api.add')('sendmodule', self.api_sendmodule) self.api.get('api.add')('togglemodule', self.api_togglemodule) self.api.get('api.add')('getv', self.api_getv)
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.canreload = False self.triggers = {} self.regexlookup = {} self.triggergroups = {} self.uniquelookup = {} self.regex = {} self.regex['color'] = "" self.regex['noncolor'] = "" self.api('api.add')('add', self.api_addtrigger) self.api('api.add')('remove', self.api_remove) self.api('api.add')('toggle', self.api_toggle) self.api('api.add')('gett', self.api_gett) self.api('api.add')('togglegroup', self.api_togglegroup) self.api('api.add')('toggleomit', self.api_toggleomit) self.api('api.add')('removeplugin', self.api_removeplugin) self.api('api.add')('update', self.api_update)
def load(self): """ load the module """ BasePlugin.load(self) self.api.get('events.register')('log_plugin_loaded', self.logloaded) self.api.get('events.eraise')('event_plugin_loaded', {}) parser = argparse.ArgumentParser(add_help=False, description='get details of an event') parser.add_argument('event', help='the event name to get details for', default=[], nargs='*') self.api.get('commands.add')('detail', self.cmd_detail, parser=parser) parser = argparse.ArgumentParser(add_help=False, description='list events and the ' \ 'plugins registered with them') parser.add_argument('match', help='list only events that have this argument in their name', default='', nargs='?') self.api.get('commands.add')('list', self.cmd_list, parser=parser) self.api.get('events.register')('plugin_unloaded', self.pluginunloaded)
def __init__(self, *args, **kwargs): """ Iniitilaize the class """ BasePlugin.__init__(self, *args, **kwargs) self.canreload = False
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.savesubfile = os.path.join(self.savedir, 'subs.txt') self._substitutes = PersistentDict(self.savesubfile, 'c')
def load(self): """ load the plugins """ BasePlugin.load(self) self.api.get('events.register')('GMCP_raw', self.gmcpfromserver) self.api.get('events.register')('GMCP_from_client', self.gmcpfromclient) self.api.get('events.register')('GMCP:server-enabled', self.gmcprequest) self.api.get('events.register')('muddisconnect', self.disconnect) self.api.get('options.addserveroption')(self.sname, SERVER) self.api.get('options.addclientoption')(self.sname, CLIENT) parser = argparse.ArgumentParser(add_help=False, description='send something through GMCP') parser.add_argument('stuff', help='the item to send through GCMP', default='', nargs='?') self.api('commands.add')('send', self.cmd_send, history=False, parser=parser) parser = argparse.ArgumentParser(add_help=False, description='show an item in the cache') parser.add_argument('item', help='the item to show', default='', nargs='?') self.api('commands.add')('cache', self.cmd_cache, history=False, parser=parser)
def __init__(self, *args, **kwargs): """ init the class """ BasePlugin.__init__(self, *args, **kwargs) self.canreload = False #print('log api.api', self.api.api) #print('log basepath', self.api.BASEPATH) self.savedir = os.path.join(self.api.BASEPATH, 'data', 'plugins', self.sname) self.logdir = os.path.join(self.api.BASEPATH, 'data', 'logs') #print('logdir', self.logdir) try: os.makedirs(self.savedir) except OSError: pass self.dtypes = {} self.sendtoclient = PersistentDict( os.path.join(self.savedir, 'sendtoclient.txt'), 'c') self.sendtoconsole = PersistentDict( os.path.join(self.savedir, 'sendtoconsole.txt'), 'c') self.sendtofile = PersistentDict( os.path.join(self.savedir, 'sendtofile.txt'), 'c') self.currentlogs = {} self.colors = {} self.filenametemplate = '%a-%b-%d-%Y.log' #self.sendtofile['default'] = { #'logdir':os.path.join(self.logdir, 'default'), #'file':'%a-%b-%d-%Y.log', 'timestamp':True #} self.colors['error'] = '@x136' self.api('api.add')('msg', self.api_msg) self.api('api.add')('adddtype', self.api_adddtype) self.api('api.add')('console', self.api_toggletoconsole) self.api('api.add')('file', self.api_toggletofile) self.api('api.add')('client', self.api_toggletoclient) self.api('api.add')('writefile', self.api_writefile) # add some default datatypes self.api('log.adddtype')('default') self.api('log.adddtype')('frommud') self.api('log.adddtype')('startup') self.api('log.adddtype')('shutdown') self.api('log.adddtype')('error') # log some datatypes by default self.api('log.client')('error') self.api('log.console')('error') self.api('log.console')('default') self.api('log.console')('startup') self.api('log.console')('shutdown')
def load(self): """ load the plugins """ BasePlugin.load(self) self.api.get('events.register')('A102', self.test) self.api.get('events.register')('A102:101', self.test101)
def __init__(self, tname, tsname, filename, directory, importloc): # pylint: disable=too-many-arguments """ Iniitilaize the class """ BasePlugin.__init__(self, tname, tsname, filename, directory, importloc) self.canreload = False
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.commandtraces = None self.changedmuddata = None
def load(self): """ load the plugin """ BasePlugin.load(self) self.api('setting.add')('commands', False, bool, 'flag to echo commands') self.api('setting.add')('functions', False, bool, 'flag to profile functions') self.api('setting.add')('stacklen', 20, int, '# of traces kept') self.api('setting.add')('cmdfuncstack', False, bool, 'print the function stack in an echo') parser = argp.ArgumentParser( add_help=False, description='show trace info about commands') parser.add_argument('-i', '--item', help='the item to show', default='', nargs='?') parser.add_argument( '-c', "--callstack", help="print callstack if available", action="store_true", default=False) self.api('commands.add')('commands', self.cmd_commands, parser=parser) parser = argp.ArgumentParser( add_help=False, description='show trace info about data from the mud') parser.add_argument('-i', '--item', help='the item to show', default='', nargs='?') # parser.add_argument( # '-c', "--callstack", # help="print callstack if available", # action="store_true", # default=False) self.api('commands.add')('muddata', self.cmd_muddata, parser=parser) parser = argp.ArgumentParser(add_help=False, description='reset command stack') self.api('commands.add')('rstack', self.cmd_rstack, parser=parser) self.commandtraces = SimpleQueue(self.api('setting.gets')('stacklen')) self.changedmuddata = SimpleQueue(self.api('setting.gets')('stacklen')) self.api('events.register')('io_execute_trace_finished', self.savecommand, prio=99) self.api('events.register')('from_mud_event', self.savechangedmuddata, prio=99) self.api('events.register')('var_%s_functions' % self.sname, self.onfunctionschange)
def disconnect(self, _=None): """ reattach to GMCP:char.status """ BasePlugin.disconnect(self) self.gotchar = False self.gotroom = False self.sentchar = False self.api.get("events.register")("GMCP:char", self._char) self.api.get("events.register")("GMCP:room.info", self._roominfo)
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.aliasfile = os.path.join(self.savedir, 'aliases.txt') self._aliases = PersistentDict(self.aliasfile, 'c') self.sessionhits = {}
def load(self): """ load the plugins """ BasePlugin.load(self) parser = argp.ArgumentParser(add_help=False, description='create documentation') self.api('commands.add')('build', self.cmd_build, parser=parser, group='Documentation')
def load(self): """ load the plugins """ BasePlugin.load(self) self.api('triggers.add')( 'example_trigger', r"^(?P<name>.*) flicks a (?P<insect>.*) off his bar\.$") self.api('events.register')('trigger_example_trigger', self.testtrigger)
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.errors = [] self.api('api.add')('add', self.api_adderror) self.api('api.add')('gete', self.api_geterrors) self.api('api.add')('clear', self.api_clearerrors)
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.variablefile = os.path.join(self.savedir, 'variables.txt') self._variables = PersistentDict(self.variablefile, 'c') self.api('api.add')('getv', self.api_getv) self.api('api.add')('setv', self.api_setv) self.api('api.add')('replace', self.api_replace)
def __init__(self, *args, **kwargs): BasePlugin.__init__(self, *args, **kwargs) self.api('api.add')('iscolor', self.api_iscolor) self.api('api.add')('convertcolors', self.api_convertcolors) self.api('api.add')('convertansi', self.api_convertansi) self.api('api.add')('ansicode', self.api_ansicode) self.api('api.add')('stripansi', self.api_stripansi) self.api('api.add')('stripcolor', self.api_stripcolor) self.api('api.add')('lengthdiff', self.api_getlengthdiff) self.api('api.add')('colortohtml', self.api_colorcodestohtml)
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.api('dependency.add')('ssc') self.apikey = None self.api('api.add')('note', self.api_note) self.api('api.add')('link', self.api_link)
def __init__(self, *args, **kwargs): BasePlugin.__init__(self, *args, **kwargs) self.firstactive = False self.connected = False self.sentchar = False self.sentquest = False self.sentroom = False # the firstactive flag self.api('api.add')('firstactive', self.api_firstactive)
def __init__(self): """ initialize the instance """ # Examples: # name : 'Actions' - from plugin file variable NAME (long name) # sname : 'actions' - from plugin file variable SNAME (short name) # modpath : '/client/actions.py' - path relative to the plugins directory # basepath : '/home/src/games/bastproxy/bp/plugins' - the full path to the # plugins directory # fullimploc : 'plugins.client.actions' - import location #name, sname, modpath, basepath, fullimploc BasePlugin.__init__(self, 'Plugin Manager', #name, 'plugins', #sname, "/__init__.py", #modpath "$basepath$", # basepath "plugins.__init__", # fullimploc ) self.canreload = False #key: modpath #value: {'plugin', 'module'} self.loadedpluginsd = {} self.pluginlookupbysname = {} self.pluginlookupbyname = {} self.pluginlookupbyfullimploc = {} # key: modpath # value: {'sname', 'name', 'purpose', 'author', # 'version', 'modpath', 'fullimploc' self.allplugininfo = {} index = __file__.rfind(os.sep) if index == -1: self.basepath = "." + os.sep else: self.basepath = __file__[:index] self.savefile = os.path.join(self.api.BASEPATH, 'data', 'plugins', 'loadedplugins.txt') self.loadedplugins = PersistentDict(self.savefile, 'c') self.api('api.add')('isloaded', self._api_isloaded) self.api('api.add')('getp', self._api_getp) self.api('api.add')('module', self._api_getmodule) self.api('api.add')('allplugininfo', self._api_allplugininfo) self.api('api.add')('savestate', self.savestate)
def load(self): """ load the plugins """ BasePlugin.load(self) self.api('events.register')('A102_from_server', self.a102fromserver) self.api('events.register')('A102_from_client', self.a102fromclient) self.api('events.register')('A102:server-enabled', self.a102request) self.api('events.register')('muddisconnect', self.a102disconnect) self.api('options.addserveroption')(self.sname, SERVER) self.api('options.addclientoption')(self.sname, CLIENT)
def __init__(self, *args, **kwargs): BasePlugin.__init__(self, *args, **kwargs) self.firstactive = False self.connected = False self.gotchar = False self.gotroom = False self.sentchar = False self.sentquest = False # the firstactive flag self.api.get("api.add")("firstactive", self.api_firstactive)
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs) self.api('dependency.add')('ssc') self.proxypw = None self.proxyvpw = None self.mudpw = None self.api('api.add')('restart', self.api_restart) self.api('api.add')('shutdown', self.api_shutdown)
def load(self): """ load the plugins """ BasePlugin.load(self) self.api('timers.add')('test_timer', self.test, 600, onetime=False) self.api('timers.add')('test_touser_timer', self.test_to_user, 10, onetime=True) self.api('timers.add')('test_timewsec', self.test_timewsec, 60, time='2010') self.api('timers.add')('test_time', self.test_time, 60*60*24, time='1200')
def load(self): """ load the plugin """ BasePlugin.load(self) self.api('events.register')('client_connected', self.checkpassword) parser = argp.ArgumentParser( add_help=False, description='set the password for the mail account') parser.add_argument('password', help='the top level api to show (optional)', default='', nargs='?') self.api('commands.add')('password', self.cmd_pw, showinhistory=False, parser=parser) parser = argp.ArgumentParser(add_help=False, description='send a test email') parser.add_argument('subject', help='the subject of the test email (optional)', default='Test subject from bastproxy', nargs='?') parser.add_argument('message', help='the message of the test email (optional)', default='Msg from bastproxy', nargs='?') self.api('commands.add')('test', self.cmd_test, parser=parser) parser = argp.ArgumentParser( add_help=False, description='check to make sure all settings are applied') self.api('commands.add')('check', self.cmd_check, parser=parser) self.api('setting.add')('server', '', str, 'the smtp server to send mail through') self.api('setting.add')('port', '', int, 'the port to use when sending mail') self.api('setting.add')('username', '', str, 'the username to connect as', nocolor=True) self.api('setting.add')('to', '', str, 'the address to send mail to', nocolor=True) self.api('setting.add')('from', '', str, 'the address to send mail from', nocolor=True) self.api('setting.add')( 'ssl', '', bool, 'set this to True if the connection will use ssl') if self.api('setting.gets')('username') != '': self.api('send.client')('Please set the mail password')
def __init__(self, *args, **kwargs): """ initialize the instance """ BasePlugin.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): BasePlugin.__init__(self, *args, **kwargs) self.api('dependency.add')('aardwolf.connect') self.api('dependency.add')('aardwolf.aardu') self.api('dependency.add')('aardwolf.agmcp')
def load(self): """ load the plugin """ BasePlugin.load(self) self.api('setting.add')('nextnum', 0, int, 'the number of the next alias added', readonly=True) parser = argp.ArgumentParser(add_help=False, description='add an alias') parser.add_argument('original', help='the input to replace', default='', nargs='?') parser.add_argument('replacement', help='the string to replace it with', default='', nargs='?') parser.add_argument('-o', "--overwrite", help="overwrite an alias if it already exists", action="store_true") parser.add_argument('-d', "--disable", help="disable the alias", action="store_true") parser.add_argument('-g', "--group", help="the alias group", default="") self.api('commands.add')('add', self.cmd_add, parser=parser) parser = argp.ArgumentParser(add_help=False, description='remove an alias') parser.add_argument('alias', help='the alias to remove', default='', nargs='?') self.api('commands.add')('remove', self.cmd_remove, parser=parser) parser = argp.ArgumentParser(add_help=False, description='list aliases') parser.add_argument( 'match', help='list only aliases that have this argument in them', default='', nargs='?') self.api('commands.add')('list', self.cmd_list, parser=parser) parser = argp.ArgumentParser(add_help=False, description='toggle enabled flag') parser.add_argument('alias', help='the alias to toggle', default='', nargs='?') self.api('commands.add')('toggle', self.cmd_toggle, parser=parser) parser = argp.ArgumentParser( add_help=False, description='toggle all aliases in a group') parser.add_argument('group', help='the group to toggle', default='', nargs='?') parser.add_argument('-d', "--disable", help="disable the group", action="store_true") self.api('commands.add')('groupt', self.cmd_grouptoggle, parser=parser) parser = argp.ArgumentParser(add_help=False, description='get detail for an alias') parser.add_argument('alias', help='the alias to get details for', default='', nargs='?') self.api('commands.add')('detail', self.cmd_detail, parser=parser) self.api('commands.default')('list') self.api('events.register')('io_execute_event', self.checkalias, prio=2) self.api('events.register')('plugin_%s_savestate' % self.sname, self._savestate)
def reset(self): """ reset the plugin """ BasePlugin.reset(self) self.clearvariables()
def load(self): """ load the plugins """ BasePlugin.load(self)
def __init__(self, *args, **kwargs): BasePlugin.__init__(self, *args, **kwargs) self.reloaddependents = True self.api.get('api.add')('baseclass', self.api_baseclass)
def savestate(self): """ save states """ BasePlugin.savestate(self) self._variables.sync()
def load(self): BasePlugin.load(self) self.api('options.addserveroption')(self.sname, SERVER) self.api('options.addclientoption')(self.sname, CLIENT)
def savestate(self): """ save states """ BasePlugin.savestate(self) self._aliases.sync()
def load(self): """ load various things """ self._loadplugins("*.py") BasePlugin._loadcommands(self) parser = argp.ArgumentParser(add_help=False, description="list plugins") parser.add_argument('-n', "--notloaded", help="list plugins that are not loaded", action="store_true") parser.add_argument( '-c', "--changed", help="list plugins that are load but are changed on disk", action="store_true") parser.add_argument('package', help='the to list', default='', nargs='?') self.api('commands.add')('list', self._cmd_list, lname='Plugin Manager', parser=parser) parser = argp.ArgumentParser(add_help=False, description="load a plugin") parser.add_argument('plugin', help='the plugin to load, don\'t include the .py', default='', nargs='?') self.api('commands.add')('load', self._cmd_load, lname='Plugin Manager', parser=parser) parser = argp.ArgumentParser(add_help=False, description="unload a plugin") parser.add_argument('plugin', help='the plugin to unload', default='', nargs='?') self.api('commands.add')('unload', self._cmd_unload, lname='Plugin Manager', parser=parser) parser = argp.ArgumentParser(add_help=False, description="reload a plugin") parser.add_argument('plugin', help='the plugin to reload', default='', nargs='?') self.api('commands.add')('reload', self._cmd_reload, lname='Plugin Manager', parser=parser) self.api('commands.default')('list', self.sname) self.api('timers.add')('save', self.savestate, 60, nodupe=True, log=False) self.api('events.register')('proxy_shutdown', self.shutdown)
def load(self): """ load the module """ BasePlugin.load(self) self.api('log.console')(self.sname)
def load(self): """ load external stuff """ BasePlugin.load(self) #print('log api before adding', self.api.api) #print('log api after adding', self.api.api) self.api('events.register')('from_mud_event', self.logmud) self.api('events.register')('to_mud_event', self.logmud) self.api('events.register')('plugin_%s_savestate' % self.sname, self._savestate) parser = argp.ArgumentParser(add_help=False, description="""\ toggle datatypes to clients if no arguments, data types that are currenty sent to clients will be listed""") parser.add_argument('datatype', help='a list of datatypes to toggle', default=[], nargs='*') self.api('commands.add')('client', self.cmd_client, lname='Logger', parser=parser) parser = argp.ArgumentParser(add_help=False, description="""\ toggle datatype to log to a file the file will be located in the data/logs/<dtype> directory the filename for the log will be <date>.log Example: Tue-Feb-26-2013.log if no arguments, types that are sent to file will be listed""") parser.add_argument('datatype', help='the datatype to toggle', default='list', nargs='?') parser.add_argument("-n", "--notimestamp", help="do not log to file with a timestamp", action="store_false") self.api('commands.add')('file', self.cmd_file, lname='Logger', parser=parser) parser = argp.ArgumentParser(add_help=False, description="""\ toggle datatypes to the console if no arguments, data types that are currenty sent to the console will be listed""") parser.add_argument('datatype', help='a list of datatypes to toggle', default=[], nargs='*') self.api('commands.add')('console', self.cmd_console, lname='Logger', parser=parser) parser = argp.ArgumentParser(add_help=False, description="list all datatypes") parser.add_argument('match', help='only list datatypes that have this argument in their name', default='', nargs='?') self.api('commands.add')('types', self.cmd_types, lname='Logger', parser=parser)
def reset(self): """ reset the plugin """ BasePlugin.reset(self) self.clearactions()
def load(self): """ load the plugin """ BasePlugin.load(self) self.api('setting.add')('nextnum', 0, int, 'the number of the next action added', readonly=True) parser = argp.ArgumentParser(add_help=False, description='add a action') parser.add_argument('regex', help='the regex to match', default='', nargs='?') parser.add_argument('action', help='the action to take', default='', nargs='?') parser.add_argument('send', help='where to send the action', default='execute', nargs='?', choices=self.api('api.getchildren')('send')) parser.add_argument('-c', "--color", help="match colors (@@colors)", action="store_true") parser.add_argument('-d', "--disable", help="disable the action", action="store_true") parser.add_argument('-g', "--group", help="the action group", default="") parser.add_argument('-o', "--overwrite", help="overwrite an action if it already exists", action="store_true") self.api('commands.add')('add', self.cmd_add, parser=parser) parser = argp.ArgumentParser(add_help=False, description='list actions') parser.add_argument('match', help='list only actions that have this argument in them', default='', nargs='?') self.api('commands.add')('list', self.cmd_list, parser=parser) parser = argp.ArgumentParser(add_help=False, description='remove an action') parser.add_argument('action', help='the action to remove', default='', nargs='?') self.api('commands.add')('remove', self.cmd_remove, parser=parser) parser = argp.ArgumentParser(add_help=False, description='toggle enabled flag') parser.add_argument('action', help='the action to toggle', default='', nargs='?') action = parser.add_mutually_exclusive_group() action.add_argument('-t', '--toggle', action='store_const', dest='togact', const='toggle', default='toggle', help='toggle the action') action.add_argument('-d', '--disable', action='store_const', dest='togact', const='disable', help='disable the action') action.add_argument('-e', '--enable', action='store_const', dest='togact', const='enable', help='enable the action') self.api('commands.add')('toggle', self.cmd_toggle, parser=parser) parser = argp.ArgumentParser(add_help=False, description='get detail for an action') parser.add_argument('action', help='the action to get details for', default='', nargs='?') self.api('commands.add')('detail', self.cmd_detail, parser=parser) parser = argp.ArgumentParser(add_help=False, description='toggle all actions in a group') parser.add_argument('group', help='the group to toggle', default='', nargs='?') action = parser.add_mutually_exclusive_group() action.add_argument('-t', '--toggle', action='store_const', dest='togact', const='toggle', default='toggle', help='toggle the action') action.add_argument('-d', '--disable', action='store_const', dest='togact', const='disable', help='disable the action') action.add_argument('-e', '--enable', action='store_const', dest='togact', const='enable', help='enable the action') self.api('commands.add')('groupt', self.cmd_grouptoggle, parser=parser) for action in self.actions.values(): self.register_action(action) self.api('events.register')('plugin_%s_savestate' % self.sname, self._savestate)
def savestate(self): """ save states """ BasePlugin.savestate(self) self.cmdhistorydict.sync()
def reset(self): """ reset the plugin """ BasePlugin.reset(self) self.clearsubs()
def load(self): """ load external stuff """ BasePlugin.load(self) self.api.get('log.adddtype')(self.sname) #self.api.get('log.console')(self.sname) self.api.get('setting.add')('spamcount', 20, int, 'the # of times a command can ' \ 'be run before an antispam command') self.api.get('setting.add')('antispamcommand', 'look', str, 'the antispam command to send') self.api.get('setting.add')('cmdcount', 0, int, 'the # of times the current command has been run', readonly=True) self.api.get('setting.add')('lastcmd', '', str, 'the last command that was sent to the mud', readonly=True) self.api.get('setting.add')('historysize', 50, int, 'the size of the history to keep') parser = argparse.ArgumentParser(add_help=False, description='list commands in a category') parser.add_argument('category', help='the category to see help for', default='', nargs='?') parser.add_argument('cmd', help='the command in the category (can be left out)', default='', nargs='?') self.api.get('commands.add')('list', self.cmd_list, shelp='list commands', parser=parser, history=False) parser = argparse.ArgumentParser(add_help=False, description='list the command history') parser.add_argument('-c', "--clear", help="clear the history", action='store_true') self.api.get('commands.add')('history', self.cmd_history, shelp='list or run a command in history', parser=parser, history=False) parser = argparse.ArgumentParser(add_help=False, description='run a command in history') parser.add_argument('number', help='the history # to run', default=-1, nargs='?', type=int) self.api.get('commands.add')('!', self.cmd_runhistory, shelp='run a command in history', parser=parser, preamble=False, format=False, history=False) self.api.get('events.register')('from_client_event', self.chkcmd, prio=5) self.api.get('events.register')('plugin_unloaded', self.pluginunloaded) self.api.get('events.eraise')('plugin_cmdman_loaded', {})
def savestate(self): """ save states """ BasePlugin.savestate(self) self._substitutes.sync()