Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ymbotpy

ymbotpy 是基于 机器人开放平台API https://bot.q.qq.com/wiki/develop/api/ 实现的机器人框架,目的提供一个易使用、开发效率高的开发框架,同时支持Webhook和WebSocket,非Tencent官方SDK,但用法完全相同。

特性

  • 兼容 Python 3.7+
  • 简单、易用、快速集成,过滤垃圾消息以及消息鉴权
  • 同时支持Webhook和WebSocket,可无缝替换websocket版本qq-botpy

安装

pip install ymbotpy

注意: Webhook由于通信方式的变化, 不再需要在本地注册监听事件,只需要编写具体的事件代码即可,事件开关在平台控制

Webhook 快速上手

  1. 频道内@自动回复

    import ymbotpy
    from ymbotpy.message import Message
    
    class MyClient(ymbotpy.WebHookClient):
        async def on_at_message_create(self, message: Message):
            """频道内@"""
            await message.reply(content=f"机器人{self.robot.name}收到你的@消息了: {message.content}")
    
    if __name__ == "__main__":
        client = MyClient()
        # 启用沙盒模式
        # client = MyClient(is_sandbox=True)
        client.run(appid='botid',secret='secert',port=8080,system_log=True)
    
  2. 在开发平台应配置的回调地址为:example.com/qbot/webhook,您可以通过以下方式来修改回调URL自定义webhook的url

    client.run(appid=BOT_APPID,secret=BOT_SECRET,port=8080,system_log=True,hook_route='/your_url')
    
  3. 配置SSL以直接实现域名直接访问

    client.run(appid=BOT_APPID,secret=BOT_SECRET,port=443,system_log=True,
        ssl_keyfile='ssl/private.key',ssl_certfile='ssl/public.crt')
    

WebSocket 快速上手(更多用法请参考官方文档)

  1. 频道内@自动回复
    import ymbotpy
    from ymbotpy.message import Message
    
    class MyClient(ymbotpy.Client):
        async def on_at_message_create(self, message: Message):
            """频道内@"""
            await message.reply(content=f"机器人{self.robot.name}收到你的@消息了: {message.content}")
    
    if __name__ == "__main__":
        intents = ymbotpy.Intents(public_guild_messages=True) 
        client = MyClient(intents=intents)
        # 启用沙盒模式
        # client = MyClient(intents=intents, is_sandbox=True)
        client.run(appid='botid', secret='secert')
    

文档

有关此 SDK 更多用法,请查阅qq-botpy https://github.com/tencent-connect/botpy

欢迎访问镜芯科技

  1. 天狼星框架:https://www.siriusbot.cn/
  2. 镜芯API:https://api2.wer.plus/
  3. 林枫云_站长首选云服务器:https://www.dkdun.cn/

Metadata

Release files for ymbotpy 1.1.0.dev0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ymbotpy 1.1.0.dev0
File Size Uploaded Provenance Actions
ymbotpy-1.1.0.dev0.tar.gz 43.4 kB Without provenance Details for ymbotpy-1.1.0.dev0.tar.gz

Release files / ymbotpy-1.1.0.dev0.tar.gz

Download URL ymbotpy-1.1.0.dev0.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
31ac735e279d7c07a01bd9dd3bc3794dca17016705ed525847e65880f1576495
BLAKE2b-256 checksum
How to use checksums
38d3a5640c74fbf166795ef4130425e5226e94ab92b2fa83142770b9fce8ed91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for ymbotpy 1.1.0.dev0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page