Skip to main content

微信个人号 API,基于 itchat,告别满屏 dict,更具 Python 范儿

Project description

微信个人号 API,基于 itchat,告别满屏 dict,更具 Python 范儿

安装

pip3 install -U wxpy

Python 3.x

使用

示例代码

# 导入所需的组件,也可直接 from wxpy import *
from wxpy import Robot, Friend, Group, MALE, TEXT

# 初始化机器人,并登陆
robot = Robot()

# 搜索名称含有 "游否" 的男性深圳好友
my_friend = robot.friends.search('游否', sex=MALE, city="深圳")[0]

# 打印其他好友或群聊的文本消息 (装饰器语法,放在函数 def 的前一行即可)
@robot.msg_register([Friend, Group], TEXT)
def reply_others(msg):
    print(msg)

# 回复 my_friend 的所有消息 (后注册的匹配优先级更高)
@robot.msg_register(my_friend)
def reply_my_friend(msg):
    return 'received: {} ({})'.format(msg.text, msg.type)

# 开始监听和处理消息
robot.run()

目前暂无正式说明文档更多的 API 使用说明请查看源码中的各
docstring

关于

ItChat 是目前 GitHub 上唯一功能完善,且支持 Python 3.x 的微信个人号 API 模块,不过其大量使用 dict 进行数据传递,多少有些不方便。因此心血来潮通过继承重载的方式将 itchat 的接口层进行了全面的优化,相信通过本次优化,在调用接口的使用体验上会有一定的提升。

wxpy 仅仅是基于 itchat 的接口优化,网络数据等相对底层的工作仍然由 itchat 完成。

Project details


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.1.tar.gz (13.5 kB view details)

Uploaded Source

File details

Details for the file wxpy-0.0.1.tar.gz.

File metadata

  • Download URL: wxpy-0.0.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wxpy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4f396afebf1873a66aad321b88f2467631bcbb1efb3a60184bbd590a38b5ba51
MD5 2b06dd9229d7e40c61755a6ea88530b0
BLAKE2b-256 645dfb19944ea708b697c620cc166aedce100191ad0fa8792fd00b7fd25a67f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page