Exemple #1
0
 def display_name(self, name):
   if not name:
     return
   
   # Just get a single player based on the name. In the future I may
   # make this thing get multiple player's location info.
   players = rcon_client.get_players(names=[name])
   print players
   if players:
     player = players.values()[0]
   else:
     return
   
   # They don't have location information. Go grab it.
   if 'country' not in player:
     if 'ip' not in player:
       print 'Error: Player has no ip.'
       return
     
     data = self.lookup_ip(player['ip'])
     
     # Save the information for later
     player.update(data)
     
   rcon_client.hsay(player['name'], '%s, %s, %s (%s)' % (player['city'], player['region'], player['country'], player['area_code']))
Exemple #2
0
 def display_info(self, info):
   """A function to display information about a player's league status in game."""
   
   if 'team_name' in info:
     league = '%(team_game)s-%(team_league)s-%(team_division)s' % info
     record = '%(wins)s-%(losses)s-%(ties)s' % info['team_record']
     rcon_client.hsay('', '%s in %s(%s, %s) | %s' % (info['player_alias'], info['team_name'], league, record, info['ingame_name']))
   else:
     rcon_client.hsay('', '%s is not in any leagues' % info['ingame_name'])
Exemple #3
0
 def do_restarts(index):
   if index < len(lo3_messages):
     message = lo3_messages[index]
     delay = lo3_delays[index]
     rcon_client.hsay('', message)
     rcon_client.command('sv_restart', delay)
     index += 1
     reactor.callLater(int(delay)+1, do_restarts, index)
   else:
     self.performing_lo3 = False
     rcon_client.hsay('', lo3_live_message)
Exemple #4
0
 def find_nick(self, nick, silent=True):
   """A helper function to try to find a nick inside our nick list.
   The nick that you pass is a regular expression."""
   
   regex = re.compile(nick, re.IGNORECASE)
   for key in self.nicks:
     if regex.match(key):
       return self.nicks[key]
   
   if not silent:
     rcon_client.hsay('', 'Did not find nick: %s' % name)
   
   return None
Exemple #5
0
 def on_command(self, command, params, silent, **kwargs):
   extra = kwargs.get('extra', {})
   uniqueid = extra.get('uniqueid', '')
   
   # We don't have access. Return.
   if not has_access(uniqueid, 'admin'):
     # Keep processing other plugins.
     return True
   
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Restart round
   if command == 'r' or command == 'rr':
     wait = params if params else '1'
     rcon_client.cvar('sv_restart', wait)
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Map
   elif command == 'map' or command == 'changelevel':
     rcon_client.changelevel(params)
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Say
   elif command == 'say':
     rcon_client.say(params)
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Hostname say
   elif command == 'hsay':
     p = params.split(' ', 1)
     if len(p) > 1:
       rcon_client.hsay(p[0], ' '.join(p[1:]))
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Password
   elif command == 'pass' or command == 'password':
     if params:
       rcon_client.cvar('sv_password', params)
       if not silent:
         rcon_client.hsay('', 'Set password to: %s' % params)
     else:
       #==============================
       def got_password(value):
         rcon_client.hsay('', 'Password is set to: %s' % value)
       rcon_client.cvar('sv_password').addCallback(got_password)
       
   
   # Keep processing other plugins.
   return True
Exemple #6
0
 def on_privmsg(self, user, channel, message, **kwargs):
   """Called when the bot receives a privmsg."""
   
   user = user.split('!', 1)[0]
   
   if self.channels and channel == irc_client.network['nickname']:
     if self.finding:      
       self.nicks[user] = user # Probably should fill with info or something.
       
       if not self.bad_message_re.match(message):
         rcon_client.hsay('irc:%s' % user, message)
     else:
       # If the user is in the ignore list, then just return. This could be
       # "Global" telling you something that we shouldn't respond to or we'll
       # enter into an infinite loop.
       user = user.lower()
       for ignore in cget('plugins', 'ircbot', 'ignore_nicks', default=[]):
         if ignore.lower() == user:
           return
         
       irc_client.msg(user, 'Sorry, I\'m no longer looking for a scrim.')
Exemple #7
0
 def on_command(self, command, params, silent, **kwargs):    
   extra = kwargs.get('extra', {})
   uniqueid = extra.get('uniqueid', '')
   
   # We don't have access. Return.
   if not has_access(uniqueid, 'admin'):
     # Keep processing other plugins.
     return True     
   
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Find
   if command == 'find':      
     # We must decode the string to interpret the escapes (e.g. '\x37' into '7').
     ad = cget('plugins', 'ircbot', 'ad').decode('string-escape')
     self.comment = params if params else cget('plugins', 'ircbot', 'default_comment', default='de_any')
     self.ad = ad.replace('{comment}', self.comment)
     
     # We're not finding, so let's start it.
     if not self.finding:
       if not silent:
         rcon_client.hsay('', 'Finding a scrim.')
       self.finding = True
       
       # Only call do_advertising if the delayed call isn't active.
       # Otherwise we would message the channel immediately and potientially
       # get kicked/banned from it for spamming.
       if not self.ad_delayed_call or not self.ad_delayed_call.active():
         self.do_advertising()
     # If we are finding, just notify the user that we changed the parameters.
     else:
       if not silent:
         rcon_client.hsay('', 'Changed parameters. Still finding.')
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Stop finding
   elif command == 'stopfind' or command == 'stopfinding' or command == 'findstop':
     if not silent:
       if self.finding:        
         rcon_client.hsay('', 'No longer finding a scrim.')
       else:
         rcon_client.hsay('', 'Not finding. Nothing to stop.')
     self.finding = False
     self.nicks = {}
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Accept
   elif command == 'accept':
     if params:
       nick = self.find_nick(params, silent)
       if nick:
         default_password = cget('game', 'default_password', default='scrim')
         new_password = '******' % (default_password, random.randint(1, 99))
         rcon_client.cvar('sv_password', new_password)
         rcon_client.hsay('', 'Giving "%s" the info. New password: %s' % (nick, new_password))
         rcon_client.hsay('', 'Don\'t forget to .stopfind when they connect.')
         # Too bad python 2.6's string formatting isn't in 2.5
         accept_message = cget('plugins', 'ircbot', 'accept_message', default='connect {host}:{port};password {password}')
         accept_message = accept_message.replace('{host}', cget('rcon', 'host'))
         accept_message = accept_message.replace('{port}', cget('rcon', 'port'))
         accept_message = accept_message.replace('{password}', new_password)
         irc_client.msg(nick, accept_message)    
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Ad
   elif command == 'ad':
     rcon_client.hsay('', 'Find ad: %s' % self.comment)
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Message
   elif command == 'msg':
     if params:
       params = params.split(' ', 1)
       if len(params) >= 2:
         nick = self.find_nick(params[0], silent)
         if nick:
           irc_client.msg(nick, params[1])
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Private message or literal message. We send the message via irc no
   # matter if we have a record of the nick or not.
   elif command == 'privmsg' or command == 'lmsg':
     if params:
       params = params.split(' ', 1)
       if len(params) >= 2:
         irc_client.msg(params[0], params[1])
         
   # Keep processing other plugins.
   return True
Exemple #8
0
 def got_password(value):
   rcon_client.hsay('', 'Password is set to: %s' % value)