Example #1
0
 def on_control(self, command, params, silent, **kwargs):
   extra = kwargs.get('extra', {})
   uniqueid = extra.get('uniqueid', '')
   
   if not has_access(uniqueid, 'admin'):
     return True
   
   parsed_params = shell_parse(params)
   
   # Test if there is a --force parameter. If so then ignore any exceptions.
   # Otherwise, build a list of exceptions based on the admin users.
   uniqueid_exceptions = []
   if parsed_params and parsed_params[0] == '--force':
     parsed_params = parsed_params[1:]
   else:
     # If there was no force param, then add all people who are admins or higher
     # onto the list of exceptions.
     for user in cget('users', default=[]):
       entry = cget('users', user, default={'uniqueid': None})
       if has_access(entry['uniqueid'], 'user'):
         uniqueid_exceptions.append(entry['uniqueid'])
    
   action = ''
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Kick
   if command == 'k' or command == 'kick':
     action = 'kick'
     rcon_client.kick_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions)
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Reverse kick
   elif command == 'rkick' or command == 'rk':
     action = 'rkick'
     rcon_client.rkick_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions)
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Ban
   elif command == 'b' or command == 'ban' or command == 'kb':
     action = 'ban'
     rcon_client.ban_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions)
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # Reverse ban
   elif command == 'rban' or command == 'rb' or command == 'rkb':
     action = 'rban'
     rcon_client.rban_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions)
     
   #if action:
   #  if not silent:
   #    rcon_client.hsay('', '[%s]: %s' % (action, params))
       
     # This will print out a warning as to why the action was not performed on
     # the list of players.
     #if 'exceptions' in ret and ret['exceptions']:
       #names = [rcon_client.cache['players'][uniqueid]['name'] for uniqueid in ret['exceptions']]
       #rcon_client.say('[%s]: Use --force to %s exceptions.' % (action, action))
       
   return True
     
Example #2
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

        # Keep processing other plugins.
        return True
Example #3
0
  def on_command(self, command, params, parsed_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

    if command == 'exec' and parsed_params:
      self.exec_(parsed_params[0])      

    # Keep processing other plugins.
    return True
Example #4
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

    if command == 'ip2l' and params:
      reactor.callInThread(self.display_name, params)

    # Keep processing other plugins.
    return True
Example #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

    if (command == 'exec' or command == 'execr') and params:
      self.exec_(params)
      
      if command == 'execr':
        rcon_client.cvar('sv_restart', '1')

    # Keep processing other plugins.
    return True
Example #6
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
Example #7
0
 def on_lo3(self, command, params, silent, **kwargs):
   extra = kwargs.get('extra', {})
   uniqueid = extra.get('uniqueid', '')
   
   if not has_access(uniqueid, 'admin'):
     return True
     
   if command == 'lo3':
     # Don't do lo3 if we're already doing lo3.
     if self.performing_lo3:
       return True
     self.performing_lo3 = True
   
     self.pre_lo3.send(sender=self.__class__)
     
     self.exec_(cget('plugins', 'exec', 'exec_on_lo3'))
     
     # Get the configuration options for going lo3.
     default_lo3_messages = ['[ Going live on 3 restarts ]', '[ Two more restarts ]', '[ Last restart ]']
     default_lo3_delays = ['2', '2', '5']
     lo3_messages = cget('plugins', 'exec', 'lo3_messages', default=default_lo3_messages)
     lo3_delays = cget('plugins', 'exec', 'lo3_delays', default=default_lo3_delays)
     lo3_live_message = cget('plugins', 'exec', 'lo3_live_message', default='[* LIVE LIVE LIVE *]')
      
     #==============================
     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)+0.9, do_restarts, index)
       else:
         self.performing_lo3 = False
         rcon_client.hsay('', lo3_live_message)
         self.post_lo3.send(sender=self.__class__)
       
     do_restarts(0)
Example #8
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     
    
    # No reason to do anything if we're silent.
    if silent:
      return True
    
    players = None
    
    if command == 'id':
      # If they passed params, then get the players by their names
      parsed_commands = shell_parse(params)
      if parsed_commands:
        players = rcon_client.get_players(names=parsed_commands)
      else: # Otherwise, just use all the players
        players = rcon_client.get_players()
    elif command == 'idteam' and params:
      # Get the correct team name based on what they passed.
      team = None
      if params == 'c' or params == 'ct':
        team = 'CT'
      elif params == 't':
        team = 'TERRORIST'
      # If we have a team, get the players on that team.
      if team:
        players = rcon_client.find_players('team', team)
    
    if players:
      reactor.callInThread(self.display_players, players)
    
    # Keep processing other plugins.
    return True
Example #9
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