def text_reply(msg):
if msg['Type'] == 'Text':
reply_content = msg['Text']
elif msg['Type'] == 'Picture':
reply_content = u"??: " + msg['FileName']
elif msg['Type'] == 'Card':
reply_content = u" " + msg['RecommendInfo']['NickName'] + u" ???"
elif msg['Type'] == 'Map':
x, y, location = re.search("<location x=\"(.*?)\" y=\"(.*?)\".*label=\"(.*?)\".*", msg['OriContent']).group(1,
2,
3)
if location is None:
reply_content = u"??: ??->" + x.__str__() + " ??->" + y.__str__()
else:
reply_content = u"??: " + location
elif msg['Type'] == 'Note':
reply_content = u"??"
elif msg['Type'] == 'Sharing':
reply_content = u"??"
elif msg['Type'] == 'Recording':
reply_content = u"??"
elif msg['Type'] == 'Attachment':
reply_content = u"??: " + msg['FileName']
elif msg['Type'] == 'Video':
reply_content = u"??: " + msg['FileName']
else:
reply_content = u"??"
friend = itchat.search_friends(userName=msg['FromUserName'])
itchat.send(u"Friend:%s -- %s "
u"Time:%s "
u" Message:%s" % (friend['NickName'], friend['RemarkName'], time.ctime(), reply_content),
toUserName='filehelper')
itchat.send(u"????????%s???????%s??????--????(Python?)" % (time.ctime(), reply_content),
toUserName=msg['FromUserName'])
apiTestForWeChatWithItChat.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录