Advertisement
Guest User

Untitled

a guest
May 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.04 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import random
  4. from Credentials import botowner, botname, botpassword
  5. from SubspaceBot import *
  6.  
  7. TYPE_RULES1 = 1
  8. TYPE_RULES2 = 2
  9. TYPE_RULES3 = 3
  10. TYPE_CAP = 4
  11. TYPE_ROLL = 5
  12. random_number = random.randrange(1, 999)
  13. Caps = 0
  14. Captains = []
  15. started = 0
  16. capfound = False
  17.  
  18. if __name__ == '__main__':
  19.     bot = SubspaceBot(botowner, 'Siege event bot')
  20.     bot.connectToServer('66.235.184.102', 7900, botname, botpassword, '#python')
  21.    
  22.     print "Bot connected to server"
  23.     msg_command_id = bot.registerCommand('!msg', 'Arena Message', allowed_players=['American','Dbz'])
  24.     lock_command_id = bot.registerCommand('!lock', 'Locks Arena', allowed_players=['American','Dbz'])
  25.     start_command_id = bot.registerCommand('!start', 'Starts Event', allowed_players=['American','Dbz'])
  26.    
  27.     while bot.isConnected():
  28.         event = bot.waitForEvent()
  29.  
  30.         if event.type == EVENT_COMMAND:
  31.             if event.command.id == msg_command_id:
  32.                 bot.sendArenaMessage(event.arguments_after[0] + ' - ' + event.player.name)
  33.             elif event.command.id == lock_command_id:
  34.                 bot.sendPublicMessage('*lock')
  35.                 bot.sendPrivateMessage(event.player.name, ' Un/locked' )
  36.             elif event.command.id == start_command_id:
  37.                 bot.sendArenaMessage('Welcome to Siege!')
  38.                 timers = []
  39.                 bot.setTimer(1, user_data = TYPE_RULES1)
  40.                 ##timers.append(bot.setTimer(5, TYPE_RULES1))
  41.                 ##timers.append(bot.setTimer(5 * 2, TYPE_RULES2))
  42.                 ##timers.append(bot.setTimer(5 * 3, TYPE_RULES3))
  43.                 started = 1
  44.         elif event.type == EVENT_TIMER:
  45.             if event.user_data == 1:
  46.                 bot.sendArenaMessage('[Rules] go here.')
  47.                 bot.setTimer(2, user_data = TYPE_RULES2)
  48.             elif event.user_data == 2:
  49.                 bot.sendArenaMessage('[Rules] MORE RULES  :D.')
  50.                 bot.setTimer(3, user_data = TYPE_RULES3)
  51.             elif event.user_data == 3:
  52.                 bot.sendArenaMessage('[Rules] THE LAST RULES :D.')
  53.                 bot.setTimer(5, user_data = TYPE_CAP)
  54.             elif event.user_data == 4:
  55.                 bot.sendArenaMessage('We will be typing random numbers for captains')
  56.                 bot.setTimer(5, user_data = TYPE_ROLL)
  57.             elif event.user_data == 5:
  58.                 capfound = False
  59.                 random_number = random.randrange(1, 999)
  60.                 bot.sendArenaMessage('[Random] Type: ' + str(random_number) + ' Now!')
  61.                 bot.setTimer(10)
  62.             else:
  63.                 if not capfound:
  64.                     bot.setTimer(5, user_data = TYPE_ROLL)
  65.                
  66.                    
  67.                    
  68.         elif event.type == EVENT_MESSAGE:
  69.             if event.message_type in [MESSAGE_TYPE_PUBLIC,MESSAGE_TYPE_PRIVATE,MESSAGE_TYPE_FREQ,MESSAGE_TYPE_TEAM]:
  70.                 if event.message.lower() == str(random_number):
  71.                     __cap__ = event.player.name
  72.                     if __cap__ in Captains:
  73.                         bot.sendArenaMessage(event.player.name + ' is already a captain, rolling again.')
  74.                     else:
  75.                         cfreq = (len(Captains) + 1) * 100
  76.                         Captains.append(event.player.name)
  77.                         bot.sendPrivateMessage(event.player.name, '*setship 8')
  78.                         bot.sendArenaMessage(event.player.name + ' is the new Captain for freq ' + str(cfreq))
  79.                         Caps = Caps + 1
  80.                         capfound = True
  81.                         if Caps < 4 and started:
  82.                             bot.setTimer(1, user_data = TYPE_ROLL)
  83.  
  84.     print "Bot disconnected"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement