run.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/python
  2. import plaudereckenbot
  3. import time
  4. IP = ""
  5. PORT = 10011
  6. USERNAME = "serveradmin"
  7. PASSWORD = ""
  8. DISPLAYNAME = "Plauderecken-Bot"
  9. SID = 1
  10. ORIGINALCHANNELS = [151, 152, 153]
  11. CHANNELLIST = [151, 152, 153] # == ORIGINALCHANNELS
  12. CPID = 54
  13. pBot = plaudereckenbot.pBot(IP, PORT, USERNAME, PASSWORD, DISPLAYNAME,
  14. SID, CHANNELLIST, CPID)
  15. while 1:
  16. emptyRooms = 0
  17. pBot.getUserInfo()
  18. channelUserCount = list()
  19. print "userInfo: " + str(pBot.userInfoArray)
  20. for i in range(len(pBot.channellist)):
  21. channelUserCount.append(pBot.getChannelUsers(pBot.channellist[i]))
  22. for i in range(len(channelUserCount)):
  23. if(channelUserCount[i] > 0):
  24. channelUserCount[i] = True
  25. else:
  26. emptyRooms = emptyRooms + 1
  27. print "ChanUserCount: " + str(channelUserCount)
  28. print "lenSetUserCount: " + str(len(set(channelUserCount)) == 1
  29. and channelUserCount[0] == True)
  30. if len(set(channelUserCount)) == 1 and channelUserCount[0] == True:
  31. pBot.addChannel()
  32. print "emptyRooms: " + str(emptyRooms)
  33. if emptyRooms > 1:
  34. for i in reversed(range(len(pBot.channellist))):
  35. if channelUserCount[i] == 0:
  36. if pBot.channellist[i] not in ORIGINALCHANNELS:
  37. pBot.delChannel(pBot.channellist[i])
  38. break
  39. time.sleep(5)