花样玩微信
可应用场景
- 多个群之间消息转发 微信群限制(500人)
- 客服机器人
- 社交与乐趣
- 自动打卡签到 日历提醒等
- 信息推广(新闻,产品,广告等)
- 监控警报
不支持功能
- 支付相关 - 红包、转账、收款 等都不支持
- 在群聊中@他人 - 是的,Web 微信中被人@后也不会提醒
- 发送名片 - 但可以通过 send_raw_msg() 转发
- 发送分享链接 - 也无法转发
- 发送语音消息
- 朋友圈相关
- 无法删除好友及公众号取消关注
风险及缺陷
- 存在一定概率被限制登录的可能性主要表现为无法登陆 Web 微信 (但不影响手机等其他平台)。
- 新注册微信号直接无法登陆 Web 微信
- 后续存在网页版微信有关停的风险
模块特色
- 全面对象化接口,调用更优雅
- 默认多线程响应消息,回复更快
- 包含 聊天机器人、共同好友 等 实用组件
- 只需两行代码,在其他项目中 用微信接收警告
- 愉快的探索和调试,无需涂涂改改
- 可混合使用 itchat 的原接口
- 当然,还覆盖了各类常见基本功能:
- 发送文本、图片、视频、文件
- 通过关键词或用户属性搜索 好友、群聊、群成员等
- 获取好友/群成员的昵称、备注、性别、地区等信息
- 加好友,建群,邀请入群,移出群
简单上手
# 导入模块
from wxpy import
# 初始化机器人,扫码登陆
bot = Bot()
# 搜索名称含有 "游否" 的男性深圳好友
my_friend = bot.friends().search('游否', sex=MALE, city="深圳")[0]
# 发送文本给好友
my_friend.send('Hello WeChat!')
# 发送图片
my_friend.send_image('my_picture.jpg')
# 搜索名称含有 "游否" 的男性深圳好友
my_friend = bot.friends().search('游否', sex=MALE, city="深圳")[0]
# 发送文本给好友 my_friend.send('Hello WeChat!') # 发送图片 my_friend.send_image('my_picture.jpg') # 打印来自其他好友、群聊和公众号的消息 @bot.register() def print_others(msg): print(msg) # 回复 my_friend 的消息 (优先匹配后注册的函数!) @bot.register(my_friend)def reply_my_friend(msg): return 'received: {} ({})'.format(msg.text, msg.type) # 自动接受新的好友请求 @bot.register(msg_types=FRIENDS) def auto_accept_friends(msg): # 接受好友请求 new_friend = msg.card.accept() # 向新的好友发送消息 new_friend.send('哈哈,我自动接受了你的好友请求') # 进入 Python 命令行、让程序保持运行 embed() # 或者仅仅堵塞线程 # bot.join()
进群:960410445 获取更多源码!