from chatbot import ChatBot if __name__ == "__main__": # create the bot qchatbot = ChatBot(False, 'http://real-time-chat.appspot.com/', True) # navigate to the login page qchatbot.visit(qchatbot.site) # login to the site qchatbot.login('aaron', '1234') # select the friend to talk with assert qchatbot.select_friend('alice'), "Your friend is offline" # quotes to respond with quotes, index = [], 0 with open('quotes.txt', 'rb') as f: for line in f: quotes.append(line) # record the nubmer of messages num_messages = len(qchatbot.get_messages()) while True: # indicates a message was recieved, respond if num_messages != len(qchatbot.get_messages()): qchatbot.send_message(quotes[index%len(quotes)].strip()) num_messages = len(qchatbot.get_messages())
# navigate to the chat site cb1.visit(sys.argv[1] + '/login') # enter the site cb1.login(sys.argv[2], sys.argv[3]) # add a non-existent friend # cb1.add_friend('bob1') # select the current freinds list friends = cb1.get_friends_list() while not friends: friends = cb1.get_friends_list() aFriend = friends[0] # iterate through the friends list # select friend chat window cb1.select_friend(aFriend) # send a message while True: currentChatLength = len(cb1.get_messages()) #INSERT CURRENT CHAT LENGTH while currentChatLength == len(cb1.get_messages()): #INSURT CURRENT CHAT LENGTH #DONOTHIGN nothing = 3 cb1.send_message('qwerqwerwrreqr') cb1.logout() # logout
if __name__ == '__main__': # create a chatbot instance site = 'localhost:8080' cb1 = ChatBot(False, site) # navigate to the chat site cb1.visit(site) # enter the site cb1.login('asdf', 'asdf') # add a non-existent friend cb1.add_friend('bob1') # select the current freinds list friends = cb1.get_friends_list() # iterate through the friends list for friend in friends: # select friend chat window cb1.select_friend(friend) # send a message for i in range(0,5): cb1.send_message('qwertyuiopasadfghjklzxcvbnm') time.sleep(.5) # logout cb1.logout()