Example #1
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 #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
   
   # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   # 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 #3
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