run.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/python
  2. import plaudereckenbot
  3. import time
  4. # IP of the TS3 server
  5. IP = ""
  6. # Query port of the TS3 server
  7. PORT = 10011
  8. # Username for the query
  9. USERNAME = "serveradmin"
  10. # Password for the user specified above
  11. PASSWORD = ""
  12. # Displayname. Name visibible to the users
  13. DISPLAYNAME = "Plauderecken-Bot"
  14. # The ID of the virtual server to run on
  15. SID = 1
  16. # Which channels should be treated as the original channels
  17. CHANNELLIST = [151, 152, 153]
  18. # Channel ID of the parent channel. Created channels are children of this
  19. CPID = 54
  20. #########################################################################
  21. pBot = plaudereckenbot.pBot(IP, PORT, USERNAME, PASSWORD, DISPLAYNAME,
  22. SID, CHANNELLIST, CPID)
  23. while 1:
  24. emptyRooms = 0
  25. pBot.getUserInfo()
  26. channelUserCount = list()
  27. print "userInfo: " + str(pBot.userInfoArray)
  28. for i in range(len(pBot.channellist)):
  29. channelUserCount.append(pBot.getChannelUsers(pBot.channellist[i]))
  30. for i in range(len(channelUserCount)):
  31. if(channelUserCount[i] > 0):
  32. channelUserCount[i] = True
  33. else:
  34. emptyRooms = emptyRooms + 1
  35. print "ChanUserCount: " + str(channelUserCount)
  36. print "lenSetUserCount: " + str(len(set(channelUserCount)) == 1
  37. and channelUserCount[0] == True)
  38. if len(set(channelUserCount)) == 1 and channelUserCount[0] == True:
  39. pBot.addChannel()
  40. print "emptyRooms: " + str(emptyRooms)
  41. if emptyRooms > 1:
  42. for i in reversed(range(len(pBot.channellist))):
  43. if channelUserCount[i] == 0:
  44. if pBot.channellist[i] not in ORIGINALCHANNELS:
  45. pBot.delChannel(pBot.channellist[i])
  46. break
  47. time.sleep(5)