Example #1
0
    def cmd_locate(self, data, client, cmd=None):
        input = self._adminPlugin.parseUserCmd(data)
        if input:
            # input[0] is the player id
            sclient = self._adminPlugin.findClientPrompt(input[0], client)
            if not sclient:
                # a player matchin the name was not found, a list of closest matches will be displayed
                # we can exit here and the user will retry with a more specific player
                return False
        else:
            client.message('^7Invalid data, try !help whereis')
            return False

        if sclient.isvar(self, 'country'):
            country = sclient.var(self, 'country').value
        else:
            # lets find the country
            try:
                ret = geoip.geo_ip_lookup(sclient.ip)
                country = translate(u'%s (%s)' %
                                    (ret['city'], ret['country_name']))
                sclient.setvar(self, 'country', country)
            except Exception, e:
                self.error(e)
                client.message('^7Unable to find client location.')
                return False
Example #2
0
 def cmd_locate(self, data, client, cmd=None):
   input = self._adminPlugin.parseUserCmd(data)
   if input:
     # input[0] is the player id
     sclient = self._adminPlugin.findClientPrompt(input[0], client)
     if not sclient:
       # a player matchin the name was not found, a list of closest matches will be displayed
       # we can exit here and the user will retry with a more specific player
       return False
   else:
     client.message('^7Invalid data, try !help whereis')
     return False
 
   if sclient.isvar(self,'country'):
     country = sclient.var(self, 'country').value    
   else:
     # lets find the country
     try:
       ret = geoip.geo_ip_lookup(sclient.ip)
       country = translate(u'%s (%s)' % (ret['city'],ret['country_name']))
       sclient.setvar(self, 'country', country)
     except Exception, e:
       self.error(e)
       client.message('^7Unable to find client location.')
       return False
Example #3
0
    def cmd_locate(self, data, client, cmd=None):
        """\
        <name> - show where the user is connected from
        """
        input = self._adminPlugin.parseUserCmd(data)
        if input:
            # input[0] is the player id
            sclient = self._adminPlugin.findClientPrompt(input[0], client)
            if not sclient:
                # a player matchin the name was not found, a list of closest matches will be displayed
                # we can exit here and the user will retry with a more specific player
                return False
        else:
            client.message('^7Invalid data, try !help whereis')
            return False

        location = self.get_client_location(sclient)
        if location:
            country = translate(self._country_format % location)
            client.message('^3%s [@%s] ^7is connected from ^3%s' %
                           (sclient.name, str(sclient.id), country))
            self.debug('[LOCATE] %s [@%s] is connected from %s' %
                       (sclient.name, str(sclient.id), country))
        else:
            client.message('^7Cannot found client location.')
            self.debug('[LOCATE] Cannot found client location.')
Example #4
0
 def broadcast(self, client):
     if client.connected:
         if self._broadcast and self.get_client_location(client):
             info = {
                 'name'  : client.exactName,
                 'country'  : translate(self._country_format % self.get_client_location(client)),
             }
             self.debug('Connected %s from %s' % (client.ip,info['country']))
             self.debug('Broadcasting location')
             if self.console.gameName.startswith('cod'):
                 self.console.say(self.getMessage('broadcast', info))
             else:
                 self.console.write(self.getMessage('broadcast', info))
         else:
             self.debug('Broadcasting disable or client doesn\'t have location data')
     else:
         self.debug('Broadcasting location')
Example #5
0
 def broadcast(self, client):
     if client.connected:
         if self._broadcast and self.get_client_location(client):
             info = {
                 'name':
                 client.exactName,
                 'country':
                 translate(self._country_format %
                           self.get_client_location(client)),
             }
             self.debug('Connected %s from %s' %
                        (client.ip, info['country']))
             self.debug('Broadcasting location')
             if self.console.gameName.startswith('cod'):
                 self.console.say(self.getMessage('broadcast', info))
             else:
                 self.console.write(self.getMessage('broadcast', info))
         else:
             self.debug(
                 'Broadcasting disable or client doesn\'t have location data'
             )
     else:
         self.debug('Broadcasting location')
Example #6
0
 def cmd_locate(self, data, client, cmd=None):
     """\
     <name> - show where the user is connected from
     """
     input = self._adminPlugin.parseUserCmd(data)
     if input:
         # input[0] is the player id
         sclient = self._adminPlugin.findClientPrompt(input[0], client)
         if not sclient:
         # a player matchin the name was not found, a list of closest matches will be displayed
         # we can exit here and the user will retry with a more specific player
             return False
     else:
         client.message('^7Invalid data, try !help whereis')
         return False
   
     location = self.get_client_location(sclient)
     if location:
         country = translate(self._country_format % location)
         client.message('^3%s [@%s] ^7is connected from ^3%s' % (sclient.name,str(sclient.id),country)) 
         self.debug('[LOCATE] %s [@%s] is connected from %s' % (sclient.name,str(sclient.id),country))
     else:
         client.message('^7Cannot found client location.')
         self.debug('[LOCATE] Cannot found client location.')
    def cmd_ultrauserinfo(self, data, client=None, cmd=None):
        """\
        <name> - display player's ultra information.
        """

        if not self.console.storage.status():
            cmd.sayLoudOrPM(client, '^7Cannot lookup, database apears to be ^1DOWN')
            return False		
        input = self._adminPlugin.parseUserCmd(data)
        input = data.split(' ',1)
        if not input:
            client.message('^7correct syntax is ^2!ultrauserinfo ^7<name>')
            return False
        
        cid = input[0]
        sclient = self._adminPlugin.findClientPrompt(cid, client)
        if not sclient:
            client.message('^7correct syntax is ^2!ultrauserinfo ^7<name>')
            return

        self._country_format = '^1%(city)s ^7[^3%(country_name)s^7]'
        bans = self.get_all_player_bans(sclient)
        location = self.get_client_location(sclient)
        clients = self.console.clients.getClientsByLevel()
        cursor = self.console.storage.query(self._SELECT_QUERY % sclient.id)
        if location:
            country = translate(self._country_format % location)
            cmd.sayLoudOrPM(client, self.getMessage('general_info', sclient.cid, sclient.exactName, sclient.id, sclient.maxGroup.name, sclient.maxLevel, sclient.connections, sclient.ip, country))
        else:
            cmd.sayLoudOrPM(client, '^7%s: %s^7 [^2@%s^7] is a  ^2%s^7 [^1%s^7], connected: ^6%s ^7times. ^4%s ^7from: %s' % (sclient.cid, sclient.exactName, sclient.id, sclient.maxGroup.name, sclient.maxLevel, sclient.connections, sclient.ip))
    
        if sclient not in clients:
            cmd.sayLoudOrPM(client, 'Last seen: %s' % self.console.formatTime(sclient.timeEdit))

        if cursor.rowcount > 0:
            r = cursor.getRow()
            admin = self._adminPlugin.findClientPrompt("@%s" % r['admin_id'], client)
            if admin:
                admin_name = admin.name
            else:
                admin_name = 'B3'
            if r['reason'] and r['reason'] != '' and r['reason'] != 'None':
                reason = r['reason']
            else:
                reason = self._DEFAULT_REASON
            cmd.sayLoudOrPM(client, self.getMessage('watchlist_info', admin_name, reason))
        else:
            cmd.sayLoudOrPM(client, "")

        if sclient:
            warns = sclient.numWarnings
            myaliases = []
            for a in sclient.aliases:
                myaliases.append('%s' % a.alias)
                if len(myaliases) > 4:
                    myaliases.append('^7[^2more^7]')
                    break

            if len(myaliases):
                cmd.sayLoudOrPM(client, "^3Aliases^7: %s" % (', '.join(myaliases)))
            else:
                cmd.sayLoudOrPM(client, '')
 
            if warns:
                msg = ''
                warn = sclient.firstWarning
                if warn:
                    expire = functions.minutesStr((warn.timeExpire - (self.console.time())) / 60)
                    msg = '^7. expires in ^5%s' % expire
                warn = sclient.lastWarning
                if warn:
                    msg += '^7: ^3%s' % warn.reason
                message = '^1Warnings^7: ^4%s %s' % (warns, msg)
            else:
                message = ''
                
            cmd.sayLoudOrPM(client, message)

        if len(bans) == 0:
            return True

        cmd.sayLoudOrPM(client, "^1Past Bans^7: ^4%s"  % len(bans))
        for b in bans:
            cmd.sayLoudOrPM(client,  b)
Example #8
0
    def welcome(self, client):
        _timeDiff = 0
        if client.lastVisit:
            self.debug('LastVisit: %s' %
                       (self.console.formatTime(client.lastVisit)))
            _timeDiff = self.console.time() - client.lastVisit
        else:
            self.debug('LastVisit not available. Must be the first time.')
            _timeDiff = 1000000  # big enough so it will welcome new players

        # don't need to welcome people who got kicked or where already welcomed in the last hour
        if client.connected and _timeDiff > 3600:
            info = {
                'name': client.exactName,
                'id': str(client.id),
                'connections': str(client.connections)
            }

            if client.maskedGroup:
                info['group'] = client.maskedGroup.name
                info['level'] = str(client.maskedGroup.level)
            else:
                info['group'] = 'None'
                info['level'] = '0'

            if client.connections >= 2:
                info['lastVisit'] = self.console.formatTime(client.lastVisit)
            else:
                info['lastVisit'] = 'Unknown'

            if self.get_client_location(client):
                info['country'] = translate(self._country_format %
                                            self.get_client_location(client))

            if client.connections >= 2:
                self.debug('Newb welcome')
                if client.maskedGroup:
                    if self._welcomeFlags & 16:
                        client.message(self.getMessage('user', info))
                elif self._welcomeFlags & 1:
                    client.message(self.getMessage('newb', info))

                if self._welcomeFlags & 2 and client.connections < self._newbConnections:
                    if info.has_key('country'):
                        self.console.say(
                            self.getMessage('announce_user_geo', info))
                    else:
                        self.console.say(self.getMessage(
                            'announce_user', info))
            else:
                self.debug('User welcome')
                if self._welcomeFlags & 4:
                    client.message(self.getMessage('first', info))
                if self._welcomeFlags & 8:
                    if info.has_key('country'):
                        self.console.say(
                            self.getMessage('announce_first_geo', info))
                    else:
                        self.console.say(
                            self.getMessage('announce_first', info))

            if self._welcomeFlags & 32 and client.greeting:
                info['greeting'] = client.greeting % info
                self.console.say(self.getMessage('greeting', info))

        else:
            if _timeDiff <= 3600:
                self.debug('Client already welcomed in the past hour')
Example #9
0
    def welcome(self, client):
        _timeDiff = 0
        if client.lastVisit:
            self.debug('LastVisit: %s' %(self.console.formatTime(client.lastVisit)))
            _timeDiff = self.console.time() - client.lastVisit
        else:
            self.debug('LastVisit not available. Must be the first time.')
            _timeDiff = 1000000 # big enough so it will welcome new players

        # don't need to welcome people who got kicked or where already welcomed in the last hour
        if client.connected and _timeDiff > 3600:
            info = {
                'name'    : client.exactName,
                'id'    : str(client.id),
                'connections' : str(client.connections)
            }

            if client.maskedGroup:
                info['group'] = client.maskedGroup.name
                info['level'] = str(client.maskedGroup.level)
            else:
                info['group'] = 'None'
                info['level'] = '0'

            if client.connections >= 2:
                info['lastVisit'] = self.console.formatTime(client.lastVisit)
            else:
                info['lastVisit'] = 'Unknown'

            if self.get_client_location(client):
                info['country'] = translate(self._country_format % self.get_client_location(client))
            
            if client.connections >= 2:
                self.debug('Newb welcome')
                if client.maskedGroup:
                    if self._welcomeFlags & 16:
                        client.message(self.getMessage('user', info))
                elif self._welcomeFlags & 1:
                        client.message(self.getMessage('newb', info))

                if self._welcomeFlags & 2 and client.connections < self._newbConnections:
                    if info.has_key('country'):
                        self.console.say(self.getMessage('announce_user_geo', info))
                    else:
                        self.console.say(self.getMessage('announce_user', info))
            else:
                self.debug('User welcome')
                if self._welcomeFlags & 4:
                    client.message(self.getMessage('first', info))
                if self._welcomeFlags & 8:
                    if info.has_key('country'):
                        self.console.say(self.getMessage('announce_first_geo', info))
                    else:
                        self.console.say(self.getMessage('announce_first', info))
                        
            if self._welcomeFlags & 32 and client.greeting:
                info['greeting'] = client.greeting % info
                self.console.say(self.getMessage('greeting', info))
            
        else:
            if _timeDiff <= 3600:
                self.debug('Client already welcomed in the past hour')