def add_channel(user): users = open('Authorised_Channels.txt', 'r').read() userExists = re.search(r"(\{0}\n)|(^{0}\n)".format(user), users) if userExists: main.chat("Come on, you can't adopt me again OpieOP", config.NICK) else: conn_handle.join_channel(user) main.chat("Hey, I'm here now 4Head", user) channelFile = open("Authorised_Channels.txt","a+") channelFile.write(user+"\n"); channelFile.close()
def perform_command(user, channel, messageList, response): if messageList[0] == "!mods": retrieve_mods(channel) elif messageList[0] == "!points": points_command(user, channel, messageList, response) elif messageList[0] == "!adopt" and channel == config.NICK: db_handle.add_channel(user) elif messageList[0] == "!abandon" and channel == config.NICK: conn_handle.remove_channel(user) else: main.chat("'"+messageList[0][1:len(messageList[0])]+"' is not a valid command GeeFaceNoSpace", channel)
def points_command(user, channel, messageList, response): if len(messageList) > 1: if messageList[1] == "send": points_send(user, channel, messageList) elif messageList[1] == "add": points_add(user, channel, messageList, response) elif messageList[1] == "remove": points_remove(user, channel, messageList, response) elif messageList[1] == "help": points_help() else: main.chat(user+": 0 4Head", channel)
def remove_channel(user): users = open('Authorised_Channels.txt', 'r').read() userExists = re.search(r"(\{0}\n)|(^{0}\n)".format(user), users) if userExists: channelFile = open("Authorised_Channels.txt","r") lines = channelFile.readlines() channelFile.close() channelFile = open("Authorised_Channels.txt","w") for line in lines: if line!=user+"\n": channelFile.write(line) channelFile.close() main.chat("I'm gone now BibleThump",config.NICK) conn_handle.leave_channel(user) else: main.chat("You can't remove me if I wasn't there to begin with 4Head", config.NICK)
def handleMessage(self): # echo message back to client message = self.data #Get the written message by user and give it as input to chat() response = chat(message) #Print the response of from the chat() self.sendMessage(response)
def msg(update, context): a = str(update) data = eval(a) print(data['message']['chat']['first_name'] + " : " + data['message']['text']) msg_text = data['message']['text'] context.bot.send_message(chat_id=update.effective_chat.id, text=replay.chat(msg_text))
def handle_my_custom_event1(json1): message = json1['message'] print(message) answer = chat(message) json1['answer'] = answer json1['bot'] = 'AI' print('recived my event: ' + str(json1)) socketio.emit('my response', json1, callback=messageRecived)
def audio(update, context): a = str(update) data = eval(a) print("Audio message Processing! ") x = data["message"]["voice"]['file_id'] text = download_voice(x) print(data['message']['chat']['first_name'] + " : " + text) context.bot.send_message(chat_id=update.effective_chat.id, text=replay.chat(text))
def home(): #return render_template("index.html") if request.method == "GET": return render_template("index.html") if request.method == "POST": text = request.form.get('textbox') return render_template("index.html", output=main.chat(text), user_text=text) """
def post(): try: data = request.get_json() userdata = chat(data) response = jsonify({ "patient": userdata['UserID'], "doctor": userdata['Data']['doctor'], "reason": userdata['Data']['reason'], "date": userdata['Data']['date'], "time": userdata['Data']['time'], "message": userdata["Message"] }) response.headers.add('Access-Control-Allow-Origin', '*') except: response = jsonify({"message": "Error has occured"}) response.headers.add('Access-Control-Allow-Origin', '*') return response
def retrieve_mods(channel): try: j_obj = json.loads(urllib.request.urlopen('http://tmi.twitch.tv/group/user/'+channel+'/chatters', timeout = 15).read().decode('utf-8')) modsOnline = j_obj['chatters']['moderators'] if modsOnline is not None: print(modsOnline) if len(modsOnline) > 0: modList = "" for curMod in modsOnline: modList = modList+curMod+", " main.chat("Mods currently in chat: "+modList[0:(len(modList)-2)], channel) else: main.chat("mods are offline, post FrankerZ", channel) except urllib.error.URLError as e: print(e.reason) main.chat("Twitch messed up KappaGee", channel) return
def send_message_insert(self, message): inp = self.entry_field.get() pr1 = "You : " + inp + "\n" self.text_box.configure(state=NORMAL) self.text_box.insert(END, pr1) self.text_box.configure(state=DISABLED) self.text_box.see(END) #t1 = threading.Thread(target=self.playResponce, args=(user_input,)) #t1.start() #time.sleep(1) ob = chat(inp) pr = "CB_shop : " + ob + "\n" self.text_box.configure(state=NORMAL) self.text_box.insert(END, pr) self.text_box.configure(state=DISABLED) self.text_box.see(END) self.last_sent_label( str( time.strftime("Last message sent: " + '%B %d, %Y' + ' at ' + '%I:%M %p'))) self.entry_field.delete(0, END) time.sleep(0) t2 = threading.Thread(target=self.playResponce, args=(ob, )) t2.start()
def chatbot(): message = str(request.data.get('message','')) response = main.chat(message) return {'message':response}
def points_add(user, channel, messageList, response): isMod = re.search(r"(mod=)(.*?);",response).group(2) # grabs for mod status from raw message if isMod == "1": main.chat("Points were added... somehow", channel) else: main.chat("You don't have the permission to send points OpieOP", channel)
def suggestions(): text = request.args.get('appid') if text: abc = chat(text) return {'text': text, "response": abc}
def add_channel(user): cur.execute("""INSERT OR IGNORE INTO channels VALUES(?, 1)""", (user,)) conn_handle.join_channel(user) main.chat("Hey, I'm here now 4Head", user)
def points_help(): main.chat("Syntax: !points [send/add] [user] [amount]", channel)
def points_send(user, channel, messageList): main.chat("Send points pls", channel)
messages = Text(window) messages.pack() messages.insert(INSERT,'Agent:\n' + 'Welcome to the flydubai chat assistant\n\ Here you can talk to us about\n\ * Search flights\n\ * Book flights\n\ * Track flights\n') input_user = StringVar() input_field = Entry(window, text=input_user) input_field.pack(side=BOTTOM, fill=X) print 'pintooo' bot = chat() def Enter_pressed(event): input_get = input_field.get() # print(input_get) messages.insert(INSERT, 'You:\n%s\n\n\n' % input_get) if(bot.flag==0): response = bot.bolo(input_get) messages.insert(INSERT, 'Agent:\n'+str(response)+'\n\n') if response.startswith("Searching"): bot.flag = 1 if(bot.flag==1): response = bot.Search(input_get) messages.insert(INSERT, 'Agent:\n'+str(response)+'\n\n')
def chat(): req = request.json print("below is req") print(req) return jsonify({"response": main.chat(req)})
def get_bot_response(): userText = request.args.get('msg') # return ("Hello Swaaz!!!") return str(main.chat(userText))
def get_bot_response(): userText = request.args.get('msg') return main.chat(userText)