微信机器人 / 优雅的微信个人号API
Project description
微信机器人 / 优雅的微信个人号API,基于 itchat,全面优化接口,更有 Python 范儿。
用来干啥
一些常见的场景
控制路由器、智能家居等具有开放接口的玩意儿
运行脚本时自动把日志发送到你的微信
加群主为好友,自动拉进群中
跨号或跨群转发消息
自动陪人聊天
逗人玩
… [1]
总而言之,可用来实现各种微信个人号的自动化操作
轻松安装
使用 Python 3.x
pip3 install -U wxpy
简单上手
登陆微信:
# 导入模块 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')
自动响应各类消息:
# 打印来自其他好友、群聊和公众号的消息 @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) # 堵塞线程,并进入 Python 命令行 embed() # 或者仅仅堵塞线程 # bot.join()
模块特色
说明文档
项目主页
https://github.com/youfou/wxpy
加入微信交流群 (真的是群哦)
扫描以下二维码,填写验证信息 [ wxpy ],即可自动受邀入群
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wxpy-0.3.2.tar.gz
(30.5 kB
view hashes)