The_insane_Scientist

Untitled

Nov 15th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. from selenium import webdriver #Import the webdriver
  2. from selenium.webdriver.common.keys import Keys #Import the ability to input keys (I think)
  3. import time #Import time (useless I think but shhh)
  4. import datetime #Import the datetime (Actual module (That comes with python) used for time command, do not delete)
  5. from cleverbot import Cleverbot
  6. import os
  7. #Open firefox browser (Change for ie)
  8. browser = webdriver.Firefox()
  9. #GO to band page
  10. browser.get('https://auth.band.us/email_login?keep_login=false ')
  11. #Find the text box id's for username and password
  12. username = browser.find_element_by_id("input_email")
  13. password = browser.find_element_by_id("input_password")
  14. #Input username and password
  15. username.send_keys("USERNAME")
  16. password.send_keys("PASSWORD")
  17. #Enter the username and password
  18. password.send_keys(Keys.ENTER)
  19.  
  20. #Second log in attempt, I really dont need to re explain what it does.
  21. browser.get('https://auth.band.us/email_login?keep_login=false ')
  22. username = browser.find_element_by_id("input_email")
  23. password = browser.find_element_by_id("input_password")
  24. username.send_keys("USERNAME")
  25. password.send_keys("PASSWORD")
  26. password.send_keys(Keys.ENTER)
  27. time.sleep(2)
  28. #GO to cloak Out of character chat chat
  29. browser.get('http://band.us/chat/chattingRoom?channelID=CAd3ok&bandNo=62973656')
  30. #Wait for chat load
  31. time.sleep(5)
  32. #Find the message box element
  33. chat = browser.find_element_by_id("write_comment_view20")
  34. #Starting message
  35. #chat.send_keys("Father O'Mally O'Connel O'Ciero O'Riley O'Brian O'Sullivan has been activated")
  36. #Press enter
  37. chat.send_keys(Keys.ENTER)
  38. #Create the variable used to count messages
  39. cb = Cleverbot()
  40. count = 0
  41. msgold = 0
  42. chat_thing = 1
  43. chat = browser.find_element_by_id("write_comment_view20")
  44. def anrp_chat_on():
  45. time.sleep(7)
  46. newcount = 0
  47. for element in reversed(browser.find_elements_by_class_name("txt")):
  48. newcount +=1
  49. if newcount == 2:
  50. newcount = 0
  51. break
  52. chat_thing = element.text
  53. cbAnswer = cb.ask(chat_thing)
  54. chat = browser.find_element_by_id("write_comment_view20")
  55. chat.send_keys(cbAnswer)
  56. chat.send_keys(Keys.ENTER)
  57. def anrp_chat_offline():
  58. cbAnswer = None
  59.  
  60. #Main brunt of the code, this will constantly check for messages
  61. while True:
  62. for element in reversed(browser.find_elements_by_class_name("txt")):
  63. count +=1
  64. if count == 3:
  65. chat_thing = str(element.text)
  66. #If the new message isn't a repeat it will display the newest message and the previous, non-repeat message
  67. if chat_thing != msgold:
  68. print (chat_thing)
  69. print ("New message")
  70. print (msgold)
  71. print ("This is the old message")
  72. msgold = chat_thing
  73. if chat_thing == "!spam":
  74. while True:
  75. chat = browser.find_element_by_id("write_comment_view20")
  76. chat.send_keys("I AM A SPAM BOT, SPAMMING CHATS, SPAMMY SPAMMY SPAAAM!")
  77. chat.send_keys(Keys.ENTER)
  78. chat.send_keys(Keys.ENTER)
  79. #Help command
  80. if chat_thing == "!help":
  81. chat = browser.find_element_by_id("write_comment_view20")
  82. chat.send_keys("Father O'Mally O'Connel O'Ciero O'Riley O'Brian O'Sullivan here, I have some interesting things to tell")
  83. chat.send_keys(Keys.ENTER)
  84. chat.send_keys("I can assist you using these commands, all commands must be prefixed with !")
  85. chat.send_keys(Keys.ENTER)
  86. chat.send_keys("help, time")
  87. chat.send_keys(Keys.ENTER)
  88. #!Time command
  89. if chat_thing == "!time":
  90. chat = browser.find_element_by_id("write_comment_view20")
  91. now = datetime.datetime.now()
  92. hour = str(now.hour)
  93. minute = str(now.minute)
  94. second = str(now.second)
  95. chat.send_keys("Calculating time")
  96. chat.send_keys(Keys.ENTER)
  97. chat.send_keys(hour, ":", minute, ":", second)
  98. chat.send_keys(Keys.ENTER)
  99. if chat_thing == "anrp_on":
  100. while True:
  101. anrp_chat_on()
  102. if chat_thing == "anrp_off":
  103. anrp_chat_off()
  104. count = 0
  105. break
  106.  
  107. """#Refresh the browser, what do you think it was going to do?
  108. browser.refresh()
  109. #More waiting, this is what slows down my code
  110. time.sleep(7)
  111. for element in reversed(browser.find_elements_by_class_name("txt")):
  112. count +=1
  113. if count == 2:
  114. count = 0
  115. break
  116. print(element.text)
  117. chat_thing = element.text"""
  118.  
  119. """
  120. #this gathers the text without refreshing all the time lol (Zeke code)
  121. for element in reversed(browser.find_elements_by_class_name("txt")):
  122. count +=1
  123. if count == 3:
  124. count = 0
  125. break
  126. print(element.text)
  127. chat_thing = element.text
  128. """
Add Comment
Please, Sign In to add comment