Ejemplo n.º 1
0
  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)
Ejemplo n.º 2
0
  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)
Ejemplo n.º 3
0
 def load(self):
   """
   load the module
   """
   BasePlugin.load(self)
   #self.api.get('events.register')('plugin_loaded', self.plugin_loaded)
   self.api.get('log.console')(self.sname)
Ejemplo n.º 4
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    #self.api.get('commands.add')('detail', self.cmd_detail,
                                 #shelp='details of an event')

    self.api.get('events.register')('from_client_event', self.checkcmd)

    parser = argparse.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.get('commands.add')('list',
                                 self.cmd_list,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='get details of a watch')
    parser.add_argument('watch',
                        help='the trigger to detail',
                        default=[],
                        nargs='*')
    self.api.get('commands.add')('detail',
                                 self.cmd_detail,
                                 parser=parser)

    self.api.get('events.register')('plugin_unloaded', self.pluginunloaded)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        self.api('events.register')('GMCP_raw', self.gmcpfromserver)
        self.api('events.register')('GMCP_from_client', self.gmcpfromclient)
        self.api('events.register')('GMCP:server-enabled', self.gmcprequest)
        self.api('events.register')('muddisconnect', self.gmcpdisconnect)

        self.api('options.addserveroption')(self.sname, SERVER)
        self.api('options.addclientoption')(self.sname, CLIENT)

        parser = argp.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,
                                 showinhistory=False,
                                 parser=parser)

        parser = argp.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,
                                 showinhistory=False,
                                 parser=parser)
Ejemplo n.º 7
0
  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)
Ejemplo n.º 8
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        parser = argparse.ArgumentParser(
            add_help=False, description='get details of a trigger')
        parser.add_argument('trigger',
                            help='the trigger to detail',
                            default=[],
                            nargs='*')
        self.api.get('commands.add')('detail', self.cmd_detail, parser=parser)

        parser = argparse.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.get('commands.add')('list', self.cmd_list, parser=parser)

        #self.api.get('commands.add')('stats', self.cmd_stats,
        #                             shelp='show trigger stats')

        self.api.get('events.register')('from_mud_event',
                                        self.checktrigger,
                                        prio=1)

        self.api.get('events.register')('plugin_unloaded', self.pluginunloaded)
Ejemplo n.º 9
0
  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)
Ejemplo n.º 10
0
  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)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
    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, 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')
Ejemplo n.º 14
0
  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)
Ejemplo n.º 15
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    parser = argparse.ArgumentParser(add_help=False,
                 description='create documentation')
    self.api.get('commands.add')('build', self.cmd_build,
                                 parser=parser, group='Documentation')
Ejemplo n.º 16
0
  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)
Ejemplo n.º 17
0
  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')
Ejemplo n.º 18
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        parser = argp.ArgumentParser(add_help=False,
                                     description='drop the last command')
        self.api('commands.add')('fixqueue', self.cmd_fixqueue, parser=parser)

        self.api('events.register')('plugin_unloaded', self.pluginunloaded)
Ejemplo n.º 19
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        parser = argp.ArgumentParser(add_help=False, description='show colors')
        self.api('commands.add')('show', self.cmd_show, parser=parser)
        parser = argp.ArgumentParser(add_help=False,
                                     description='show color examples')
        self.api('commands.add')('example', self.cmd_example, parser=parser)
Ejemplo n.º 20
0
  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)
Ejemplo n.º 21
0
    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)
Ejemplo n.º 22
0
  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')
Ejemplo n.º 23
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        self.api('setting.add')('mudhost', '', str,
                                'the hostname/ip of the mud')
        self.api('setting.add')('mudport', 0, int, 'the port of the mud')
        self.api('setting.add')('listenport', 9999, int,
                                'the port for the proxy to listen on')
        self.api('setting.add')('username', '', str, 'username')
        self.api('setting.add')('linelen', 79, int, 'the line length for data')

        self.api.get('commands.add')('clients',
                                     self.cmd_clients,
                                     shelp='list clients that are connected')

        self.api.get('commands.add')('disconnect',
                                     self.cmd_disconnect,
                                     shelp='disconnect from the mud')

        self.api.get('commands.add')('connect',
                                     self.cmd_connect,
                                     shelp='connect to the mud')

        self.api.get('commands.add')('restart',
                                     self.cmd_restart,
                                     shelp='restart the proxy',
                                     format=False)

        self.api.get('commands.add')('shutdown',
                                     self.cmd_shutdown,
                                     shelp='shutdown the proxy')

        self.api('events.register')('client_connected', self.client_connected)
        self.api('events.register')('mudconnect', self.sendusernameandpw)
        self.api('events.register')('var_net_listenport',
                                    self.listenportchange)

        ssc = self.api('ssc.baseclass')()
        self.proxypw = ssc('proxypw',
                           self,
                           desc='Proxy Password',
                           default='defaultpass')
        self.proxyvpw = ssc('proxypwview',
                            self,
                            desc='Proxy View Password',
                            default='defaultviewpass')
        self.mudpw = ssc('mudpw', self, desc='Mud Password')
Ejemplo n.º 24
0
    def load(self):
        """
    load the plugin
    """
        BasePlugin.load(self)

        self.api('setting.add')('channel', '', str, 'the channel to send to')

        parser = argparse.ArgumentParser(add_help=False,
                                         description='send a note')
        parser.add_argument('title',
                            help='the title of the note',
                            default='Pushbullet note from bastproxy',
                            nargs='?')
        parser.add_argument('body',
                            help='the body of the note',
                            default='A Pushbullet note sent through bastproxy',
                            nargs='?')
        parser.add_argument('-c',
                            "--channel",
                            help="the pushbullet channel to send to",
                            default='')
        self.api('commands.add')('note', self.cmd_note, parser=parser)

        parser = argparse.ArgumentParser(add_help=False,
                                         description='send a link')
        parser.add_argument('title',
                            help='the title of the link',
                            default='Pushbullet link from bastproxy',
                            nargs='?')
        parser.add_argument('url',
                            help='the url of the link',
                            default='https://github.com/endavis/bastproxy',
                            nargs='?')
        parser.add_argument('-c',
                            "--channel",
                            help="the pushbullet channel to send to",
                            default='')
        self.api('commands.add')('link', self.cmd_link, parser=parser)

        parser = argparse.ArgumentParser(
            add_help=False, description='show channels associated with pb')
        self.api('commands.add')('channels', self.cmd_channels, parser=parser)

        ssc = self.api('ssc.baseclass')()
        self.apikey = ssc('apikey', self, desc='Pushbullet API key')

        if not PUSHBULLET:
            global PUSHBULLET
            from pushbullet import Pushbullet as PUSHBULLET
Ejemplo n.º 25
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    parser = argp.ArgumentParser(add_help=False,
                                 description='add a simple substitute')
    parser.add_argument('original',
                        help='the output to substitute',
                        default='',
                        nargs='?')
    parser.add_argument('replacement',
                        help='the string to replace it with',
                        default='',
                        nargs='?')
    self.api('commands.add')('add',
                             self.cmd_add,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='remove a substitute')
    parser.add_argument('substitute',
                        help='the substitute to remove',
                        default='',
                        nargs='?')
    self.api('commands.add')('remove',
                             self.cmd_remove,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='list substitutes')
    parser.add_argument('match',
                        help='list only substitutes 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='clear all substitutes')
    self.api('commands.add')('clear',
                             self.cmd_clear,
                             parser=parser)

    self.api('commands.default')('list')
    self.api('events.register')('from_mud_event', self.findsub)

    self.api('events.register')('plugin_%s_savestate' % self.sname, self._savestate)
Ejemplo n.º 26
0
  def load(self):
    """
    load the plugin
    """
    BasePlugin.load(self)

    self.api('setting.add')('channel', '', str,
                            'the channel to send to')

    parser = argp.ArgumentParser(add_help=False,
                                 description='send a note')
    parser.add_argument('title',
                        help='the title of the note',
                        default='Pushbullet note from bastproxy',
                        nargs='?')
    parser.add_argument('body',
                        help='the body of the note',
                        default='A Pushbullet note sent through bastproxy',
                        nargs='?')
    parser.add_argument('-c', "--channel",
                        help="the pushbullet channel to send to",
                        default='')
    self.api('commands.add')('note', self.cmd_note,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='send a link')
    parser.add_argument('title',
                        help='the title of the link',
                        default='Pushbullet link from bastproxy',
                        nargs='?')
    parser.add_argument('url',
                        help='the url of the link',
                        default='https://github.com/endavis/bastproxy',
                        nargs='?')
    parser.add_argument('-c', "--channel",
                        help="the pushbullet channel to send to",
                        default='')
    self.api('commands.add')('link', self.cmd_link,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='show channels associated with pb')
    self.api('commands.add')('channels', self.cmd_channels,
                             parser=parser)

    ssc = self.api('ssc.baseclass')()
    self.apikey = ssc('apikey', self, desc='Pushbullet API key')

    self.import_pushbullet()
Ejemplo n.º 27
0
  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,
                             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')
Ejemplo n.º 28
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    self.api.get('timers.add')('test_timer', self.test,
                               600, onetime=False)
    self.api.get('timers.add')('test_touser_timer', self.test_to_user,
                               10, onetime=True)
    self.api.get('timers.add')('test_timewsec', self.test_timewsec,
                               60, time='2010')
    self.api.get('timers.add')('test_time', self.test_time,
                               60*60*24, time='1200')
Ejemplo n.º 29
0
  def load(self):
    """
    load the plugin
    """
    BasePlugin.load(self)

    parser = argp.ArgumentParser(add_help=False,
                                 description='add a variable')
    parser.add_argument('name',
                        help='the name of the variable',
                        default='',
                        nargs='?')
    parser.add_argument('value',
                        help='the value of the variable',
                        default='',
                        nargs='?')
    self.api('commands.add')('add',
                             self.cmd_add,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='remove a variable')
    parser.add_argument('name',
                        help='the variable to remove',
                        default='',
                        nargs='?')
    self.api('commands.add')('remove',
                             self.cmd_remove,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='list variables')
    parser.add_argument('match',
                        help='list only variables that have this argument in their name',
                        default='',
                        nargs='?')
    self.api('commands.add')('list',
                             self.cmd_list,
                             parser=parser)

    self.api('commands.default')('list')

    self.api('events.register')('io_execute_event',
                                self.checkline,
                                prio=99)
    self.api('events.register')('io_execute_event',
                                self.checkline,
                                prio=1)
    self.api('events.register')('plugin_%s_savestate' % self.sname, self._savestate)
Ejemplo n.º 30
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    self.api('setting.add')('mudhost', '', str,
                            'the hostname/ip of the mud')
    self.api('setting.add')('mudport', 0, int,
                            'the port of the mud')
    self.api('setting.add')('listenport', 9999, int,
                            'the port for the proxy to listen on')
    self.api('setting.add')('username', '', str,
                            'username')
    self.api('setting.add')('linelen', 79, int,
                            'the line length for data')

    self.api('commands.add')('info',
                             self.cmd_info,
                             shelp='list proxy info')

    self.api('commands.add')('disconnect',
                             self.cmd_disconnect,
                             shelp='disconnect from the mud')

    self.api('commands.add')('connect',
                             self.cmd_connect,
                             shelp='connect to the mud')

    self.api('commands.add')('restart',
                             self.cmd_restart,
                             shelp='restart the proxy',
                             format=False)

    self.api('commands.add')('shutdown',
                             self.cmd_shutdown,
                             shelp='shutdown the proxy')

    self.api('events.register')('client_connected', self.client_connected)
    self.api('events.register')('mudconnect', self.sendusernameandpw)
    self.api('events.register')('var_%s_listenport' % self.sname, self.listenportchange)

    ssc = self.api('ssc.baseclass')()
    self.proxypw = ssc('proxypw', self, desc='Proxy Password',
                       default='defaultpass')
    self.proxyvpw = ssc('proxypwview', self, desc='Proxy View Password',
                        default='defaultviewpass')
    self.mudpw = ssc('mudpw', self, desc='Mud Password')
Ejemplo n.º 31
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    parser = argp.ArgumentParser(add_help=False,
                                 description='show colors')
    self.api('commands.add')('show',
                             self.cmd_show,
                             parser=parser)
    parser = argp.ArgumentParser(add_help=False,
                                 description='show color examples')
    self.api('commands.add')('example',
                             self.cmd_example,
                             parser=parser)
Ejemplo n.º 32
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    self.api.get('events.register')('global_timer', self.checktimerevents,
                                    prio=1)
    self.api.get('send.msg')('lasttime:  %s' % self.lasttime)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='list timers')
    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)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='toggle log flag for a timer')
    parser.add_argument('timername',
                        help='the timer name',
                        default='',
                        nargs='?')
    self.api.get('commands.add')('log',
                                 self.cmd_log,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='get details for timers')
    parser.add_argument('timers',
                        help='a list of timers to get details',
                        default=[],
                        nargs='*')
    self.api.get('commands.add')('detail',
                                 self.cmd_detail,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='get overall timer stats')
    self.api.get('commands.add')('stats',
                                 self.cmd_stats,
                                 parser=parser)

    self.api.get('events.register')('plugin_unloaded', self.pluginunloaded)
Ejemplo n.º 33
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    self.api('commands.add')('show',
                             self.cmd_show,
                             shelp='list clients that are connected')

    self.api('events.register')('proxy_shutdown',
                                self.shutdown)

    self.api('events.register')('client_connected', self.addclient)
    self.api('events.register')('client_connected_view', self.addviewclient)

    self.api('events.register')('client_disconnected', self.removeclient)
Ejemplo n.º 34
0
  def load(self):
    """
    load the plugin
    """
    BasePlugin.load(self)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='add a variable')
    parser.add_argument('name',
                        help='the name of the variable',
                        default='',
                        nargs='?')
    parser.add_argument('value',
                        help='the value of the variable',
                        default='',
                        nargs='?')
    self.api.get('commands.add')('add',
                                 self.cmd_add,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='remove a variable')
    parser.add_argument('name',
                        help='the variable to remove',
                        default='',
                        nargs='?')
    self.api.get('commands.add')('remove',
                                 self.cmd_remove,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='list variables')
    parser.add_argument('match',
                        help='list only variables that have this argument in their name',
                        default='',
                        nargs='?')
    self.api.get('commands.add')('list',
                                 self.cmd_list,
                                 parser=parser)

    self.api.get('commands.default')('list')
    #self.api.get('events.register')('from_client_event', self.checkvariable,
                                        #prio=1)
    self.api.get('events.register')('from_client_event',
                                    self.checkline,
                                    prio=99)
Ejemplo n.º 35
0
    def load(self):
        """
    load the plugin
    """
        BasePlugin.load(self)

        parser = argparse.ArgumentParser(add_help=False,
                                         description='show errors')
        parser.add_argument('number',
                            help='list the last <number> errors',
                            default='-1',
                            nargs='?')
        self.api.get('commands.add')('show', self.cmd_show, parser=parser)

        parser = argparse.ArgumentParser(add_help=False,
                                         description='clear errors')
        self.api.get('commands.add')('clear', self.cmd_clear, parser=parser)
Ejemplo n.º 36
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        self.api('events.register')('GMCP', self.test)
        self.api('events.register')('GMCP:char', self.testchar)
        self.api('events.register')('GMCP:char.status', self.testcharstatus)

        parser = argp.ArgumentParser(
            add_help=False,
            description='print what is in a module in the gmcp cache')
        parser.add_argument('module',
                            help='the module to show',
                            default='',
                            nargs='?')
        self.api('commands.add')('get', self.cmd_get, parser=parser)
Ejemplo n.º 37
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        parser = argp.ArgumentParser(add_help=False,
                                     description='add a simple substitute')
        parser.add_argument('original',
                            help='the output to substitute',
                            default='',
                            nargs='?')
        parser.add_argument('replacement',
                            help='the string to replace it with',
                            default='',
                            nargs='?')
        self.api('commands.add')('add', self.cmd_add, parser=parser)

        parser = argp.ArgumentParser(add_help=False,
                                     description='remove a substitute')
        parser.add_argument('substitute',
                            help='the substitute to remove',
                            default='',
                            nargs='?')
        self.api('commands.add')('remove', self.cmd_remove, parser=parser)

        parser = argp.ArgumentParser(add_help=False,
                                     description='list substitutes')
        parser.add_argument(
            'match',
            help='list only substitutes 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='clear all substitutes')
        self.api('commands.add')('clear', self.cmd_clear, parser=parser)

        self.api('commands.default')('list')
        self.api('events.register')('from_mud_event', self.findsub)

        self.api('events.register')('plugin_%s_savestate' % self.sname,
                                    self._savestate)
Ejemplo n.º 38
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    parser = argp.ArgumentParser(add_help=False,
                                 description='list functions in the api')
    parser.add_argument('toplevel',
                        help='the top level api to show (optional)',
                        default='', nargs='?')
    self.api('commands.add')('list', self.cmd_list,
                             parser=parser)
    parser = argp.ArgumentParser(add_help=False,
                                 description='detail a function in the api')
    parser.add_argument('api', help='the api to detail (optional)',
                        default='', nargs='?')
    self.api('commands.add')('detail', self.cmd_detail,
                             parser=parser)
Ejemplo n.º 39
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    parser = argparse.ArgumentParser(add_help=False,
                 description='list functions in the api')
    parser.add_argument('toplevel',
                        help='the top level api to show (optional)',
                        default='', nargs='?')
    self.api.get('commands.add')('list', self.cmd_list,
                                 parser=parser)
    parser = argparse.ArgumentParser(add_help=False,
                 description='detail a function in the api')
    parser.add_argument('api', help='the api to detail (optional)',
                        default='', nargs='?')
    self.api.get('commands.add')('detail', self.cmd_detail,
                                 parser=parser)
Ejemplo n.º 40
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        parser = argparse.ArgumentParser(add_help=False,
                                         description='loop a command')
        parser.add_argument('cmd',
                            help='the command to run',
                            default='',
                            nargs='?')
        parser.add_argument('-c',
                            "--count",
                            help="how many times to execute the command",
                            default=1)
        self.api.get('commands.add')('cmd', self.cmd_loop, parser=parser)

        self.api.get('commands.default')('loop')
Ejemplo n.º 41
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        self.api.get("triggers.add")("reconnect", "^############# Reconnecting to Game #############$")

        self.api.get("events.register")("GMCP:char", self._char)
        self.api.get("events.register")("GMCP:room.info", self._roominfo)
        self.api.get("events.register")("trigger_reconnect", self.reconnect)
        self.api.get("events.register")("client_connected", self.clientconnected)

        self.api.get("events.register")("GMCP:server-enabled", self.enablemods)

        state = self.api.get("GMCP.getv")("char.status.state")
        proxy = self.api.get("managers.getm")("proxy")
        if state == 3 and proxy and proxy.connected:
            self.enablemods()
            self.clientconnected()
Ejemplo n.º 42
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    self.api('events.register')('GMCP', self.test)
    self.api('events.register')('GMCP:char', self.testchar)
    self.api('events.register')('GMCP:char.status', self.testcharstatus)

    parser = argp.ArgumentParser(
        add_help=False,
        description='print what is in a module in the gmcp cache')
    parser.add_argument('module',
                        help='the module to show',
                        default='',
                        nargs='?')
    self.api('commands.add')('get',
                             self.cmd_get,
                             parser=parser)
Ejemplo n.º 43
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        parser = argparse.ArgumentParser(add_help=False, description="get details of a trigger")
        parser.add_argument("trigger", help="the trigger to detail", default=[], nargs="*")
        self.api.get("commands.add")("detail", self.cmd_detail, parser=parser)

        parser = argparse.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.get("commands.add")("list", self.cmd_list, parser=parser)

        # self.api.get('commands.add')('stats', self.cmd_stats,
        #                             shelp='show trigger stats')

        self.api.get("events.register")("from_mud_event", self.checktrigger, prio=1)

        self.api.get("events.register")("plugin_unloaded", self.pluginunloaded)
Ejemplo n.º 44
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='loop a command')
    parser.add_argument('cmd',
                        help='the command to run',
                        default='',
                        nargs='?')
    parser.add_argument('-c',
                        "--count",
                        help="how many times to execute the command",
                        default=1)
    self.api.get('commands.add')('cmd',
                                 self.cmd_loop,
                                 parser=parser)

    self.api.get('commands.default')('loop')
Ejemplo n.º 45
0
  def load(self):
    """
    load the plugin
    """
    BasePlugin.load(self)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='show errors')
    parser.add_argument('number',
                        help='list the last <number> errors',
                        default='-1',
                        nargs='?')
    self.api.get('commands.add')('show',
                                 self.cmd_show,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='clear errors')
    self.api.get('commands.add')('clear',
                                 self.cmd_clear,
                                 parser=parser)
Ejemplo n.º 46
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        self.api.get('triggers.add')(
            'reconnect', "^############# Reconnecting to Game #############$")

        self.api.get('events.register')('GMCP:char', self._char)
        self.api.get('events.register')('GMCP:room.info', self._roominfo)
        self.api.get('events.register')('trigger_reconnect', self.reconnect)
        self.api.get('events.register')('client_connected',
                                        self.clientconnected)

        self.api.get('events.register')('GMCP:server-enabled', self.enablemods)

        state = self.api.get('GMCP.getv')('char.status.state')
        proxy = self.api.get('managers.getm')('proxy')
        if state == 3 and proxy and proxy.connected:
            self.enablemods()
            self.clientconnected()
Ejemplo n.º 47
0
  def load(self):
    """
    load the plugins
    """
    BasePlugin.load(self)

    self.api('triggers.add')('connect_return',
                             r"\[ Press Return to continue \]")

    self.api('events.register')('muddisconnect', self._disconnect)
    self.api('events.register')('GMCP:char', self._check)
    self.api('events.register')('GMCP:room.info', self._check)
    self.api('events.register')('GMCP:comm.quest', self._check)
    self.api('events.register')('trigger_connect_return', self._connect_return)
    self.api('events.register')('client_connected', self.clientconnected)

    self.api('events.register')('GMCP:server-enabled', self.enablemods)

    state = self.api('GMCP.getv')('char.status.state')
    mud = self.api('managers.getm')('mud')
    if state == 3 and mud and mud.connected:
      self.enablemods()
      self.clientconnected()
Ejemplo n.º 48
0
    def load(self):
        """
    load the plugins
    """
        BasePlugin.load(self)

        self.api('triggers.add')('connect_return',
                                 r"\[ Press Return to continue \]")

        self.api('events.register')('muddisconnect', self._disconnect)
        self.api('events.register')('GMCP:char', self._check)
        self.api('events.register')('GMCP:room.info', self._check)
        self.api('events.register')('GMCP:comm.quest', self._check)
        self.api('events.register')('trigger_connect_return',
                                    self._connect_return)
        self.api('events.register')('client_connected', self.clientconnected)

        self.api('events.register')('GMCP:server-enabled', self.enablemods)

        state = self.api('GMCP.getv')('char.status.state')
        mud = self.api('managers.getm')('mud')
        if state == 3 and mud and mud.connected:
            self.enablemods()
            self.clientconnected()
Ejemplo n.º 49
0
    def load(self):
        """
    load external stuff
    """
        BasePlugin.load(self)
        self.api('log.adddtype')(self.sname)
        #self.api('log.console')(self.sname)

        self.api('setting.add')('cmdprefix', '#bp', str,
                                'the command preamble for the proxy')
        self.api('setting.add')('spamcount', 20, int,
                                'the # of times a command can ' \
                                 'be run before an antispam command')
        self.api('setting.add')('antispamcommand', 'look', str,
                                'the antispam command to send')
        self.api('setting.add')(
            'cmdcount',
            0,
            int,
            'the # of times the current command has been run',
            readonly=True)
        self.api('setting.add')('lastcmd',
                                '',
                                str,
                                'the last command that was sent to the mud',
                                readonly=True)
        self.api('setting.add')('historysize', 50, int,
                                'the size of the history to keep')

        parser = argp.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('commands.add')('list',
                                 self.cmd_list,
                                 shelp='list commands',
                                 parser=parser,
                                 showinhistory=False)

        parser = argp.ArgumentParser(add_help=False,
                                     description='list the command history')
        parser.add_argument('-c',
                            "--clear",
                            help="clear the history",
                            action='store_true')
        self.api('commands.add')('history',
                                 self.cmd_history,
                                 shelp='list or run a command in history',
                                 parser=parser,
                                 showinhistory=False)

        parser = argp.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('commands.add')('!',
                                 self.cmd_runhistory,
                                 shelp='run a command in history',
                                 parser=parser,
                                 preamble=False,
                                 format=False,
                                 showinhistory=False)

        self.api('events.register')('io_execute_event', self.chkcmd, prio=5)
        self.api('events.register')('plugin_unloaded', self.pluginunloaded)
        self.api('events.eraise')('plugin_cmdman_loaded', {})

        self.api('events.register')('plugin_%s_savestate' % self.sname,
                                    self._savestate)
Ejemplo n.º 50
0
 def load(self):
   """
   load the plugins
   """
   BasePlugin.load(self)
Ejemplo n.º 51
0
  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)
Ejemplo n.º 52
0
  def load(self):
    BasePlugin.load(self)

    self.api.get('options.addserveroption')(self.sname, SERVER)
    self.api.get('options.addclientoption')(self.sname, CLIENT)
Ejemplo n.º 53
0
  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)
Ejemplo n.º 54
0
 def load(self):
   """
   load the plugins
   """
   BasePlugin.load(self)
Ejemplo n.º 55
0
  def load(self):
    """
    load the plugin
    """
    BasePlugin.load(self)

    self.api.get('setting.add')('nextnum', 0, int,
                                'the number of the next alias added',
                                readonly=True)

    parser = argparse.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.get('commands.add')('add',
                                 self.cmd_add,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='remove an alias')
    parser.add_argument('alias',
                        help='the alias to remove',
                        default='',
                        nargs='?')
    self.api.get('commands.add')('remove',
                                 self.cmd_remove,
                                 parser=parser)

    parser = argparse.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.get('commands.add')('list',
                                 self.cmd_list,
                                 parser=parser)

    parser = argparse.ArgumentParser(add_help=False,
                                     description='toggle enabled flag')
    parser.add_argument('alias',
                        help='the alias to toggle',
                        default='',
                        nargs='?')
    self.api.get('commands.add')('toggle',
                                 self.cmd_toggle,
                                 parser=parser)

    parser = argparse.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.get('commands.add')('groupt',
                                 self.cmd_grouptoggle,
                                 parser=parser)

    parser = argparse.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.get('commands.add')('detail',
                                 self.cmd_detail,
                                 parser=parser)

    self.api.get('commands.default')('list')
    self.api.get('events.register')('from_client_event', self.checkalias,
                                    prio=2)
Ejemplo n.º 56
0
    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.get('events.register')('from_mud_event', self.logmud)
        self.api.get('events.register')('to_mud_event', self.logmud)

        parser = argparse.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.get('commands.add')('client',
                                     self.cmd_client,
                                     lname='Logger',
                                     parser=parser)

        parser = argparse.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.get('commands.add')('file',
                                     self.cmd_file,
                                     lname='Logger',
                                     parser=parser)

        parser = argparse.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.get('commands.add')('console',
                                     self.cmd_console,
                                     lname='Logger',
                                     parser=parser)

        parser = argparse.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.get('commands.add')('types',
                                     self.cmd_types,
                                     lname='Logger',
                                     parser=parser)
Ejemplo n.º 57
0
  def load(self):
    """
    load external stuff
    """
    BasePlugin.load(self)
    self.api('log.adddtype')(self.sname)
    #self.api('log.console')(self.sname)

    self.api('setting.add')('cmdprefix', '#bp', str,
                            'the command preamble for the proxy')
    self.api('setting.add')('spamcount', 20, int,
                            'the # of times a command can ' \
                             'be run before an antispam command')
    self.api('setting.add')('antispamcommand', 'look', str,
                            'the antispam command to send')
    self.api('setting.add')('cmdcount', 0, int,
                            'the # of times the current command has been run',
                            readonly=True)
    self.api('setting.add')('lastcmd', '', str,
                            'the last command that was sent to the mud',
                            readonly=True)
    self.api('setting.add')('historysize', 50, int,
                            'the size of the history to keep')

    parser = argp.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('commands.add')('list',
                             self.cmd_list,
                             shelp='list commands',
                             parser=parser,
                             showinhistory=False)

    parser = argp.ArgumentParser(add_help=False,
                                 description='list the command history')
    parser.add_argument('-c',
                        "--clear",
                        help="clear the history",
                        action='store_true')
    self.api('commands.add')('history',
                             self.cmd_history,
                             shelp='list or run a command in history',
                             parser=parser,
                             showinhistory=False)

    parser = argp.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('commands.add')('!',
                             self.cmd_runhistory,
                             shelp='run a command in history',
                             parser=parser,
                             preamble=False,
                             format=False,
                             showinhistory=False)

    self.api('events.register')('io_execute_event', self.chkcmd, prio=5)
    self.api('events.register')('plugin_unloaded', self.pluginunloaded)
    self.api('events.eraise')('plugin_cmdman_loaded', {})

    self.api('events.register')('plugin_%s_savestate' % self.sname, self._savestate)