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.2.12.tar.gz
(186.0 kB
view details)
File details
Details for the file qq.py-1.2.12.tar.gz.
File metadata
- Download URL: qq.py-1.2.12.tar.gz
- Upload date:
- Size: 186.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd22deb1363d760f5dd01dfb7d5f5ecfbe233c240f1896ef9bc2b493e21565ca
|
|
| MD5 |
bd115f2808d69abde495c1dcdb9cb699
|
|
| BLAKE2b-256 |
2df381f148d558abd366f1deb3d42b948b8dea47248313834b6daea739adde7f
|