Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import selenium.common.exceptions
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from selenium import webdriver #Import the webdriver
- from selenium.webdriver.common.keys import Keys #Import the ability to input keys (I think)
- import time #Import time (useless I think but shhh)
- import datetime #Import the datetime (Actual module (That comes with python) used for time command, do not delete)
- from cleverbot import Cleverbot
- import os
- #Open firefox browser (Change for ie)
- browser = webdriver.Firefox()
- #GO to band page
- browser.get('https://auth.band.us/email_login?keep_login=false ')
- #Find the text box id's for username and password
- username = browser.find_element_by_id("input_email")
- password = browser.find_element_by_id("input_password")
- #Input username and password
- username.send_keys("USERNAME")
- password.send_keys("Password")
- #Enter the username and password
- password.send_keys(Keys.ENTER)
- #Second log in attempt, I really dont need to re explain what it does.
- browser.get('https://auth.band.us/email_login?keep_login=false ')
- username = browser.find_element_by_id("input_email")
- password = browser.find_element_by_id("input_password")
- username.send_keys("USERNAME")
- password.send_keys("PASSWORD")
- password.send_keys(Keys.ENTER)
- time.sleep(2)
- #GO to cloak Out of character chat chat
- browser.get('http://band.us/chat/chattingRoom?channelID=CAd3ok&bandNo=62973656')
- #Wait for chat load
- time.sleep(5)
- #Find the message box element
- chat = browser.find_element_by_id("write_comment_view20")
- #Starting message
- #chat.send_keys("Father O'Mally O'Connel O'Ciero O'Riley O'Brian O'Sullivan has been activated")
- #Press enter
- chat.send_keys(Keys.ENTER)
- #Create the variable used to count messages
- browser.refresh()
- time.sleep(10)
- cb = Cleverbot()
- count = 0
- msgold = 0
- chat_thing = 1
- chat = browser.find_element_by_id("write_comment_view20")
- def anrp_chat_on():
- time.sleep(7)
- newcount = 0
- for element in reversed(browser.find_elements_by_class_name("txt")):
- newcount +=1
- if newcount == 2:
- newcount = 0
- break
- chat_thing = element.text
- cbAnswer = cb.ask(chat_thing)
- chat = browser.find_element_by_id("write_comment_view20")
- chat.send_keys(cbAnswer)
- chat.send_keys(Keys.ENTER)
- def anrp_chat_offline():
- cbAnswer = None
- #Main brunt of the code, this will constantly check for messages
- while True:
- try:
- for element in reversed(browser.find_elements_by_class_name("txt")):
- count +=1
- if count == 3:
- chat_thing = str(element.text)
- #If the new message isn't a repeat it will display the newest message and the previous, non-repeat message
- if chat_thing != msgold:
- print (chat_thing)
- print ("New message")
- print (msgold)
- print ("This is the old message")
- msgold = chat_thing
- if chat_thing == "!spam":
- while True:
- chat = browser.find_element_by_id("write_comment_view20")
- chat.send_keys("I AM A SPAM BOT, SPAMMING CHATS, SPAMMY SPAMMY SPAAAM!")
- chat.send_keys(Keys.ENTER)
- chat.send_keys(Keys.ENTER)
- #Help command
- if chat_thing == "!help":
- chat = browser.find_element_by_id("write_comment_view20")
- chat.send_keys("Father O'Mally O'Connel O'Ciero O'Riley O'Brian O'Sullivan here, I have some interesting things to tell")
- chat.send_keys(Keys.ENTER)
- chat.send_keys("I can assist you using these commands, all commands must be prefixed with !")
- chat.send_keys(Keys.ENTER)
- chat.send_keys("help, time")
- chat.send_keys(Keys.ENTER)
- #!Time command
- if chat_thing == "!time":
- chat = browser.find_element_by_id("write_comment_view20")
- now = datetime.datetime.now()
- hour = str(now.hour)
- minute = str(now.minute)
- second = str(now.second)
- chat.send_keys("Calculating time")
- chat.send_keys(Keys.ENTER)
- chat.send_keys(hour, ":", minute, ":", second)
- chat.send_keys(Keys.ENTER)
- if chat_thing == "anrp_on":
- while True:
- anrp_chat_on()
- if chat_thing == "anrp_off":
- anrp_chat_off()
- count = 0
- break
- except selenium.common.exceptions.StaleElementReferenceException:
- print("Stale dom")
- """#Refresh the browser, what do you think it was going to do?
- browser.refresh()
- #More waiting, this is what slows down my code
- time.sleep(7)
- for element in reversed(browser.find_elements_by_class_name("txt")):
- count +=1
- if count == 2:
- count = 0
- break
- print(element.text)
- chat_thing = element.text"""
- """
- #this gathers the text without refreshing all the time lol (Zeke code)
- for element in reversed(browser.find_elements_by_class_name("txt")):
- count +=1
- if count == 3:
- count = 0
- break
- print(element.text)
- chat_thing = element.text
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement