def on_new_message(data): # this is used to strip away the nickname infront of the chat message botcommand = data["message"].lstrip(":") chat = Chatbot(botcommand) if chat.checkcommand(): db.session.add(models.Chatlog(chat.getcommand())) db.session.commit() else: db.session.add( models.Chatlog(data["nickname"] + ": " + data["message"])) db.session.commit() emit_all_messages(ADDRESSES_RECEIVED_CHANNEL)