Ejemplo n.º 1
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        self.adminPlugin = self.console.getPlugin('admin')

        # create database tables (if needed)
        if 'callvote' not in self.console.storage.getTables():
            sql_path_main = b3.getAbsolutePath('@b3/plugins/callvote/sql')
            sql_path = os.path.join(sql_path_main, self.console.storage.dsnDict['protocol'], 'callvote.sql')
            self.console.storage.queryFromFile(sql_path)

        # unregister the veto command of the admin plugin
        if self.console.getPlugin('poweradminurt'):
            self.adminPlugin.unregisterCommand('paveto')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent('EVT_CLIENT_CALLVOTE', self.onCallvote)
        self.registerEvent('EVT_VOTE_PASSED', self.onCallvoteFinish)
        self.registerEvent('EVT_VOTE_FAILED', self.onCallvoteFinish)

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 2
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # get the admin plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            raise AttributeError('could not find admin plugin')

        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        # do not balance on the 1st minute after bot start
        self._ignoreBalancingTill = self.console.time() + 60

        # register our events
        self.registerEvent('EVT_CLIENT_TEAM_CHANGE', self.onTeamChange)
        self.registerEvent('EVT_GAME_ROUND_START', self.onRoundStart)
        self.registerEvent('EVT_GAME_ROUND_PLAYER_SCORES',
                           self.onGameRoundPlayerScores)
        self.registerEvent('EVT_CLIENT_AUTH', self.onClientAuth)
        self.registerEvent('EVT_CLIENT_DISCONNECT', self.onClientDisconnect)
Ejemplo n.º 3
0
    def onStartup(self):
        """
        Startup the plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            raise AttributeError('could not find admin plugin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        self.registerEvent('EVT_CLIENT_AUTH', self.onAuth)

        if self._banlists:
            for banlist in self._banlists:
                if banlist._cronTab:
                    # remove existing crontab
                    self.console.cron - banlist._cronTab
        if self._whitelists:
            for whitelist in self._whitelists:
                if whitelist._cronTab:
                    # remove existing crontab
                    self.console.cron - whitelist._cronTab
    def onStartup(self):
        """
		startup the plugin
		"""
        # get the admin plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')
        self.powerAdminUrtPlugin = self.console.getPlugin(
            'powerAdminUrtPlugin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        self.registerEvent('EVT_GAME_ROUND_START', self.onNewMap)
        self.registerEvent('EVT_GAME_EXIT')
        self.registerEvent('EVT_GAME_ROUND_END')
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # patch the admin module
        patch_admin_module(self._adminPlugin)

        # create database tables (if needed)
        if 'cmdgrants' not in self.console.storage.getTables():
            sql_path_main = b3.getAbsolutePath('@b3/plugins/cmdmanager/sql')
            sql_path = os.path.join(sql_path_main, self.console.storage.dsnDict['protocol'], 'cmdmanager.sql')
            self.console.storage.queryFromFile(sql_path)

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # register events needed
        self.registerEvent('EVT_CLIENT_AUTH', self.onAuth)

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 6
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        try:
            # register the events needed using the new event dispatch system
            self.registerEvent(self.console.getEventID('EVT_CLIENT_CONNECT'),
                               self.onConnect)
        except TypeError:
            # keep backwards compatibility
            self.registerEvent(self.console.getEventID('EVT_CLIENT_CONNECT'))

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 7
0
    def onStartup(self):
        """
        Initialize the plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent('EVT_CLIENT_DAMAGE_TEAM', self.onDamageTeam)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onTeamKill)
        self.registerEvent('EVT_CLIENT_KILL', self.onKill)
        self.registerEvent('EVT_CLIENT_DAMAGE', self.onDamage)
        self.registerEvent('EVT_GAME_EXIT', self.onShowAwards)
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onShowAwards)
        self.registerEvent('EVT_GAME_ROUND_START', self.onRoundStart)
Ejemplo n.º 8
0
    def onStartup(self):
        """
        Initialize the plugin
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # register events needed
        self.registerEvent('EVT_CLIENT_GEOLOCATION_SUCCESS', self.onGeolocationSuccess)
        self.registerEvent('EVT_CLIENT_GEOLOCATION_FAILURE', self.onGeolocationFailure)

        welcomePlugin = self.console.getPlugin('welcome')
        if welcomePlugin:
            self.info('NOTE: to run this plugin you don\'t need to load also the Welcome plugin: disabling Welcome plugin')
            welcomePlugin.disable()
Ejemplo n.º 9
0
    def onStartup(self):
        """
        Initialize plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            raise AttributeError('could not find admin plugin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        if self.console.gameName not in ('iourt41', 'iourt42', 'iourt43'):
            self.info('NOTE: !firsths command is available only in UrbanTerror 4.x game serie')
            self._adminPlugin.unregisterCommand('firsths')

        # register events needed
        self.registerEvent('EVT_CLIENT_KILL', self.onClientKill)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onClientKillTeam)
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onMapChange)
Ejemplo n.º 10
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        self.adminPlugin = self.console.getPlugin('admin')
        
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2: 
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func: 
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent('EVT_CLIENT_SAY', self.onSay)
        self.registerEvent('EVT_CLIENT_TEAM_SAY', self.onSay)

        self.cmdPrefix = (self.adminPlugin.cmdPrefix, self.adminPlugin.cmdPrefixLoud,
                          self.adminPlugin.cmdPrefixBig, self.adminPlugin.cmdPrefixPrivate)

        # notice plugin startup
        self.debug('plugin started')
    def onStartup(self):

        self._adminPlugin = self.console.getPlugin('admin')
        
        if not self._adminPlugin:

            self.error('Could not find admin plugin')
            return False
        
        self.registerEvent('EVT_CLIENT_AUTH', self.onClientAuth)
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onGameMapChange)

        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)
                    
        self._adminleveltempmute = self._adminPlugin._commands["pbpermmute"].level[0]

        if self._cronTab:
        
            self.console.cron - self._cronTab

        self._cronTab = b3.cron.PluginCronTab(self, self.update, minute='*/1')
        self.console.cron + self._cronTab
Ejemplo n.º 12
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # get the admin plugin
        self._adminPlugin = self.console.getPlugin('admin')

        if 'commands' in self.config.sections():
            # parse the commands section looking for valid commands
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # register events needed
        self.registerEvent(self.console.getEventID('EVT_CLIENT_GEOLOCATION_SUCCESS'), self.onGeolocalization)
        self.registerEvent(self.console.getEventID('EVT_PLUGIN_DISABLED'), self.onPluginDisable)

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 13
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # patch the admin module
        patch_admin_module(self._adminPlugin)

        # create database tables (if needed)
        if 'cmdgrants' not in self.console.storage.getTables():
            sql_path_main = b3.getAbsolutePath('@b3/plugins/cmdmanager/sql')
            sql_path = os.path.join(sql_path_main, self.console.storage.dsnDict['protocol'], 'cmdmanager.sql')
            self.console.storage.queryFromFile(sql_path)

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # register events needed
        self.registerEvent('EVT_CLIENT_AUTH', self.onAuth)

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 14
0
    def onStartup(self):
        """
        Initialize plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            raise AttributeError('could not find admin plugin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        if self.console.gameName not in ('iourt41', 'iourt42'):
            self.info('NOTE: !firsths command is available only in UrbanTerror 4.x game serie')
            self._adminPlugin.unregisterCommand('firsths')

        # register events needed
        self.registerEvent('EVT_CLIENT_KILL', self.onClientKill)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onClientKillTeam)
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onMapChange)
Ejemplo n.º 15
0
    def onStartup(self):
        self._adminPlugin = self.console.getPlugin('admin')

        if not self._adminPlugin:
            self.error('Could not find admin plugin')
            return

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        self.registerEvent(b3.events.EVT_CLIENT_AUTH, self.onConnect)

        #prepare user-agent
        hostIp = str(self.console._publicIp)
        HostPort = str(self.console._port)
        spr = '%s:%s' % (hostIp, HostPort)
        self.serverId = str(uuid.uuid5(uuid.NAMESPACE_DNS, spr))
Ejemplo n.º 16
0
    def onStartup(self):
        """
        Initialize the plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        if self.console.PunkBuster is None:
            self.warning(
                'could not register commands because Punkbuster is disabled in your b3 configuration file'
            )
            return False

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)
Ejemplo n.º 17
0
    def onStartup(self):
        """
        Initialize plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # register events needed
        self.registerEvent('EVT_GAME_EXIT', self.onGameExit)
        self._ignoreTill = self.console.time(
        ) + 120  # dont check pings on startup

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        # remove existing crontab
        if self._cronTab:
            self.console.cron - self._cronTab

        # setup the new crontab
        self._cronTab = b3.cron.PluginCronTab(self, self.check,
                                              '*/%s' % self._interval)
        self.console.cron + self._cronTab
Ejemplo n.º 18
0
    def onStartup(self):
        """
        Initialize plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # register events needed
        self.registerEvent('EVT_GAME_EXIT', self.onGameExit)
        self._ignoreTill = self.console.time() + 120  # dont check pings on startup

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # remove existing crontab
        if self._cronTab:
            self.console.cron - self._cronTab

        # setup the new crontab
        self._cronTab = b3.cron.PluginCronTab(self, self.check, '*/%s' % self._interval)
        self.console.cron + self._cronTab
    def onStartup(self):
        
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            self.error('Could not find admin plugin')
            return False

        self.registerEvent('EVT_GAME_ROUND_START', self.onGameRoundStart)
        self.registerEvent('EVT_GAME_ROUND_END', self.onGameExit)
        self.registerEvent('EVT_GAME_EXIT', self.onGameExit)
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onGameExit)
        self.registerEvent('EVT_CLIENT_DAMAGE', self.onClientDamage)
        self.registerEvent('EVT_CLIENT_DAMAGE_TEAM', self.onClientDamage)
        self.registerEvent('EVT_CLIENT_KILL', self.onClientKill)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onClientKillTeam)
        self.registerEvent('EVT_CLIENT_SUICIDE', self.onClientSuicide)
        self.registerEvent('EVT_CLIENT_TEAM_CHANGE', self.onClientTeamChange)
        self.registerEvent('EVT_CLIENT_DISCONNECT', self.onClientDisconnect)
		
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)
Ejemplo n.º 20
0
    def onStartup(self):
        """
        Initialize the plugin
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        # register events needed
        self.registerEvent('EVT_CLIENT_GEOLOCATION_SUCCESS',
                           self.onGeolocationSuccess)
        self.registerEvent('EVT_CLIENT_GEOLOCATION_FAILURE',
                           self.onGeolocationFailure)

        welcomePlugin = self.console.getPlugin('welcome')
        if welcomePlugin:
            self.info(
                'NOTE: to run this plugin you don\'t need to load also the Welcome plugin: disabling Welcome plugin'
            )
            welcomePlugin.disable()
Ejemplo n.º 21
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # get the admin plugin
        self._adminPlugin = self.console.getPlugin('admin')

        if 'commands' in self.config.sections():
            # parse the commands section looking for valid commands
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        # register events needed
        self.registerEvent(
            self.console.getEventID('EVT_CLIENT_GEOLOCATION_SUCCESS'),
            self.onGeolocalization)
        self.registerEvent(self.console.getEventID('EVT_PLUGIN_DISABLED'),
                           self.onPluginDisable)

        # notice plugin started
        self.debug('plugin started')
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # create database tables (if needed)
        if not 'maphistory' in self.console.storage.getTables():
            protocol = self.console.storage.dsnDict['protocol']
            self.console.storage.query(self.sql[protocol])

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent(self.console.getEventID('EVT_GAME_MAP_CHANGE'), self.onLevelStart)
        self.registerEvent(self.console.getEventID('EVT_VOTE_PASSED'), self.onVotePassed)
        self.registerEvent(self.console.getEventID('EVT_GAME_EXIT'), self.onGameExit)
Ejemplo n.º 23
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # get the plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # listen for client events
        self.registerEvent('EVT_CLIENT_KILL', self.onClientKill)
        self.registerEvent('EVT_GAME_EXIT', self.onGameExit)

        self.debug('plugin started')
Ejemplo n.º 24
0
    def onStartup(self):
        """
        Initialize the plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        self.registerEvent('EVT_CLIENT_DAMAGE_TEAM', self.onDamageTeam)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onTeamKill)
        self.registerEvent('EVT_CLIENT_KILL', self.onKill)
        self.registerEvent('EVT_CLIENT_DAMAGE', self.onDamage)
        self.registerEvent('EVT_GAME_EXIT', self.onShowAwards)
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onShowAwards)
        self.registerEvent('EVT_GAME_ROUND_START', self.onRoundStart)
        if self.console.gameName == "iourt43":
            self.registerEvent('EVT_ASSIST', self.onAssist)
Ejemplo n.º 25
0
    def onStartup(self):
        """
        Startup the plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            raise AttributeError('could not find admin plugin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent('EVT_CLIENT_AUTH', self.onAuth)

        if self._banlists:
            for banlist in self._banlists:
                if banlist._cronTab :
                    # remove existing crontab
                    self.console.cron - banlist._cronTab
        if self._whitelists:
            for whitelist in self._whitelists:
                if whitelist._cronTab :
                    # remove existing crontab
                    self.console.cron - whitelist._cronTab
Ejemplo n.º 26
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # get the plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        # listen for client events
        self.registerEvent('EVT_CLIENT_KILL', self.onClientKill)
        self.registerEvent('EVT_GAME_EXIT', self.onGameExit)

        self.debug('plugin started')
Ejemplo n.º 27
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        self.adminPlugin = self.console.getPlugin('admin')
        
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2: 
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func: 
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent('EVT_CLIENT_SAY', self.onSay)
        self.registerEvent('EVT_CLIENT_TEAM_SAY', self.onSay)

        self.cmdPrefix = (self.adminPlugin.cmdPrefix, self.adminPlugin.cmdPrefixLoud,
                          self.adminPlugin.cmdPrefixBig, self.adminPlugin.cmdPrefixPrivate)

        # notice plugin startup
        self.debug('plugin started')
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        if self.settings['useirc']:
            # get the ircbot plugin if available
            self.ircbotPlugin = self.console.getPlugin('ircbot')
            if self.ircbotPlugin:
                self.debug('IRC BOT plugin loaded: admin requests will be broadcasted also on the IRC channel the BOT is in')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        try:
            # B3 > 1.10dev
            self.registerEvent(self.console.getEventID('EVT_CLIENT_AUTH'), self.onAuth)
            self.registerEvent(self.console.getEventID('EVT_CLIENT_DISCONNECT'), self.onDisconnect)
        except TypeError:
            # B3 < 1.10dev
            self.registerEvent(self.console.getEventID('EVT_CLIENT_AUTH'))
            self.registerEvent(self.console.getEventID('EVT_CLIENT_DISCONNECT'))

        # notice plugin startup
        self.debug('plugin started')
    def onStartup(self):

        self._adminPlugin = self.console.getPlugin('admin')
        
        if not self._adminPlugin:

            self.error('Could not find admin plugin')
            return False
        
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        if self.console.gameName not in ('iourt41', 'iourt42', 'iourt43'):
		
            self.debug('cmd !firsths is available only in UrbanTerror')
            self._adminPlugin.unregisterCommand('firsths')
            self._hsonoff = False

        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onMapChange)			
        self.registerEvent('EVT_CLIENT_KILL', self.onClientKill)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onClientKillTeam)
Ejemplo n.º 30
0
    def onStartup(self):
        """
        Startup the plugin
        """
        # get the admin plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')

        if not self.has_startserverdemo_cmd():
            self.error(
                "this plugin can only work with ioUrTded server with server-side demo recording capabilities: "
                "see http://www.urbanterror.info/forums/topic/28657-server-side-demo-recording/"
            )
            self.disable()
            return
        else:
            self.debug("server has startserverdemo command")

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        self.demo_manager = DemoManager(self)

        self.registerEvent('EVT_CLIENT_DISCONNECT', self.onDisconnect)
        self.registerEvent('EVT_CLIENT_JOIN', self.onJoin)

        # http://forum.bigbrotherbot.net/plugins-by-courgette/hax-buster-%28urt%29/
        if self.console.getPlugin('haxbusterurt'):
            self.info(
                "HaxBusterUrt plugin found - we will auto record demos for suspected hackers"
            )
            self.registerEvent('EVT_BAD_GUID', self.onHaxBusterUrTEvent)
            self.registerEvent('EVT_1337_PORT', self.onHaxBusterUrTEvent)
        else:
            self.info("HaxBusterUrt plugin not found")

        # http://forum.bigbrotherbot.net/releases/follow-users-plugin/
        if self.console.getPlugin('follow'):
            self.info(
                "Follow plugin found - we will auto record demos for followed players"
            )
            self.registerEvent('EVT_FOLLOW_CONNECTED',
                               self.onFollowConnectedEvent)
        else:
            self.info("Follow plugin not found")
Ejemplo n.º 31
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        self.adminPlugin = self.console.getPlugin('admin')
        if not self.adminPlugin:
            self.error('could not start without admin plugin')
            return False

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func,
                                                     alias)

        try:
            # register the events needed
            self.registerEvent(self.console.getEventID('EVT_CLIENT_SAY'),
                               self.onSay)
            self.registerEvent(self.console.getEventID('EVT_CLIENT_TEAM_SAY'),
                               self.onSay)
        except TypeError:
            # keep backwards compatibility
            self.registerEvent(self.console.getEventID('EVT_CLIENT_SAY'))
            self.registerEvent(self.console.getEventID('EVT_CLIENT_TEAM_SAY'))

        try:
            # B3 > 1.10dev
            self.cmdPrefix = (self.adminPlugin.cmdPrefix,
                              self.adminPlugin.cmdPrefixLoud,
                              self.adminPlugin.cmdPrefixBig,
                              self.adminPlugin.cmdPrefixPrivate)
        except AttributeError:
            # B3 1.9.x
            self.cmdPrefix = (self.adminPlugin.cmdPrefix,
                              self.adminPlugin.cmdPrefixLoud,
                              self.adminPlugin.cmdPrefixBig)

        # notice plugin startup
        self.debug('plugin started')
Ejemplo n.º 32
0
    def onStartup(self):
        """
        Startup the plugin
        """
        # get the admin plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')

        if not self.has_startserverdemo_cmd():
            self.error("this plugin can only work with ioUrTded server with server-side demo recording capabilities: "
                       "see http://www.urbanterror.info/forums/topic/28657-server-side-demo-recording/")
            self.disable()
            return
        else:
            self.debug("server has startserverdemo command")

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.demo_manager = DemoManager(self)

        self.registerEvent('EVT_CLIENT_DISCONNECT', self.onDisconnect)
        self.registerEvent('EVT_CLIENT_JOIN', self.onJoin)

        # http://forum.bigbrotherbot.net/plugins-by-courgette/hax-buster-%28urt%29/
        if self.console.getPlugin('haxbusterurt'):
            self.info("HaxBusterUrt plugin found - we will auto record demos for suspected hackers")
            self.registerEvent('EVT_BAD_GUID', self.onHaxBusterUrTEvent)
            self.registerEvent('EVT_1337_PORT', self.onHaxBusterUrTEvent)
        else:
            self.info("HaxBusterUrt plugin not found")

        # http://forum.bigbrotherbot.net/releases/follow-users-plugin/
        if self.console.getPlugin('follow'):
            self.info("Follow plugin found - we will auto record demos for followed players")
            self.registerEvent('EVT_FOLLOW_CONNECTED', self.onFollowConnectedEvent)
        else:
            self.info("Follow plugin not found")
    def onStartup(self):

        self._adminPlugin = self.console.getPlugin('admin')
        
        if not self._adminPlugin:

            self.error('Could not find admin plugin')
            return False
        
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onGameMapChange)

        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)
        
        self._listmapsplayed.append(self.console.game.mapName)

        self.listemaps()

        if not self._shufflemapcycle:

            if self.nmap <= 5:

                self._shufflemapcycle = True
                self.debug('maps < 6 shufflemapcycle : %s' % self._shufflemapcycle)

        if self._shufflemapcycle:

            random.shuffle(self._listmap)

            if self.console.game.mapName == self._listmap[0]:

                self.console.write("g_nextmap %s"%self._listmap[1])

            else:

                self.console.write("g_nextmap %s"%self._listmap[0])
Ejemplo n.º 34
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        self.adminPlugin = self.console.getPlugin('admin')
        if not self.adminPlugin:    
            self.error('could not start without admin plugin')
            return False
        
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2: 
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func: 
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        try:
            # register the events needed
            self.registerEvent(self.console.getEventID('EVT_CLIENT_SAY'), self.onSay)
            self.registerEvent(self.console.getEventID('EVT_CLIENT_TEAM_SAY'), self.onSay)
        except TypeError:
            # keep backwards compatibility
            self.registerEvent(self.console.getEventID('EVT_CLIENT_SAY'))
            self.registerEvent(self.console.getEventID('EVT_CLIENT_TEAM_SAY'))

        try:
            # B3 > 1.10dev
            self.cmdPrefix = (self.adminPlugin.cmdPrefix,
                              self.adminPlugin.cmdPrefixLoud,
                              self.adminPlugin.cmdPrefixBig,
                              self.adminPlugin.cmdPrefixPrivate)
        except AttributeError:
            # B3 1.9.x
            self.cmdPrefix = (self.adminPlugin.cmdPrefix,
                              self.adminPlugin.cmdPrefixLoud,
                              self.adminPlugin.cmdPrefixBig)

        # notice plugin startup
        self.debug('plugin started')
Ejemplo n.º 35
0
    def onStartup(self):
        """
        Initialize plugin.
        """
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent('EVT_CLIENT_AUTH', self.onClientAuth)
Ejemplo n.º 36
0
    def onStartup(self):
        """
        Initialize plugin.
        """
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        self.registerEvent('EVT_CLIENT_AUTH', self.onClientAuth)
    def onStartup(self):
        
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            self.error('Could not find admin plugin')
            return False

        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)
Ejemplo n.º 38
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func,
                                                     alias)

        # get server information
        self.serverinfo['ip'] = self.console.config.get('server', 'public_ip')
        self.serverinfo['port'] = self.console.config.get('server', 'port')

        # register necessary events
        self.registerEvent(self.console.getEventID('EVT_CLIENT_SAY'),
                           self.onSay)
        self.registerEvent(self.console.getEventID('EVT_CLIENT_BAN'),
                           self.onBan)
        self.registerEvent(self.console.getEventID('EVT_CLIENT_BAN_TEMP'),
                           self.onBan)
        self.registerEvent(self.console.getEventID('EVT_CLIENT_KICK'),
                           self.onKick)
        self.registerEvent(self.console.getEventID('EVT_GAME_MAP_CHANGE'),
                           self.onMapChange)

        # startup the bot
        self.ircbot = IRCBot(plugin=self)

        # start the bot main loop in a separate thread
        self.pthread = Thread(target=self.ircbot.start)
        self.pthread.setDaemon(True)
        self.pthread.start()

        # notice plugin started
        self.debug('plugin started')
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # get the admin plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            # something is wrong, can't start without admin plugin
            raise AttributeError('could not find admin plugin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

        # register our events
        self.registerEvent('EVT_GAME_ROUND_START', self.onGameRoundStart)

        # check if server is ranked/unranked
        self._isranked = self.isranked()
        self.debug('This server is %s' %
                   'ranked' if self._isranked else 'unranked')
        if not self._isranked:
            # check playlist status
            self._isplaylist_enabled = self.isplaylist_enabled()

        # get maplist excluded by server admin
        m = self.console.getCvar('playlist_excludeMap')
        if m:
            self._admin_excluded_maps = m.value
            if self._admin_excluded_maps != '':
                self.debug('Excluded maps by admin are: %s' %
                           self._admin_excluded_maps)
            else:
                self.debug('No maps found in map exclusion list')
Ejemplo n.º 40
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # get the admin plugin
        self.adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func,
                                                     alias)

        # register the events needed
        self.registerEvent('EVT_CLIENT_SPAWN', self.onSpawn)
        self.registerEvent('EVT_CLIENT_DAMAGE', self.onDamage)
        self.registerEvent('EVT_CLIENT_KILL', self.onKill)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onKillTeam)

        # create out custom events
        self.console.createEvent('EVT_CLIENT_SPAWNKILL',
                                 'Event client spawnkill')
        self.console.createEvent('EVT_CLIENT_SPAWNKILL_TEAM',
                                 'Event client spawnkill team')

        # register penalty handlers
        self.penalties['warn'] = self.warn_client
        self.penalties['kick'] = self.kick_client
        self.penalties['tempban'] = self.tempban_client
        self.penalties['slap'] = self.slap_client
        self.penalties['nuke'] = self.nuke_client
        self.penalties['kill'] = self.kill_client

        # notice plugin startup
        self.debug('plugin started')
    def onStartup(self):
        
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            raise AttributeError('could not find admin plugin')

        self.registerEvent('EVT_CLIENT_AUTH', self.onClientAuth)

        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)
Ejemplo n.º 42
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 43
0
    def onStartup(self):

        self._adminPlugin = self.console.getPlugin('admin')

        if not self._adminPlugin:

            self.error('Could not find admin plugin')
            return False

        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)
Ejemplo n.º 44
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # get the admin plugin
        self.adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        # register the events needed
        self.registerEvent('EVT_CLIENT_SPAWN', self.onSpawn)
        self.registerEvent('EVT_CLIENT_DAMAGE', self.onDamage)
        self.registerEvent('EVT_CLIENT_KILL', self.onKill)
        self.registerEvent('EVT_CLIENT_KILL_TEAM', self.onKillTeam)

        # create out custom events
        self.console.createEvent('EVT_CLIENT_SPAWNKILL', 'Event client spawnkill')
        self.console.createEvent('EVT_CLIENT_SPAWNKILL_TEAM', 'Event client spawnkill team')

        # register penalty handlers
        self.penalties['warn'] = self.warn_client
        self.penalties['kick'] = self.kick_client
        self.penalties['tempban'] = self.tempban_client
        self.penalties['slap'] = self.slap_client
        self.penalties['nuke'] = self.nuke_client
        self.penalties['kill'] = self.kill_client

        # notice plugin startup
        self.debug('plugin started')
Ejemplo n.º 45
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # get the admin plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')
        if not self._adminPlugin:
            # something is wrong, can't start without admin plugin
            raise AttributeError('could not find admin plugin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

        # register our events
        self.registerEvent('EVT_GAME_ROUND_START', self.onGameRoundStart)

        # check if server is ranked/unranked
        self._isranked = self.isranked()
        self.debug('This server is %s' % 'ranked' if self._isranked else 'unranked')
        if not self._isranked:
            # check playlist status
            self._isplaylist_enabled = self.isplaylist_enabled()

        # get maplist excluded by server admin
        m = self.console.getCvar('playlist_excludeMap')
        if m:
            self._admin_excluded_maps = m.value
            if self._admin_excluded_maps != '':
                self.debug('Excluded maps by admin are: %s' % self._admin_excluded_maps)
            else:
                self.debug('No maps found in map exclusion list')
Ejemplo n.º 46
0
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # create database tables if needed
        tables = self.console.storage.getTables()
        if not 'callvote' in tables:
            if self.console.storage.dsnDict['protocol'] == 'mysql':
                self.console.storage.query(self.sql['c1'])
            else:
                self.console.storage.query(self.sql['c2'])

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func,
                                                     alias)

        try:
            self.registerEvent(self.console.getEventID('EVT_CLIENT_CALLVOTE'),
                               self.onCallvote)
            self.registerEvent(self.console.getEventID('EVT_VOTE_PASSED'),
                               self.onCallvoteFinish)
            self.registerEvent(self.console.getEventID('EVT_VOTE_FAILED'),
                               self.onCallvoteFinish)
        except TypeError:
            self.registerEvent(self.console.getEventID('EVT_CLIENT_CALLVOTE'))
            self.registerEvent(self.console.getEventID('EVT_VOTE_PASSED'))
            self.registerEvent(self.console.getEventID('EVT_VOTE_FAILED'))

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 47
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        # register the events needed
        self.registerEvent(self.console.getEventID('EVT_CLIENT_CONNECT'), self.onConnect)

        # notice plugin startup
        self.debug('plugin started')
Ejemplo n.º 48
0
    def onStartup(self):
        """
        Initialize the plugin.
        """
        self._adminPlugin = self.console.getPlugin('admin')

        if self.console.PunkBuster is None:
            self.warning('could not register commands because Punkbuster is disabled in your b3 configuration file')
            return False

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        self.adminPlugin = self.console.getPlugin('admin')

        # create database tables (if needed)
        if 'callvote' not in self.console.storage.getTables():
            sql_path_main = b3.getAbsolutePath('@b3/plugins/callvote/sql')
            sql_path = os.path.join(sql_path_main,
                                    self.console.storage.dsnDict['protocol'],
                                    'callvote.sql')
            self.console.storage.queryFromFile(sql_path)

        # unregister the veto command of the admin plugin
        if self.console.getPlugin('poweradminurt'):
            self.adminPlugin.unregisterCommand('paveto')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func,
                                                     alias)

        self.registerEvent('EVT_CLIENT_CALLVOTE', self.onCallvote)
        self.registerEvent('EVT_VOTE_PASSED', self.onCallvoteFinish)
        self.registerEvent('EVT_VOTE_FAILED', self.onCallvoteFinish)

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 50
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        # get server information
        self.serverinfo['ip'] = self.console.config.get('server', 'public_ip')
        self.serverinfo['port'] = self.console.config.get('server', 'port')

        # register necessary events
        self.registerEvent(self.console.getEventID('EVT_CLIENT_SAY'), self.onSay)
        self.registerEvent(self.console.getEventID('EVT_CLIENT_BAN'), self.onBan)
        self.registerEvent(self.console.getEventID('EVT_CLIENT_BAN_TEMP'), self.onBan)
        self.registerEvent(self.console.getEventID('EVT_CLIENT_KICK'), self.onKick)
        self.registerEvent(self.console.getEventID('EVT_GAME_MAP_CHANGE'), self.onMapChange)

        # startup the bot
        self.ircbot = IRCBot(plugin=self)

        # start the bot main loop in a separate thread
        self.pthread = Thread(target=self.ircbot.start)
        self.pthread.setDaemon(True)
        self.pthread.start()

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 51
0
    def onStartup(self):
        """
        Initialize the plugin.
        """
        # register the events needed
        self.registerEvent('EVT_CLIENT_SAY', self.onChat)
        self.registerEvent('EVT_CLIENT_TEAM_SAY', self.onChat)
        self.registerEvent('EVT_CLIENT_PRIVATE_SAY', self.onChat)

        self._adminPlugin = self.console.getPlugin('admin')

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # create database tables (if needed)
        if 'proxies' not in self.console.storage.getTables():
            external_dir = self.console.config.get_external_plugins_dir()
            sql_path = os.path.join(external_dir, 'proxyfilter', 'sql', self.console.storage.dsnDict['protocol'], 'proxyfilter.sql')
            self.console.storage.queryFromFile(sql_path)

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        # create proxy scanner instances
        for keyword in self.settings['services']:
            if self.settings['services'][keyword]['enabled']:
                self.init_proxy_service(keyword)

        self.registerEvent('EVT_CLIENT_GEOLOCATION_SUCCESS', self.doProxyScan)
        self.registerEvent('EVT_CLIENT_GEOLOCATION_FAILURE', self.doProxyScan)
        self.registerEvent('EVT_CLIENT_AUTH', self.onAuth)
        self.registerEvent('EVT_PLUGIN_DISABLED', self.onPluginDisabled)
        self.registerEvent('EVT_PLUGIN_ENABLED', self.onPluginEnabled)

        # notice plugin started
        self.debug('plugin started')
    def onStartup(self):
        """
        Initialize plugin settings
        """
        # create database tables if needed
        tables = self.console.storage.getTables()
        if not 'callvote' in tables:
            if self.console.storage.dsnDict['protocol'] == 'mysql':
                self.console.storage.query(self.sql['c1'])
            else:
                self.console.storage.query(self.sql['c2'])

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        try:
            self.registerEvent(self.console.getEventID('EVT_CLIENT_CALLVOTE'), self.onCallvote)
            self.registerEvent(self.console.getEventID('EVT_VOTE_PASSED'), self.onCallvoteFinish)
            self.registerEvent(self.console.getEventID('EVT_VOTE_FAILED'), self.onCallvoteFinish)
        except TypeError:
            self.registerEvent(self.console.getEventID('EVT_CLIENT_CALLVOTE'))
            self.registerEvent(self.console.getEventID('EVT_VOTE_PASSED'))
            self.registerEvent(self.console.getEventID('EVT_VOTE_FAILED'))

        # notice plugin started
        self.debug('plugin started')
Ejemplo n.º 54
0
    def onStartup(self):
        """
        Initialize plugin settings.
        """
        # get the admin plugin
        self.adminPlugin = self.console.getPlugin('admin')

        # get the poweradminurt plugin
        self.powerAdminUrtPlugin = self.console.getPlugin('poweradminurt')

        if self._demo_record:
            self.serverSideDemoPlugin = self.console.getPlugin('urtserversidedemo')
            if not self.serverSideDemoPlugin:
                self._demo_record = False
                self.warning("automatic demo recording is enabled in configuration file but plugin 'urtserversidedemo' "
                             "has not been loaded in B3 main configuration file: automatic demo recording will be disabled")

        # register our commands
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = getCmd(self, cmd)
                if func:
                    self.adminPlugin.registerCommand(self, cmd, level, func, alias)

        for cmd in ('map', 'maps', 'pasetnextmap'):

            try:
                alias = self.adminPlugin._commands[cmd].alias
                level = '-'.join(map(str, self.adminPlugin._commands[cmd].level))
                func = getCmd(self, cmd)
                self.adminPlugin.unregisterCommand(cmd)
                self.adminPlugin.registerCommand(self, cmd, level, func, alias)
            except KeyError:
                self.debug('not overriding command (%s) : it has not been registered by any other plugin')

        # create database tables (if needed)
        current_tables = self.console.storage.getTables()
        if 'jumpruns' not in current_tables or 'jumpways' not in current_tables:
            sql_path_main = b3.getAbsolutePath('@b3/plugins/jumper/sql')
            sql_path = os.path.join(sql_path_main, self.console.storage.dsnDict['protocol'], 'jumper.sql')
            self.console.storage.queryFromFile(sql_path)

        self.registerEvent('EVT_CLIENT_JUMP_RUN_START', self.onJumpRunStart)
        self.registerEvent('EVT_CLIENT_JUMP_RUN_STOP', self.onJumpRunStop)
        self.registerEvent('EVT_CLIENT_JUMP_RUN_CANCEL', self.onJumpRunCancel)
        self.registerEvent('EVT_CLIENT_TEAM_CHANGE', self.onTeamChange)
        self.registerEvent('EVT_CLIENT_DISCONNECT', self.onDisconnect)
        self.registerEvent('EVT_GAME_MAP_CHANGE', self.onMapChange)
        self.registerEvent('EVT_PLUGIN_ENABLED', self.onPluginEnabled)
        self.registerEvent('EVT_PLUGIN_DISABLED', self.onPluginDisabled)

        # make sure to stop all the demos being recorded or the plugin
        # will go out of sync: will not be able to retrieve demos for players
        # who are already in a jumprun and being recorded
        if self._demo_record and self.serverSideDemoPlugin:
            self.serverSideDemoPlugin.stop_recording_all_players()

        # notice plugin startup
        self.debug('plugin started')
Ejemplo n.º 55
0
 def test_get_cmd(self):
     self.assertEqual(functions.getCmd(self, "foo"), self.cmd_foo)
     self.assertEqual(functions.getCmd(self, "bar"), self.cmd_bar)
     self.assertIsNone(functions.getCmd(self, "baz"))