def construct_reply(msg): if '生日快乐' in msg.text: rep = get_response( msg['Text']) or u'蟹蟹蟹蟹我已经快乐得飞起来了呢' + ' ' + random.choice(happy) else: rep = get_response(msg['Text']) return (rep)
def text_reply(msg): if u'获取图片' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture else: return get_response(msg['Text']) or u'收到:' + msg['Text']
def text_reply(msg): # print(msg) # 设置延迟回复 time.sleep(0.2) if msg["MsgType"] == "text": if msg["Content"] == u'【收到不支持的消息类型,暂无法显示】': # 图片回复 reply = pictureReply() else: reply = get_response(msg["Content"]) return reply if msg["MsgType"] == "image": # reply = pictureReply() reply = u"接收到图片" return reply if msg["MsgType"] == "event": # print("hhh") if msg["Event"] == "subscribe": # print("关注") reply = u"你好,欢迎关注squirrel" return reply if msg["Event"] == "unsubscribe": # print("取消关注") return else: return else: return
def return_img(Ask_text, user_name): current_ask_Y = 517 current_ans_Y = 635 num = random.randint(1, 5) img_PIL = Image.open(str(num) + '.png') Ans_text = get_response(Ask_text) font = ImageFont.truetype('C:\WINDOWS\FONTS\HANYINUOMITUAN-W-2.TTF', 48) draw = ImageDraw.Draw(img_PIL) while len(Ask_text): draw.text((120, current_ask_Y), Ask_text[:8], font=font, fill=(255, 255, 255)) Ask_text = Ask_text[8:] current_ask_Y += 40 while len(Ans_text): draw.text((120, current_ans_Y), Ans_text[:8], font=font, fill=(255, 255, 255)) Ans_text = Ans_text[8:] current_ans_Y += 40 draw.text((282.5 - 22.5 * len(user_name), 420), user_name, font=font, fill=(255, 255, 255)) save_file_name = str(int(time.time())) + '_' + str(random.randint( 1, 10000)) + '.jpg' plt.imsave('./tmp/' + save_file_name, img_PIL) return './tmp/' + save_file_name
def text_reply(msg): text = msg['Text'] if msg['Type'] == itchat.content.RECORDING: mp3_name = "download/" + msg['FileName'] msg['Text'](mp3_name) txts = baidu.get_response(mp3_name) log('recognized len: %d' % len(txts)) text = txts[0] peer = msg['User'] title = '' if msg['ToUserName'] == 'filehelper': title += 'Self' else: if peer['UserName'] == msg['ToUserName']: title += 'Send to >' # Uin, Sex, MsgId, CreateTime if peer['RemarkName']: title += '%(RemarkName)s(%(Province)s %(City)s)' % peer else: title += '%(NickName)s(%(Province)s %(City)s)' % peer log('%s: %s' % (title, text)) if peer['UserName'] != msg['ToUserName'] or msg['ToUserName'] == 'filehelper': reply = filter_reply(text) if reply == None: reply = tuling.get_response(text) touser = msg['FromUserName'] if msg['ToUserName'] == 'filehelper': touser = '******' send_msg(reply, touser) return
def text_reply(msg): ttt='找我干嘛' if msg['isAt']: if len(msg['Text'])>2: ttt=msg['Text'].split()[1:] txt=tuling.get_response(ttt, storageClass = None, userName = None, userid = 'ItChat') itchat.send(u'@%s\u2005 %s'%(msg['ActualNickName'],txt), msg['FromUserName'])
def get_nir_response(message): # help,以及code if u'/help' == message or u'help' == message: return (u'Bot:' + info.help) # 关于图灵机的启动与关闭 if u'/tuling' == message: info.tulingBot = True return (u'M醬:你好,我是M醬') elif u'/killTuling' == message: info.tulingBot = False return (u'M醬:我这就走') elif info.tulingBot == True: return ('M醬:' + get_response(message)) or u'bot:M醬不在' # 自定义回复内容 if message in info.items.keys(): return ('Bot:' + info.items[message]) # 调试模式 if u'/test' in message: test, from_str, to_str = map(str, message.split()) info.items[from_str] = to_str # 这已经是互异的了 return (u'Bot:指令录入成功') # 时间模式,只对自己有用 if u'/time' in message: time0, info.time = map(str, message.split()) return (u'Bot:成功设定时间 ' + info.time) # 状态模式,只对自己有用 if u'/status' in message: test, info.status = map(str, message.split()) return ('Bot:成功设定状态 ' + info.time) # 对作业的操作 if '/add' in message: course_name = message.split()[1] homework = '' for row in message.split('\n')[1:]: homework = homework + '\n' + row info.homework[course_name] = homework return (course_name + homework) if '/del' in message: info.homework.pop(str(message.split()[1])) return "Bot:成功删除" if '/homework' == message: homework = "" cow = "" for cow in info.homework: homework = homework + cow homework = homework + info.homework[cow] homework += "\n\n" return homework
def text_reply(msg): print(msg) white_list = { '张喜庄92号院': '@@427f7ba31d25e1dc70f88978bfbc861a6142573141a0fbcddb1a4b11af16e4c5', } if msg['FromUserName'] in white_list.values(): return get_response(msg['Text'])
def text_reply(msg): print(msg) if msg['FromUserName'] == '@efd311ea496fbfcd5b55ae8a164512845605463d6c5703cab311c0f8b4018f3a': return '你是xxxx~' #可以对某人专门回复 elif msg['Text'] == '01': return '你好,我是!' else: return get_response(msg['Text'])
def echo(bot, update): if info.tulingBot_Telegram == True: update.message.reply_text(('M醬:' + get_response(update.message.text)) or u'bot:M醬不在') return """自定义回复内容""" if update.message.text in info.items.keys(): update.message.reply_text(u'Bot:' + info.items[update.message.text])
def text_reply(msg): print(msg) if msg['FromUserName'] == '@efd311ea496fbfcd5b55ae8a164512845605463d6c5703cab311c0f8b4018f3a': return '你是?' elif msg['Text'] == '狂欢马克思': return '没错,我就是狂欢马克思!哈哈哈~' else: return get_response(msg['Text'])
def text_reply(msg): if u'作者' in msg['Text'] or u'主人' in msg['Text']: return u'你可以在这里了解他:https://github.com/littlecodersh' elif u'源代码' in msg['Text'] or u'获取文件' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) return u'这就是现在机器人后台的代码,是不是很简单呢?' elif u'获取图片' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture else: return get_response(msg['Text']) or u'收到:' + msg['Text']
def text_reply(msg): print(msg) white_list = { 'pmcaff 专家群': '@@2b915b714a0e65fe93bb0b94dfc80156db79334ff9fda274ba08ae7638dd7cb6', '葫芦娃群': '@@90b2ad91b1c33967d6d0723217b6084ed0607c7b627f8a87e53d4e8b802ff1ed', } if msg['FromUserName'] in white_list.values(): return get_response(msg['Text'])
def text_reply(msg): if u'作者' in msg['Text'] or u'主人' in msg['Text']: return u'Lazy' elif u'源代码' in msg['Text'] or u'获取文件' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) return u'还没开发呢' elif u'获取图片' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture else: return get_response(msg['Text']) or u'' + msg['Text']
def atreply(msg): if msg.isAt: out = get_response(msg['Text']) qalogger.info(json.dumps(dict(question=msg['Text'], answer=out), ensure_ascii=False)) if out: timesleep(out, rate=random.random() + 0.5) text = '@%s %s' % (msg.actualNickName, out) msg.user.send(text) logger.info('Send Text: {}'.format(text)) else: sendemoji(msg)
def text_reply(msg): if u'作者' in msg['Text'] or u'主人' in msg['Text']: return u'你可以在这里了解他:https://xixiangkun.github.io/' elif u'源代码' in msg['Text'] or u'获取文件' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) return u'这就是现在机器人后台的代码,是不是很简单呢?' elif u'获取图片' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture else: return get_response( msg['Text']) or u'机器人Canglan代理回复,主人不在,Canglan收到:' + msg['Text']
def group_reply(msg): if msg['isAt']: #print json.dumps(msg, indent = 4) if u'每日一图' in msg['Text']: fileName, description = getRanPic("aa") img_msg= '@img@%s' % fileName itchat.send(img_msg, msg['FromUserName']) # there should be a picture return description else: text = msg['Text'][msg['Text'].find(u'\u2005')+1:] print text return u'@%s\u2005%s' % (msg['ActualNickName'], get_response(text) or u'收到:' + msg['Text'])
def text_reply(msg): # 关于图灵机的启动与关闭 if u'/tuling' == msg['Text']: msg.user.send(u'M醬:你好,我是M醬') info.tulingBot_Group = True return elif u'/killTuling' == msg['Text']: msg.user.send(u'M醬:我这就走') info.tulingBot_Group = False return elif info.tulingBot_Group == True: msg.user.send(('M醬:' + get_response(msg['Text'])) or u'bot:M醬不在') return
def text_reply(msg): if u'作者' in msg['Text'] or u'主人' in msg['Text']: return u'你可以在这里了解他:https://github.com/legolas007' elif u'源代码' in msg['Text'] or u'获取文件' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) return u'这就是现在机器人后台的代码,是不是很简单呢?' elif u'获取图片' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture elif u'下线' in msg['Text']: itchat.logout() return u'再见喽~~~' else: return get_response(msg['Text']) #or u'收到啦~~~'
def normalreply(msg): if msg['Type'] == 'Text': if random.choice([0, 0, 0, 0, 1]): sendemoji(msg) out = get_response(msg['Text']) qalogger.info(json.dumps(dict(question=msg['Text'], answer=out), ensure_ascii=False)) if out: logger.info('Send Text: {}'.format(out)) timesleep(out, rate=random.random() + 0.5) return out else: sendemoji(msg) else: sendemoji(msg)
def text_reply(msg): if u'作者' in msg['Text'] or u'主人' in msg['Text']: return u'找陈蒙 [email protected]' elif u'同盟会群' in msg['Text'] or u'同盟会' in msg['Text']: itchat.send( '@img@/Users/koudai232/PycharmProjects/python_pycharm/Python/itchat_test/img/tongmenghui_group.png', msg['FromUserName']) return u'长按扫码进群,有问题请@陈蒙或者群主' elif u'白领活动' in msg['Text']: itchat.send( '@img@/Users/koudai232/PycharmProjects/python_pycharm/Python/itchat_test/img/funbailing.jpg', msg['FromUserName']) # there should be a picture return u'长按扫码关注,有问题联系@陈蒙' elif u'亲子活动' in msg['Text']: itchat.send( '@img@/Users/koudai232/PycharmProjects/python_pycharm/Python/itchat_test/img/funmili.jpg', msg['FromUserName']) # there should be a picture return u'长按扫码关注,有问题联系@陈蒙' else: return get_response(msg['Text'])
def text_reply(msg): if u'作者' in msg['Text'] or u'主人' in msg['Text']: return u'我主人超级帅的!' elif u'源代码' in msg['Text'] or u'获取文件' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) itchat.send('Project: https://github.com/yhu20/WeChatBot/tree/master') return u'这就是现在机器人后台的代码,是不是很简单呢?' elif u'获取图片' in msg['Text'] or u'自拍' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture elif u'翻译' in msg['Text'] or u'translate' in msg['Text']: # print(msg['Text']) raw_text = re.split(':|:', msg['Text'], 1) # targetlan = raw_text[0] text = raw_text[-1] from api import ggtrans return ggtrans.translate2(text) else: return get_response(msg['Text']) or u'收到:' + msg['Text']
def text_reply(msg): if msg['ToUserName'] == 'filehelper': if msg['Text'] == u'关闭': close_music() itchat.send(u'音乐已关闭', 'filehelper') if msg['Text'] == u'帮助': itchat.send(HELP_MSG, 'filehelper') else: itchat.send(interact_select_song(msg['Text']), 'filehelper') else: if u'作者' in msg['Text'] or u'主人' in msg['Text']: return u'Jack Yang' elif u'获取图片' in msg['Text']: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture elif u'每日一图' in msg['Text']: fileName, description = getRanPic("aa") img_msg= '@img@%s' % fileName itchat.send(img_msg, msg['FromUserName']) # there should be a picture return description else: print msg['Text'] return get_response(msg['Text']) or u'收到:' + msg['Text']
def group_reply(msg): if msg['isAt']: text = msg['Text'].split(' ')[1].strip() if u'作者' in text or u'主人' in text: return u'我主人超级帅的!' elif u'源代码' in text or u'获取文件' in text: itchat.send('@[email protected]', msg['FromUserName']) return u'这就是现在机器人后台的代码,是不是很简单呢?' elif u'获取图片' in text or u'自拍' in text: itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture return u'这就是帅气的我!' elif u'翻译' in msg['Text'] or u'translate' in msg['Text']: # print(msg['Text']) raw_text = re.split(':|:', msg['Text'], 1) targetl = raw_text[0] text = raw_text[-1] from api import ggtrans return ggtrans.translate2(text) else: return u'@%s\u2005%s' % (msg['ActualNickName'], get_response(text) or u'收到:' + msg['Text'])
def text_reply(msg): return tuling.get_response(msg['Text']) or u'收到:' + msg['Text']
def group_reply(msg): if msg['isAt']: return u'@%s\u2005%s' % (msg['ActualNickName'], get_response(msg['Text']) or u'收到:' + msg['Text'])
def text_reply(msg): if get_catogry(msg) == 'Other': other_msg = " 主人现在不在,我只是个机器人,不太明白你要做什么。我会提醒主人,回来时候看您的留言。" return get_response(msg['Text']) or u'收到:' + msg['Text'] + other_msg else: return reply.get(get_catogry(msg))()
def text_reply(msg): txt = msg['Text'] output=tuling.get_response(txt, storageClass = None,userName = None, userid = 'ItChat') itchat.send(output, msg['FromUserName'])
def text_reply(msg): msg_clean = msg['Text'].replace(' ', '') if msg.user.remarkName == '南小倩' or msg.user.remarkName == '静静': if '很棒' in msg_clean: return random.choice(['哈哈哈', '乖']) elif '停' == msg_clean: quit() elif '不说' in msg_clean: return '不跟你玩了' elif '讨厌' in msg_clean: return '讨厌就是喜欢' elif '不爱' in msg_clean: return '你可以走了' elif '爱你' in msg_clean: return '我也爱你' elif '喜欢你' in msg_clean: return '我你也喜欢你' elif '多爱' in msg_clean: return '比你爱我更爱你' elif '滚' in msg_clean: return '滚出去,再滚回来' elif '吃了' in msg_clean: return '你个吃货' elif '没吃' in msg_clean: return '快去吃吧' elif '没' in msg_clean: return '快去' elif '你才' in msg_clean: return '我选择投降' elif '不想' in msg_clean: return '你还想不想混了' elif '想' in msg_clean or '想你' in msg_clean: return '我也想你' elif '好烦' in msg_clean: return '女人每个月都有那么几天' elif '拜拜' in msg_clean or '再见' in msg_clean or '走了' in msg_clean: return random.choice(['走了就别回来', '别走', '爱我别走']) elif '开心' in msg_clean: return '开心' elif '谢谢' in msg_clean: return '不客气' elif '是不是' in msg_clean: return '是' elif '吗' in msg_clean: return '当然' elif '你' in msg_clean or '升' in msg_clean: return '真是瞎了眼' elif '不玩' in msg_clean: return '辛苦了' elif '笨蛋' in msg_clean: return '二货' elif '顶嘴' in msg_clean: return '不敢' elif '嫁给你' in msg_clean: return '好啊' elif '娶我' in msg_clean: return '娶你' elif '生气' in msg_clean: return '生气会长皱纹' else: flag = random.randint(0, 10) if flag >= 7: return random.choice( ['快说我很棒', '说你爱我', '你吃饭了吗', '你喜欢谁', '你想不想我']) else: return get_response(msg['Text'])
def tuling(message, something): message.reply(get_response(something))