Ejemplo n.º 1
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.º 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 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.º 4
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.º 5
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.º 6
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.º 7
0
  def load(self):
    """
    load the plugins
    """
    AardwolfBasePlugin.load(self)

    self.api('events.register')('aard_quest_comp', self.compquest)
    self.api('events.register')('aard_cp_comp', self.compcp)
    self.api('events.register')('aard_level_gain', self.levelgain)
    self.api('events.register')('aard_gq_won', self.compgq)
    self.api('events.register')('aard_gq_done', self.compgq)
    self.api('events.register')('aard_gq_completed', self.compgq)
    self.api('events.register')('var_statmn_show', self.showchange)

    self.api('setting.add')('statcolor', '@W', 'color', 'the stat color')
    self.api('setting.add')('infocolor', '@x33', 'color', 'the info color')
    self.api('setting.add')('show', '5m', 'timelength',
                            'show the report every x time')
    self.api('setting.add')('reportminutes', '60m', 'timelength',
                            'the # of minutes for the report to show')
    self.api('setting.add')('exppermin', 20, int,
                            'the threshhold for showing exp per minute')

    parser = argp.ArgumentParser(add_help=False,
                                 description='show report')
    parser.add_argument('minutes', help='the number of minutes in the report',
                        default='60m', nargs='?')
    self.api('commands.add')('rep', self.cmd_rep,
                             parser=parser, format=False, preamble=False)
Ejemplo n.º 8
0
    def __init__(self, ssname, plugin, **kwargs):
        """
    initialize the class
    """
        self.ssname = ssname
        self.plugin = plugin
        self.sname = plugin.sname
        self.name = plugin.name
        self.api = plugin.api

        if 'default' in kwargs:
            self.default = kwargs['default']
        else:
            self.default = ''

        if 'desc' in kwargs:
            self.desc = kwargs['desc']
        else:
            self.desc = 'setting'

        self.api('api.add')(self.ssname, self.getss)

        parser = argp.ArgumentParser(add_help=False,
                                     description='set the %s' % self.desc)
        parser.add_argument('value', help=self.desc, default='', nargs='?')
        self.api('commands.add')(self.ssname,
                                 self.cmd_setssc,
                                 showinhistory=False,
                                 parser=parser)
Ejemplo n.º 9
0
  def load(self):
    """
    load the plugins
    """
    AardwolfBasePlugin.load(self)

    self.invdetailscmd = InvdetailsCmd(self)
    self.identifycmd = IdentifyCmd(self)

    self.api('setting.add')('idcmd', True, str,
                            'identify')

    parser = argp.ArgumentParser(add_help=False,
                                 description='id an item')
    parser.add_argument('serial', help='the item to id', default='', nargs='?')
    parser.add_argument('-f', "--force",
                        help="force an id of the item",
                        action="store_true",
                        default=False)
    parser.add_argument('-d', "--database",
                        help="get the item from the database",
                        action="store_true",
                        default=False)
    self.api('commands.add')('id', self.cmd_id,
                             parser=parser)
Ejemplo n.º 10
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.º 11
0
    def load(self):
        """
    load the plugin
    """
        BasePlugin.load(self)

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

        parser = argp.ArgumentParser(add_help=False,
                                     description='clear errors')
        self.api('commands.add')('clear', self.cmd_clear, parser=parser)

        self.api('events.register')('proxy_ready', self.proxy_ready)
Ejemplo n.º 12
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.º 13
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.º 14
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.º 15
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.º 16
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.º 17
0
  def load(self):
    """
    load the plugins
    """
    AardwolfBasePlugin.load(self)

    self.cmdaflags = AFlagsCmd(self)
    self.aflags = AFlags(self)

    parser = argp.ArgumentParser(add_help=False,
                                 description='refresh affect flags')
    self.api('commands.add')('refresh', self.cmd_refresh,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='check to see if affected by a flag')
    parser.add_argument('flag', help='the flag to check',
                        default='', nargs='?')
    self.api('commands.add')('check', self.cmd_check,
                             parser=parser)

    parser = argp.ArgumentParser(add_help=False,
                                 description='list affect flags')
    self.api('commands.add')('list', self.cmd_list,
                             parser=parser)

    self.api('events.register')('aard_skill_affoff',
                                self.flagschanged, prio=10)
    self.api('events.register')('aard_skill_affon',
                                self.flagschanged, prio=10)
    self.api('events.register')('aard_skill_recoff',
                                self.refreshflags, prio=99)
    self.api('events.register')('aard_skill_recon',
                                self.refreshflags, prio=99)
    self.api('events.register')('skills_affected_update',
                                self.refreshflags, prio=99)
    self.api('events.register')('skills_uptodate',
                                self.refreshflags, prio=99)
    self.api('events.register')('affect_diff',
                                self.flagsdiff)
Ejemplo n.º 18
0
    def load(self):
        """
    load the plugin
    """
        AardwolfBasePlugin.load(self)

        parser = argp.ArgumentParser(add_help=False,
                                     description='show needed aarch items')
        parser.add_argument('filter',
                            help='a word in an aarch piece to check for',
                            default='',
                            nargs='?')
        self.api('commands.add')('need', self.cmd_need, parser=parser)
Ejemplo n.º 19
0
    def load(self):
        """
    load the plugins
    """
        AardwolfBasePlugin.load(self)

        self.eqdb = dbcreate(self.api('sqldb.baseclass')(),
                             self,
                             dbname='eqdb',
                             dbdir=self.savedir)

        self.api('setting.add')('backupstart', '0000', 'miltime',
                                'the time for a db backup, like 1200 or 2000')
        self.api('setting.add')(
            'backupinterval', 60 * 60 * 4, int,
            'the interval to backup the db, default every 4 hours')

        parser = argp.ArgumentParser(add_help=False, description='get item')
        parser.add_argument('id',
                            help='the identifier/serial/wearloc',
                            default='',
                            nargs='?')
        self.api('commands.add')('getitem', self.cmd_getitem, parser=parser)

        parser = argp.ArgumentParser(add_help=False, description='test')
        self.api('commands.add')('test', self.cmd_test, parser=parser)

        #self.api('events.register')('GMCP:char.status', self.checkstats)
        self.api('events.register')('statdb_backupstart', self.changetimer)
        self.api('events.register')('statdb_backupinternval', self.changetimer)

        self.api('events.register')('trigger_dead', self.dead)

        self.api('timers.add')('eq_backup',
                               self.backupdb,
                               self.api('setting.gets')('backupinterval'),
                               time=self.api('setting.gets')('backupstart'))
Ejemplo n.º 20
0
    def load(self):
        """
    load the module
    """
        BasePlugin.load(self)
        self.api('events.register')('log_plugin_loaded', self.logloaded)
        self.api('events.eraise')('event_plugin_loaded', {})

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

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

        parser = argp.ArgumentParser(add_help=False,
                                     description='raise an event')
        parser.add_argument('event',
                            help='the event to raise',
                            default='',
                            nargs='?')
        self.api('commands.add')('raise', self.cmd_raise, parser=parser)

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

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

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

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

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

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

        parser = argp.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('commands.add')('cmd', self.cmd_loop, parser=parser)

        self.api('commands.default')('cmd')
Ejemplo n.º 24
0
    def load(self):
        """
    load the plugins
    """
        AardwolfBasePlugin.load(self)

        self.api('triggers.add')(
            'daily1',
            r"^You can receive a new daily blessing in (?P<hours>[\d]*) hour[s]*, " \
               r"(?P<minutes>[\d]*) minute[s]* and (?P<seconds>[\d]*) second[s]*.$")

        self.api('triggers.add')(
            'daily2',
            r"^You can receive a new daily blessing in (?P<minutes>[\d]*) minute[s]* " \
               r"and (?P<seconds>[\d]*) second[s]*.$")

        self.api(
            'triggers.add'
        )('daily3',
          r"^You can receive a new daily blessing in (?P<seconds>[\d]*) second[s]*.$"
          )

        self.api('triggers.add')(
            'dailynow', "^You are ready to receive a new daily blessing.$")

        self.api('triggers.add')(
            'tookdaily',
            "^You bow your head to Ayla and receive your daily blessing.$")

        parser = argp.ArgumentParser(add_help=False,
                                     description='show next daily')
        self.api('commands.add')('next', self.cmd_next, parser=parser)

        self.api('events.register')('trigger_daily1', self.dailytime)
        self.api('events.register')('trigger_daily2', self.dailytime)
        self.api('events.register')('trigger_daily3', self.dailytime)
        self.api('events.register')('trigger_tookdaily', self.tookdaily)
        self.api('events.register')('trigger_dailynow', self.dailyavailable)

        self.checkdaily()
Ejemplo n.º 25
0
    def load(self):
        """
    load the plugins
    """
        AardwolfBasePlugin.load(self)

        self.skills = Skills(self)
        self.slistcmd = SListCmd(self)

        self.api('send.msg')('running load function of skills')

        parser = argp.ArgumentParser(add_help=False,
                                     description='refresh skills and spells')
        self.api('commands.add')('refresh', self.cmd_refresh, parser=parser)

        parser = argp.ArgumentParser(
            add_help=False, description='lookup skill or spell by name or sn')
        parser.add_argument('skill',
                            help='the skill to lookup',
                            default='',
                            nargs='?')
        self.api('commands.add')('lu', self.cmd_lu, parser=parser)

        self.api('triggers.add')('affoff',
                                 r"^\{affoff\}(?P<sn>\d+)$",
                                 argtypes={
                                     'sn': int
                                 })
        self.api('triggers.add')('affon',
                                 r"^\{affon\}(?P<sn>\d+),(?P<duration>\d+)$",
                                 argtypes={
                                     'sn': int,
                                     'duration': int
                                 })
        self.api('triggers.add')('recoff',
                                 r"^\{recoff\}(?P<sn>\d+)$",
                                 argtypes={
                                     'sn': int
                                 })
        self.api('triggers.add')('recon',
                                 r"^\{recon\}(?P<sn>\d+),(?P<duration>\d+)$",
                                 argtypes={
                                     'sn': int,
                                     'duration': int
                                 })
        self.api('triggers.add')(
            'skillgain',
            r"^\{skillgain\}(?P<sn>\d+),(?P<percent>\d+)$",
            argtypes={
                'sn': int,
                'percent': int
            })
        self.api('triggers.add')('skillfail',
                                 r"^\{sfail\}(?P<sn>\d+),(?P<target>\d+)," \
                                   r"(?P<reason>\d+),(?P<recovery>-?\d+)$",
                                 argtypes={'sn':int, 'target':int,
                                           'reason':int, 'recovery':int})

        self.api('events.register')('trigger_affoff', self.affoff)
        self.api('events.register')('trigger_affon', self.affon)
        self.api('events.register')('trigger_recoff', self.recoff)
        self.api('events.register')('trigger_recon', self.recon)
        self.api('events.register')('trigger_skillgain', self.skillgain)
        self.api('events.register')('trigger_skillfail', self.skillfail)

        self.api('events.register')('GMCP:char.status', self.checkskills)

        self.api('events.register')('aard_level_tier', self.cmd_refresh)
        self.api('events.register')('aard_level_remort', self.cmd_refresh)

        self.api('events.register')('muddisconnect', self.skillsdisconnect)
Ejemplo n.º 26
0
    def _loadcommands(self):
        """
    load the commands
    """
        parser = argp.ArgumentParser(
            add_help=False,
            formatter_class=argp.RawDescriptionHelpFormatter,
            description=textwrap.dedent("""
          change a setting in the plugin

          if there are no arguments or 'list' is the first argument then
          it will list the settings for the plugin"""))
        parser.add_argument('name',
                            help='the setting name',
                            default='list',
                            nargs='?')
        parser.add_argument('value',
                            help='the new value of the setting',
                            default='',
                            nargs='?')
        self.api('commands.add')('set',
                                 self._cmd_set,
                                 parser=parser,
                                 group='Base',
                                 showinhistory=False)

        if self.canreset:
            parser = argp.ArgumentParser(add_help=False,
                                         description='reset the plugin')
            self.api('commands.add')('reset',
                                     self._cmd_reset,
                                     parser=parser,
                                     group='Base')

        parser = argp.ArgumentParser(add_help=False,
                                     description='save the plugin state')
        self.api('commands.add')('save',
                                 self._cmd_save,
                                 parser=parser,
                                 group='Base')

        parser = argp.ArgumentParser(add_help=False,
                                     description='show plugin stats')
        self.api('commands.add')('stats',
                                 self._cmd_stats,
                                 parser=parser,
                                 group='Base')

        parser = argp.ArgumentParser(add_help=False,
                                     description='inspect a plugin')
        parser.add_argument('-m',
                            "--method",
                            help="get code for a method",
                            default='')
        parser.add_argument(
            '-o',
            "--object",
            help="show an object of the plugin, can be method or variable",
            default='')
        parser.add_argument('-s',
                            "--simple",
                            help="show a simple output",
                            action="store_true")
        self.api('commands.add')('inspect',
                                 self._cmd_inspect,
                                 parser=parser,
                                 group='Base')

        parser = argp.ArgumentParser(
            add_help=False, description='show help info for this plugin')
        parser.add_argument('-a',
                            "--api",
                            help="show functions this plugin has in the api",
                            action="store_true")
        parser.add_argument('-c',
                            "--commands",
                            help="show commands in this plugin",
                            action="store_true")
        self.api('commands.add')('help',
                                 self._cmd_help,
                                 parser=parser,
                                 group='Base')

        parser = argp.ArgumentParser(add_help=False,
                                     description='list functions in the api')
        parser.add_argument('api',
                            help='api to get details of',
                            default='',
                            nargs='?')
        self.api('commands.add')('api',
                                 self._cmd_api,
                                 parser=parser,
                                 group='Base')
Ejemplo n.º 27
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.º 28
0
    def api_addcmd(self, cmdname, func, **kwargs):
        # pylint: disable=too-many-branches
        """  add a command
    @Ycmdname@w  = the base that the api should be under
    @Yfunc@w   = the function that should be run when this command is executed
    @Ykeyword arguments@w
      @Yshelp@w    = the short help, a brief description of what the
                                          command does
      @Ylhelp@w    = a longer description of what the command does
      @Ypreamble@w = show the preamble for this command (default: True)
      @Yformat@w   = format this command (default: True)
      @Ygroup@w    = the group this command is in

    The command will be added as sname.cmdname

    sname is gotten from the class the function belongs to or the sname key
      in args

    this function returns no values"""

        args = kwargs.copy()

        calledfrom = self.api('api.callerplugin')()

        lname = None
        if not func:
            self.api('send.error')(
                'add cmd for cmd %s was passed a null function from plugin %s, not adding' % \
                      (cmdname, calledfrom), secondary=calledfrom)
            return
        try:
            sname = func.im_self.sname
        except AttributeError:
            if 'sname' in args:
                sname = args['sname']
            else:
                callstack = self.api('api.callstack')()
                self.api('send.error')(
                    'Function is not part of a plugin class: cmd %s from plugin %s' % \
                          (cmdname, calledfrom), secondary=calledfrom)
                self.api('send.error')("\n".join(callstack).strip())
                return

        if 'parser' in args:
            tparser = args['parser']
            tparser.formatter_class = CustomFormatter

        else:
            self.api('send.msg')('adding default parser to command %s.%s' % \
                                            (sname, cmdname))
            if 'shelp' not in args:
                args['shelp'] = 'there is no help for this command'
            tparser = argp.ArgumentParser(add_help=False,
                                          description=args['shelp'])
            args['parser'] = tparser

        tparser.add_argument("-h",
                             "--help",
                             help="show help",
                             action="store_true")

        tparser.prog = '@B%s.%s.%s@w' % (self.api('setting.gets')('cmdprefix'),
                                         sname, cmdname)

        if 'group' not in args:
            args['group'] = sname

        try:
            lname = func.im_self.name
            args['lname'] = lname
        except AttributeError:
            pass

        if 'lname' not in args:
            self.api('send.msg')('cmd %s.%s has no long name, not adding' % \
                                                  (sname, cmdname),
                                 secondary=sname)
            return

        self.api('send.msg')('added cmd %s.%s' % \
                                                (sname, cmdname),
                             secondary=sname)

        if sname not in self.cmds:
            self.cmds[sname] = {}
        args['func'] = func
        args['sname'] = sname
        args['lname'] = lname
        args['commandname'] = cmdname
        if 'preamble' not in args:
            args['preamble'] = True
        if 'format' not in args:
            args['format'] = True
        if 'showinhistory' not in args:
            args['showinhistory'] = True
        self.cmds[sname][cmdname] = args
Ejemplo n.º 29
0
    def load(self):
        """
    load the plugins
    """
        AardwolfBasePlugin.load(self)

        self.api('cmdq.addcmdtype')('cpcheck',
                                    'campaign check',
                                    "^campaign check$",
                                    beforef=self.cpcheckbefore,
                                    afterf=self.cpcheckafter)

        parser = argp.ArgumentParser(add_help=False,
                                     description='show cp info')
        self.api('commands.add')('show', self.cmd_show, parser=parser)

        parser = argp.ArgumentParser(add_help=False,
                                     description='refresh cp info')
        self.api('commands.add')('refresh', self.cmd_refresh, parser=parser)

        self.api('watch.add')(
            'cp_check',
            '^(cp|campa|campai|campaig|campaign) (c|ch|che|chec|check)$')

        self.api('triggers.add')('cpnew',
                                 "^Commander Barcett tells you " \
                                   "'Type 'campaign info' to see what you must kill.'$")
        self.api('triggers.add')('cpnone',
                                 "^You are not currently on a campaign.$",
                                 enabled=False,
                                 group='cpcheck',
                                 omit=True)
        self.api('triggers.add')(
            'cptime',
            "^You have (?P<time>.*) to finish this campaign.$",
            enabled=False,
            group='cpcheck',
            omit=True)
        self.api('triggers.add')('cpmob',
                                 r"^You still have to kill \* (?P<mob>.*) " \
                                   r"\((?P<location>.*?)(?P<dead> - Dead|)\)$",
                                 enabled=False, group='cpcheck', omit=True)
        self.api('triggers.add')('cpscramble',
                                 "Note: One or more target names in this " \
                                   "campaign might be slightly scrambled.$",
                                 enabled=False, group='cpcheck', omit=True)
        self.api('triggers.add')('cpneedtolevel',
                                 "^You will have to level before you" \
                                   " can go on another campaign.$",
                                 enabled=False,
                                 group='cpin')
        self.api('triggers.add')('cpcantake',
                                 "^You may take a campaign at this level.$",
                                 enabled=False,
                                 group='cpin')
        self.api('triggers.add')(
            'cpshnext',
            "^You cannot take another campaign for (?P<time>.*).$",
            enabled=False,
            group='cpin')
        self.api('triggers.add')(
            'cpmobdead',
            "^Congratulations, that was one of your CAMPAIGN mobs!$",
            enabled=False,
            group='cpin')
        self.api('triggers.add')(
            'cpcomplete',
            "^CONGRATULATIONS! You have completed your campaign.$",
            enabled=False,
            group='cpin')
        self.api('triggers.add')('cpclear',
                                 "^Campaign cleared.$",
                                 enabled=False,
                                 group='cpin')
        self.api('triggers.add')(
            'cpreward',
            r"^\s*Reward of (?P<amount>\d+) (?P<type>.+) .+ added.$",
            enabled=False,
            group='cprew',
            argtypes={
                'amount': int
            })
        self.api('triggers.add')('cpcompdone',
                                 "^--------------------------" \
                                   "------------------------------------$",
                                 enabled=False,
                                 group='cpdone')

        self.api('events.register')('trigger_cpnew', self._cpnew)
        self.api('events.register')('trigger_cpnone', self._cpnone)
        self.api('events.register')('trigger_cptime', self._cptime)
        #self.api('events.register')('watch_cp_check', self._cpcheckcmd)
        self.api('events.register')('trigger_cpmob', self._cpmob)
        self.api('events.register')('trigger_cpneedtolevel',
                                    self._cpneedtolevel)
        self.api('events.register')('trigger_cpcantake', self._cpcantake)
        self.api('events.register')('trigger_cpshnext', self._cpshnext)
        self.api('events.register')('trigger_cpmobdead', self._cpmobdead)
        self.api('events.register')('trigger_cpcomplete', self._cpcomplete)
        self.api('events.register')('trigger_cpclear', self._cpclear)
        self.api('events.register')('trigger_cpreward', self._cpreward)
        self.api('events.register')('trigger_cpcompdone', self._cpcompdone)

        self.api('events.register')('plugin_%s_savestate' % self.sname,
                                    self._savestate)
Ejemplo n.º 30
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)