QQ 频道 API 的 Python Wrapper
Project description
主要特点
- 使用
async和await的现代 Pythonic API。 - 优化速度和内存。
安装
需要 Python 3.8或以上的版本 和一根接入互联网的网线。
要安装库,你只需运行以下命令:
pip3 install -U qq.py
快速示例
from qq import *
class MyClient(Client):
async def on_ready(self):
print('使用', self.user, '登陆')
async def on_message(self, message):
# 不要回复自己
if message.author == self.user:
return
if 'ping' in message.content:
await message.channel.send('pong')
if __name__ == '__main__':
client = MyClient()
client.run(token='app_id.token')
Bot 示例
import qq
from qq.ext import commands
bot = commands.Bot(command_prefix='>', owner_id='你的用户ID') # owner_id 是 int 类型
@bot.event
async def on_ready():
print(f'以 {bot.user} 身份登录(ID:{bot.user.id})')
print('------')
@bot.command()
async def ping(ctx):
await ctx.send('pong')
bot.run('app_id.token')
你可以在 example 目录中找到更多示例。
链接
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
qq.py-1.3.22.tar.gz
(193.5 kB
view details)
File details
Details for the file qq.py-1.3.22.tar.gz.
File metadata
- Download URL: qq.py-1.3.22.tar.gz
- Upload date:
- Size: 193.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ce6c6a8a494ede01ab2b7fdf20b7f638bffe7703aa8869f7eb1f62b8751339e
|
|
| MD5 |
220ca4d54fb6760dc6b739112af667d2
|
|
| BLAKE2b-256 |
27a21780ecfca5c865ff04b7c4a8d797051aea1814936342c0272cd4cb170fed
|