美文网首页
用python自动回复微信

用python自动回复微信

作者: 赵智雄 | 来源:发表于2018-06-26 09:49 被阅读144次

    wxpy
    微信机器人 / 可能是最优雅的微信个人号 API
    wxpyitchat 的基础上,通过大量接口优化提升了模块的易用性,并进行丰富的功能扩展
    主页:https://wxpy.readthedocs.io/zh/latest/


    在项目的主页有最简单的应用。

    #coding=utf-8
    #微信自动回复
    
    from wxpy import *
    if __name__ == '__main__':
        bot = Bot()
        # my_friend = bot.friends()
        # 打印来自其他好友、群聊和公众号的消息
        @bot.register()
        def print_others(msg):
            # 排除群聊
            friend = msg.sender
            if type(friend) == Friend:
                print (' is friend')
                friend.send(u'【您好,我现在有事不在,一会再和您联系。】')
            elif type(friend) == Group:
                print (' is group')
            print(msg)
        # (优先匹配后注册的函数!)
    
        # 阻塞进程
        bot.join()
    

    自动回复的时候要注意排除群聊。。。


    高级功能,还没搞过。

    相关文章

      网友评论

          本文标题:用python自动回复微信

          本文链接:https://www.haomeiwen.com/subject/lhrpyftx.html