python的itchat库学习----微信私聊自动回复及群聊自动回复,仅限文字

import itchat
from itchat.content import *
from itchat.content import TEXT

@itchat.msg_register(TEXT,isGroupChat=True)
def text_reply(msg):
    print(msg['isAt'])
    print(msg['ActualNickName'])
    print(msg['Content'])
    return '你刚说,%s'% msg['Content']


@itchat.msg_register(TEXT,isFriendChat=True)
def friend_reply(msg):
    if msg['Type']==TEXT:
        print(msg['Content'])
        return '你刚说->%s,好的。'% msg['Content']
#@itchat.msg_register(FRIENDS)
#def add_friend(msg):
#    itchat.add_friend(**msg['Type'])
 #   itchat.send_msg('Nice to meet you!',msg['Recommendinfo']['UserName'])
 #   return 'Nice to meet you!%s'% msg['Recommendinfo']['UserName']
itchat.auto_login(hotReload=True)
itchat.run()

结果:每自动回复一条,个人微信也会显示发出这样一条消息,如下图:

python的itchat库学习----微信私聊自动回复及群聊自动回复,仅限文字