QQBot Messaging Framework
Paste the following prompt into your AI chat to install this skill:
Please install @user_e7c8a23d/qqbot-messaging into your AI assistant using https://skillhub.cn/install/skillhub.md.
About this skill
What Problem It Solves
Building a QQ bot often gets stuck less on raw API calls and more on the differences between guild @-mentions, C2C private messages, and group @-mentions. Each path has its own Intent, event handler, message type, reply method, and user identifier. For example, guild messages require public_guild_messages=True, while C2C and group messages share public_messages=True but still use different send methods and ID fields. Adding scheduled pushes makes the failure surface larger: asyncio task setup, event-loop initialization, and short-lived msg_id values can all break the message flow.
How The Skill Works
The skill organizes qq-botpy into a practical messaging pattern for three core cases:
- Guild @-messages: handle
on_at_message_create(message: Message), reply withmessage.reply(content="..."), and send proactively withself.api.post_message(channel_id=..., content=..., msg_id=message.id). The user identifier ismessage.author.id. - C2C private messages: handle
on_c2c_message_create(message: C2CMessage), reply withmessage._api.post_c2c_message(openid=..., msg_type=0, msg_id=message.id, content=...), and usemessage.author.user_openidfor the recipient. - Group @-messages: handle
on_group_at_message_create(message: GroupMessage), reply withmessage._api.post_group_message(group_openid=..., msg_type=0, msg_id=message.id, content=...), and usemessage.author.member_openidplusmessage.group_openid.
It also includes a scheduled-push pattern using asyncio.create_task(), await asyncio.sleep(seconds), and try/except asyncio.CancelledError so background jobs can exit cleanly. For command-style messages, prefix parsing needs to happen before argument extraction.
Boundaries And Caveats
- Intents are mandatory: missing
public_guild_messages=Trueorpublic_messages=Truemeans messages will not arrive. - Reply IDs expire: passive replies rely on a recent
msg_id; scheduled sends may need proactive-message permissions or a freshmsg_idfrom a newer incoming message. - Event loops matter on Python 3.10+: if you see
RuntimeError: There is no current event loop, explicitly create and set the loop before starting the bot.
Use Cases
- Implement guild @-commands in a QQ channel by parsing the message prefix and replying via reply or post_message.
- Handle C2C private-chat events, identify the user by open_id, and send responses with post_c2c_message.
- Process group @-mentions by using member_openid and group_openid to send group replies.
- Run scheduled pushes as an asyncio background task and stop it cleanly with CancelledError.
Best For
- Python backend engineers maintaining QQ guild bots who need to route @-messages into command handlers.
- Developers building support or notification bots who need stable C2C private-chat replies.
- Engineers managing QQ group notifications who need to identify group @-mentions and send group-level responses.
- Service developers using asyncio background jobs who need scheduled pushes with clean cancellation.
Related Skills
Explains how to calculate N+1 severance, including service-year rounding, monthly wage base, caps, taxes, and notice pay.
Takes a name input and returns a simple hello greeting.
A BPU quantization tool for Horizon RDK S100 that handles PyTorch/ONNX calibration, stride alignment, post-processing, and board-side validation.
A zero-dependency Python CLI toolkit with 49 utilities for data conversion, text, images, PDF, video, and developer debugging.