def test_extract_sentiment(): print("Testing extract_sentiment() functionality...") chatbot = Chatbot(False) if assertEquals( chatbot.extract_sentiment("I like \"Titanic (1997)\"."), 1, "Incorrect output for extract_sentiment(\'I like \"Titanic (1997)\".\')" ) and assertEquals( chatbot.extract_sentiment("I saw \"Titanic (1997)\"."), 0, "Incorrect output for extract_sentiment(\'I saw \"Titanic (1997)\".\')" ) and assertEquals( chatbot.extract_sentiment("I didn't enjoy \"Titanic (1997)\"."), -1, "Incorrect output for extract_sentiment(\'I didn't enjoy \"Titanic (1997)\"\'.)" ) and assertEquals( chatbot.extract_sentiment("I saw \"Titanic (1997)\"."), 0, "Incorrect output for extract_sentiment(\'I saw \"Titanic (1997)\"\'.)" ) and assertEquals( chatbot.extract_sentiment( " \"Titanic (1997)\" started out terrible, but the ending was totally great and I loved it!" ), 1, "Incorrect output for extract_sentiment(\" \"Titanic (1997)\" started out terrible, but the ending was totally great and I loved it!\'.\")" ) and assertEquals( chatbot.extract_sentiment( "I loved \"10 Things I Hate About You\""), 1, "Incorrect output for extract_sentiment(\'I loved \"10 Things I Hate About You\"\')" ) and assertEquals( chatbot.extract_sentiment( "I saw \"The Notebook\" and it was great!"), 1, "Incorrect output for extract_sentiment(\'I saw \"The Notebook\" and it was great!\')" ): print('extract_sentiment() sanity check passed!') print()
def test_find_movies_by_title(): print("Testing find_movies_by_title() functionality...") chatbot = Chatbot(False) if assertListEquals( chatbot.find_movies_by_title("The American President"), [ 10 ], "Incorrect output for find_movies_by_title('The American President')." ) and assertListEquals( chatbot.find_movies_by_title("An American in Paris (1951)"), [ 721 ], "Incorrect output for find_movies_by_title('An American in Paris (1951)')." ) and assertListEquals( chatbot.find_movies_by_title("Titanic"), [1359, 2716], "Incorrect output for find_movies_by_title('Titanic').", orderMatters=False ) and assertListEquals( chatbot.find_movies_by_title("The Notebook"), [5448], "Incorrect output for find_movies_by_title('The Notebook')." ) and assertListEquals( chatbot.find_movies_by_title("Titanic (1997)"), [1359], "Incorrect output for find_movies_by_title('Titanic (1997)').", ) and assertListEquals( chatbot.find_movies_by_title("There is no title here!"), [], "Incorrect output for find_movies_by_title('There is no title here!')." ): print('find_movies_by_title() sanity check passed!') print()
def test(): dataset = CornellMovieDialogs(data_directory="data/", vocabulary_size=20000) if not os.path.exists("data/cleaned"): dataset.make_conversations() else: dataset.load() bot = Chatbot(sequence_length=20, hidden_size=256, vocabulary_size=dataset.vocabulary_size) bot.load("models/checkpoints/checkpoint.h5") while True: print(">>>", end="") sentence = raw_input() sentence = dataset.clean(sentence) sentence = dataset.encode_sequence(sentence) sentence = sequence.pad_sequences([sentence], maxlen=bot.sequence_length) for t in [.7, .8, .9]: response = bot.respond(sentence, temperature=t) print(response) response = dataset.decode_sequence(response) start_index = response.index( "START") + 1 if "START" in response else 0 end_index = response.index("END") if "END" in response else len( response) response = response[start_index:end_index] print(" ".join(response))
def main(args): # Configure Logger level = 'NOTSET' if args.verbose: level = 'DEBUG' logger = get_logger(name="main", level=level) logger.info("Starting Tissegram") # Get Config logger.info("Get Config") config = configparser.ConfigParser() config.read(args.conf) logger.info("Init database module") db = DataBase(ip=config['Database']['ip'], port=config['Database']['port'], database=config['Database']['database'], username=config['Database']['username'], password=config['Database']['password']) logger.info("Init transport module") transport = PublicTransport(token=config['Tisseo']['token']) logger.info("Init bot module") bot = Chatbot(token=config['Telegram']['token'], webhook_ip=config['Telegram']['webhook'], db=db, transport=transport) logger.info("Start thread") threading.Thread(target=bot.run, kwargs=dict(host='localhost', port=5001)).start()
def test_chatbot(self): bot = Chatbot() for test_case in self.chatbot_funtranslate_test: with mock.patch('requests.get', self.mocked_funtranslate_get): bot_response = bot.translate(test_case[KEY_INPUT]) self.assertEqual(test_case[KEY_EXPECTED], bot_response) for test_case in self.chatbot_joke_test: with mock.patch('requests.get', self.mocked_joke_get): bot_response = bot.joke() self.assertEqual(test_case[KEY_EXPECTED], bot_response) for test_case in self.chatbot_randcase_test: with mock.patch('chatbot.choice', self.mocked_random_choice): bot_response = bot.randcase(test_case[KEY_INPUT]) self.assertEqual(test_case[KEY_EXPECTED], bot_response) for test_case in self.chatbot_translate_from_process_test: with mock.patch('requests.get', self.mocked_funtranslate_get): bot_response = bot.process(test_case[KEY_INPUT]) self.assertEqual(test_case[KEY_EXPECTED], bot_response) for test_case in self.create_message_test: model = Message(test_case[KEY_INPUT]['username'], test_case[KEY_INPUT]['userimage'], test_case[KEY_INPUT]['userkey'], test_case[KEY_INPUT]['message'])
def test_find_movies_closest_to_title(): print("Testing find_movies_closest_to_title() functionality...") chatbot = Chatbot(True) misspelled = "Sleeping Beaty" if assertListEquals( chatbot.find_movies_closest_to_title(misspelled, max_distance=3), [1656], "Incorrect output for test_find_movies_closest_to_title('{}', max_distance={})" .format(misspelled, 3), orderMatters=False ) and assertListEquals( chatbot.find_movies_closest_to_title( "Te", max_distance=3), [8082, 4511, 1664], "Incorrect output for test_find_movies_closest_to_title('{}', max_distance={})" .format("Te", 3), orderMatters=False ) and assertListEquals( chatbot.find_movies_closest_to_title("BAT-MAAAN", max_distance=3), [524, 5743], "Incorrect output for test_find_movies_closest_to_title('{}', max_distance={})" .format("BAT-MAAAN", 3), orderMatters=False ) and assertListEquals( chatbot.find_movies_closest_to_title("Blargdeblargh", max_distance=4), [], "Incorrect output for test_find_movies_closest_to_title('{}', max_distance={})" .format("Blargdeblargh", 4), orderMatters=False): print('find_movies_closest_to_title() sanity check passed!') print() return True
def test_disambiguate(): print("Testing disambiguate() functionality...") chatbot = Chatbot(True) # clarification = "2" # candidates = [3812, 4325, 5399, 6294, 6735, 7274, 7670, 7842] # if assertListEquals( # chatbot.disambiguate(clarification, candidates), # [4325], # "Incorrect output for disambiguate('{}', {})".format(clarification, candidates), # orderMatters=False # ): # clarification = "Sorcerer's Stone" # candidates = [3812, 4325, 5399, 6294, 6735, 7274, 7670, 7842] # if assertListEquals( # chatbot.disambiguate(clarification, candidates), # [3812], # "Incorrect output for disambiguate('{}', {})".format(clarification, candidates), # orderMatters=False # ): clarification = "1997" candidates = [1359, 2716] if assertListEquals( chatbot.disambiguate(clarification, candidates), [1359], "Incorrect output for disambiguate('{}', {})".format(clarification, candidates), orderMatters=False ): print('disambiguate() sanity check passed!') print() return True
def index(): chatbot_label = "Hallo. Worüber wollen Sie sprechen?" # Listen zufallsantworten = [ "Oh wirklich...", "Interessant", "Das kann man so sehen.", "Ich verstehe..." ] reaktionen = { "hallo": "aber hallo", "geht": "Was verstehst Du darunter", "schmeckt": "Ich habe keinen Geschmackssinn" } if request.method == 'POST': chatbot_input = request.form['chatbot_input'] if not chatbot_input: flash('Ohne Frage kann ich nicht antworten!') else: bot = Chatbot(reaktionen, zufallsantworten) bot.set_Message(chatbot_input) chatbot_label = bot.get_response() return render_template('chatbot.html', chatbot_label=chatbot_label)
class Assistente(Screen): bot = Chatbot('Pedro') def mensagem(self,msg,*args): self.ids.box.add_widget(Mensagem(text=msg)) frase = self.bot.escuta(frase=msg) self.resp = self.bot.pensa(frase) self.bot.fala(self.resp) self.respWidget = Mensagem(text='Typing...') self.ids.box.add_widget(self.respWidget) self.ids.texto.text = '' Clock.schedule_once(self.responder,1) def responder(self,*args): self.respWidget.text = self.resp tts.speak(self.resp) def escuta(self,*args): if self.ids.mic.background_normal == 'mic.png': self.ids.mic.background_normal = '' stt.start() Clock.schedule_interval(self.checar,1/5) else: self.ids.mic.background_normal = 'mic.png' stt.stop() def checar(self,*args): if not stt.listening: self.ids.mic.background_normal = 'mic.png' stt.stop() Clock.unschedule(self.checar) frase = ''.join(stt.results) if frase: self.mensagem(frase)
def test_extract_titles(): print("Testing extract_titles() functionality...") chatbot = Chatbot(False) # add more test cases here!!! test_cases = [ ('I liked "The Notebook"', ["The Notebook"]), ('You are a great bot!', []), ('I enjoyed "Titanic (1997)" and "Scream 2 (1997)"', ["Titanic (1997)", "Scream 2 (1997)"]), ] tests_passed = True for input_text, expected_output in test_cases: if not assert_list_equals( chatbot.extract_titles(chatbot.preprocess(input_text)), expected_output, "Incorrect output for extract_titles(" "chatbot.preprocess('{}')).".format( input_text), orderMatters=False ): tests_passed = False if tests_passed: print('extract_titles() sanity check passed!') print()
def main(): """ Main loop for the command line interface. """ (options, args) = PARSER.parse_args() # Configure logging logging.basicConfig(filename=options.log_filename, level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") logging.getLogger('py4j.java_gateway').setLevel(logging.INFO) # These imports are performed after the logging setup because basicConfig # will not work if other modules call logging functions before it's called. from chatbot import Chatbot from database import Database # Setup the database db = Database(options.database_url) # Setup the chatbot logger = logging.getLogger('chatbot') bot = Chatbot(db, logger) greeting = bot.get_greeting() print greeting while 1: # Chatbot instances should not call exit() themselves. # If they need to exit, they should signal so, not exit # themselves. PROMPT = bot.prompt # prompt from chatbot, shows mode: creative/regular try: user_input = raw_input(PROMPT) except EOFError: return bot_output = bot.handle_input(user_input) print bot_output
def test_extract_sentiment_for_movies(): print("Testing test_extract_sentiment_for_movies() functionality...") chatbot = Chatbot(True) # add more test cases here!!! test_cases = [ ('I liked both "I, Robot" and "Ex Machina".', [("I, Robot", 1), ("Ex Machina", 1)]), ('I liked "I, Robot" but not "Ex Machina".', [("I, Robot", 1), ("Ex Machina", -1)]), ('I didn\'t like either "I, Robot" or "Ex Machina".', [("I, Robot", -1), ("Ex Machina", -1)]), ('I liked "Titanic (1997)", but "Ex Machina" was not good.', [("Titanic (1997)", 1), ("Ex Machina", -1)]), ] tests_passed = True for input_text, expected_output in test_cases: if not assertListEquals( chatbot.extract_sentiment_for_movies( chatbot.preprocess(input_text)), expected_output, "Incorrect output for extract_sentiment_for_movies(chatbot.preprocess('{}'))." .format(input_text), orderMatters=False): tests_passed = False if tests_passed: print('extract_sentiment_for_movies() sanity check passed!') print()
def test_find_movies_closest_to_title(): print("Testing find_movies_closest_to_title() functionality...") chatbot = Chatbot(True) # add more test cases here!!! test_cases = [ ('Sleeping Beaty', [1656]), ('Te', [8082, 4511, 1664]), ('BAT-MAAAN', [524, 5743]), ('Blargdeblargh', []), ] tests_passed = True for input_text, expected_output in test_cases: if not assertListEquals( chatbot.find_movies_closest_to_title( chatbot.preprocess(input_text)), expected_output, "Incorrect output for find_movies_closest_to_title(chatbot.preprocess('{}'))." .format(input_text), orderMatters=False): tests_passed = False if tests_passed: print('find_movies_closest_to_title() sanity check passed!') print() return True
def test_find_movies_closest_to_title(): print("Testing find_movies_closest_to_title() functionality...") chatbot = Chatbot(True) # add more test cases here!!! test_cases = [('Sleeping Beaty', [1656]), ('Te', [8082, 4511, 1664]), ('BAT-MAAAN', [524, 5743]), ('Blargdeblargh', []), ('The Notebok', [5448]), ('An Awfully Big Advventuree', [127]), ('An Amrican in Paris', [721]), ('The Cellloid Closet', [516]), ('Titanc', [2716, 1359])] tests_passed = True for input_text, expected_output in test_cases: if not assert_list_equals( chatbot.find_movies_closest_to_title(input_text), expected_output, "Incorrect output for find_movies_closest_to_title(" "chatbot.preprocess('{}')).".format(input_text), orderMatters=False): tests_passed = False if tests_passed: print('find_movies_closest_to_title() sanity check passed!') print() return True
def test_extract_sentiment(): print("Testing extract_sentiment() functionality...") chatbot = Chatbot(False) # add more test cases here!!! test_cases = [ ('I like "Titanic (1997)".', 1), ('I saw "Titanic (1997)".', 0), ('I didn\'t enjoy "Titanic (1997)".', -1), ('I didn\'t really like "Titanic (1997)".', -1), ('I never liked "Titanic (1997)".', -1), ('I really enjoyed "Titanic (1997)".', 1), ('"Titanic (1997)" started out terrible, but the ending was totally great and I loved it!', 1), ('I loved "10 Things I Hate About You"', 1), ] tests_passed = True for input_text, expected_output in test_cases: if not assertEquals( chatbot.extract_sentiment( chatbot.preprocess(input_text)), expected_output, "Incorrect output for extract_sentiment(chatbot.preprocess('{}'))." .format(input_text)): tests_passed = False if tests_passed: print('extract_sentiment() sanity check passed!') print()
def test_find_movies_by_title(): print("Testing find_movies_by_title() functionality...") chatbot = Chatbot(False) # add more test cases here!!! test_cases = [ ('The American President', [10]), ('Titanic', [1359, 2716]), ('Titanic (1997)', [1359]), ('An American in Paris (1951)', [721]), ('The Notebook (1220)', []), ('Scream', [1142]), ] tests_passed = True for input_text, expected_output in test_cases: if not assert_list_equals( chatbot.find_movies_by_title(input_text), expected_output, "Incorrect output for find_movies_by_title('{}').".format( input_text), orderMatters=False ): tests_passed = False if tests_passed: print('find_movies_by_title() sanity check passed!') print()
def test_disambiguate_complex(): print("Testing complex disambiguate() functionality...") chatbot = Chatbot(True) # add more test cases here!!! test_cases = [ ('2', [8082, 4511, 1664], [4511]), ('most recent', [524, 5743], [1524]), ('the Goblet of Fire one', [3812, 4325, 5399, 6294, 6735, 7274, 7670, 7842], [6294]), ('the second one', [3812, 6294, 4325, 5399, 6735, 7274, 7670, 7842], [6294]), ] tests_passed = True for clarification, candidates, expected_output in test_cases: if not assertListEquals( chatbot.disambiguate(clarification, candidates), expected_output, "Incorrect output for complex disambiguate('{}', {})".format( clarification, candidates), orderMatters=False): tests_passed = False if tests_passed: print('complex disambiguate() sanity check passed!') print() return True
def getResponse(input_statement): from chatbot import Chatbot bot = Chatbot() with open(answers_json) as ans: ans_json = json.load(ans) input_statement = re.sub(r'[^a-zA-Z0-9-:.@/ ]', '', input_statement).strip() input_statement = ' '.join(input_statement.split()) bucket, sub_bucket, _, _ = extract_buckets(input_statement.lower()) reply = bot.get_response(input_statement) print("reply ---- {}".format(reply)) if bucket and sub_bucket: reply = reply elif bucket and not sub_bucket: reply = reply elif not bucket and sub_bucket: reply = "" else: reply = "" reply = str(reply) if not reply: suggestions = "" else: suggestions = ans_json[reply]["category"] replyJson = {"suggestions": suggestions} return replyJson
def ask(): data = request.get_json() if not data: return jsonify({"message": "No payload received"}), 400 if ("message" not in data): return jsonify({"message": "please specify a message"}), 400 if ("current_context" not in data): current_context = None else: current_context = data["current_context"] chatbot = Chatbot(sensitivity=0.4) chatbot.load() ''' chatbot.add_action("NutrizionistaCittaIntent", search_nutritionists) chatbot.add_action("DietistaCittaIntent", search_dietisti) chatbot.add_action("DietologoCittaIntent", search_dietologi) ''' answer = chatbot.ask(data["message"], current_context=current_context, return_proba=True) return jsonify({ "answer": str(answer[0]), "new_context": str(answer[1]), "probability": str(answer[2]) }), 200
def test_extract_titles_creative(): print("Testing [CREATIVE MODE] extract_titles() functionality...") chatbot = Chatbot(True) if assertListEquals( chatbot.extract_titles('I liked The Notebook!'), [ "The Notebook" ], "Incorrect output for [CREATIVE] extract_titles('I liked The Notebook')." ) and assertListEquals( chatbot.extract_titles( 'I thought 10 things i hate about you was great'), ["10 things i hate about you", "10", "hate"], "Incorrect output for [CREATIVE] extract_titles('I thought 10 things i hate about you was great').", orderMatters=False ) and assertListEquals( chatbot.extract_titles('I like \"Harry Potter\"'), [ "Harry Potter" ], "Incorrect output for [CREATIVE] extract_titles('I like \"Harry Potter\"')." ) and assertListEquals( chatbot.extract_titles('I liked Scream 2!'), ["Scream", "Scream 2"], "Incorrect output for [CREATIVE] extract_titles('I liked Scream 2').", orderMatters=False ) and assertListEquals( chatbot.extract_titles( 'I liked "Titanic" and 10 things i hate about you...'), ["Titanic", "10 things i hate about you", "10", "hate"], "Incorrect output for [CREATIVE] extract_titles('I liked \"Titanic\" and 10 things i hate about you').", orderMatters=False ) and assertListEquals( chatbot.extract_titles('I liked Se7en, 10 things i hate about you, La guerre du feu, The Return of Godzilla, and I, Robot!' ), [ "10", "hate", "Se7en", "10 things i hate about you", "La guerre du feu", "I, Robot", "The Return of Godzilla", "The Return", "Godzilla" ], "Incorrect output for [CREATIVE] extract_titles('I liked Se7en, 10 things i hate about you, La guerre du feu, The Return of Godzilla, and I, Robot!').", orderMatters=False ) and assertListEquals( chatbot .extract_titles('I liked "Home Alone 3"'), ["Home Alone 3"], "Incorrect output for [CREATIVE] extract_titles('I liked \"Home Alone 3\").", orderMatters=False ) and assertListEquals( chatbot. extract_titles('I liked happy feet' ), ["happy", "happy feet"], "Incorrect output for [CREATIVE] extract_titles('I liked happy feet).", orderMatters=False ) and assertListEquals( chatbot .extract_titles('I liked \"Happy Feet\"'), ["Happy Feet"], "Incorrect output for [CREATIVE] extract_titles('I liked \"Happy Feet\").", orderMatters=False): print('[CREATIVE MODE] extract_titles() sanity check passed!') print()
def main(): chatbot = Chatbot() print('BOT: Olá querido usuário!') print( 'BOT: Fico a disposição para responder perguntas sobre mercado, saúde, tecnologia e telefonia.' ) print('BOT: Diga tchau quando encerrar!') stop = False while not stop: user_request = input('Pergunta: ') user_request = user_request.lower() if user_request != 'tchau': if user_request == 'obrigado' or user_request == 'muito obrigado': stop = True print("BOT: Não há de quê!") else: if chatbot.greeting(user_request) != '': print("BOT:", chatbot.greeting(user_request)) else: print("BOT: Pensando...") start_time = time.perf_counter() response = chatbot.response(user_request) end_time = time.perf_counter() print("BOT:", response) print('[{:.1f} segundos]'.format(end_time - start_time)) else: stop = True print("BOT: Até mais!")
def test_recommend(): print("Testing recommend() functionality...") chatbot = Chatbot(False) user_ratings = np.array([1, -1, 0, 0, 0, 0]) all_ratings = np.array([ [1, 1, 1, 0], [1, -1, 0, -1], [1, 1, 1, 0], [0, 1, 1, -1], [0, -1, 1, -1], [-1, -1, -1, 0], ]) small_recommendations = chatbot.recommend(user_ratings, all_ratings, 2) user_ratings = np.zeros(9125) user_ratings[[8514, 7953, 6979, 7890]] = 1 user_ratings[[7369, 8726]] = -1 recommendations = chatbot.recommend(user_ratings, chatbot.ratings, k=5) test_cases = [ (small_recommendations, [2, 3]), (recommendations, [8582, 8596, 8786, 8309, 8637]), ] tests_passed = True for i, (recs, expected_output) in enumerate(test_cases): if not assertListEquals( recs, expected_output, "Test case #{} for recommender tests failed".format(i), ): tests_passed = False if tests_passed: print('recommend() sanity check passed!') print()
def test_disambiguate(): print("Testing disambiguate() functionality...") chatbot = Chatbot(True) # add more test cases here!!! test_cases = [ ('1997', [1359, 2716], [1359]), ('2', [1142, 1357, 2629, 546], [1357]), ('Sorcerer\'s Stone', [3812, 4325, 5399, 6294, 6735, 7274, 7670, 7842], [3812]), ] tests_passed = True for clarification, candidates, expected_output in test_cases: if not assertListEquals( chatbot.disambiguate(clarification, candidates), expected_output, "Incorrect output for disambiguate('{}', {})".format( clarification, candidates), orderMatters=False): tests_passed = False if tests_passed: print('disambiguate() sanity check passed!') print() return True
def main(): # initialise the bot bot = Bot(cache_path=True) # search the friend with name my_friend = bot.friends().search("旋潇")[0] chatbot = Chatbot() # sent a start message my_friend.send('Hello! This is the chatbot') # reply the message send by my_friend @bot.register(my_friend) def reply_my_friend(msg): state = MAIN pending = None print(chatbot.get_intent(msg.text)) state, pending, final_response, message_intent = chatbot.send_message( state, pending, msg.text) msg.reply(final_response) # send_figure if message_intent == 'clear_historical_data' or message_intent == 'add_historical_data': msg.reply_image('result.png') return None embed()
def test_binarize(): print("Testing binarize() functionality...") chatbot = Chatbot(False) if assertNumpyArrayEquals( chatbot.binarize(np.array([[1, 2.5, 5, 0]])), np.array([[-1., -1., 1., 0.]]), "Incorrect output for binarize(np.array([[1, 2.5, 5, 0]]))."): print("binarize() sanity check passed!") print()
def handle_message(event): #print("Handle: reply_token: " + event.reply_token + ", message: " + event.message.text) tokenID = "{}".format(event.reply_token) content = "{}".format(event.message.text) print("line_message : ", content) if content != "": from chatbot import Chatbot chat = Chatbot(content) ## print("hi",chat) line_bot.reply_message(tokenID, TextSendMessage(text=chat))
def __init__(self, creative=False): super().__init__() self.chatbot = Chatbot(creative=creative) self.name = self.chatbot.name self.bot_prompt = '\001\033[96m\002%s> \001\033[0m\002' % self.name self.greeting = self.chatbot.greeting() self.intro = self.chatbot.intro() + '\n' + self.bot_prompt + self.greeting self.debug = False
def reply_messages(msg): print(msg) sender = msg.sender global chatbots if sender in chatbots: sender.send(chatbots[sender].respond(msg.text)) else: chatbot = Chatbot(interpreter) chatbots[sender] = chatbot sender.send(chatbot.greet())
class Assistente(Screen): bot = Chatbot('Pedro') def mensagem(self, msg, *args): self.ids.box.add_widget(Tarefa(text=msg)) frase = self.bot.escuta(frase=msg) resp = self.bot.pensa(frase) self.bot.fala(resp) self.ids.box.add_widget(Tarefa(text=resp)) self.ids.texto.text = ''
def main(room_id): chatbot = Chatbot(decrypt='caird') chatbot.login() chatbot.joinRoom(room_id, ignore_msgs) for msg in get_msg(): chatbot.rooms_joined[0].sendMessage(msg) chatbot.leaveAllRooms() return