微信个人号 API,基于 itchat,告别满屏 dict,更有 Python 范儿
Project description
微信个人号 API,基于 itchat,全面优化接口,更有 Python 范儿
入门
登陆微信:
# 导入模块 from wxpy import * # 初始化机器人,扫码登陆 robot = Robot()
找到好友:
# 搜索名称含有 "游否" 的男性深圳好友 my_friend = robot.friends().search('游否', sex=MALE, city="深圳")[0]
发送消息:
# 发送文本给好友 robot.my_friend.send('Hello WeChat!') # 发送图片 robot.my_friend.send_image('my_picture.jpg')
自动响应各类消息:
# 打印来自其他好友、群聊和公众号的消息 @robot.register() def print_others(msg): print(msg) # 回复 my_friend 的消息 (优先匹配后注册的函数!) @robot.register(my_friend) def reply_my_friend(msg): return 'received: {} ({})'.format(msg.text, msg.type) # 开始监听和自动处理消息 robot.start()
安装
使用 Python 3.x
pip3 install -U wxpy
讨论
GitHub: https://github.com/youfou/wxpy
加入QQ群: 593325850
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.0.7.tar.gz
(15.9 kB
view details)
File details
Details for the file wxpy-0.0.7.tar.gz
.
File metadata
- Download URL: wxpy-0.0.7.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c7ae989cb2e3f6cbc106231c4e0f01e5886b8d81fa1b7da038f27c820fa839 |
|
MD5 | 0ca9073256ed3d6512263ebb685d0ba0 |
|
BLAKE2b-256 | bf6f249af758cd94e5f09b26fcb40b457a7ce3ae8cbb361738ab01ddb48eba02 |