Skittles
Warning: 本项目仍处于开发阶段,API 可能会有较大变动。
mirai-api-http Mock 测试工具。
可以简单地将协议分为 事件(收到好友消息、收到群消息)和 命令(发送好友消息、发送群消息)两个部分。 对于客户端来说,做的事情是 ”接收事件、发送命令“,那么对于 服务端(Mock 工具)来说,做的事情就是 ”接收命令、发送事件“。
实现的功能
- 正向 Websocket
用法
pip install skittles
import asyncio
import time
import logging
import typing
logging.basicConfig(level=logging.DEBUG)
from skittles.platform import mirai
from skittles.entity import bot, connection
bot_account = bot.Bot(
account_id='12345678',
nickname='bot',
connection_types=[connection.ConnectionType.FORWARD_WS]
) # 建立假账号,目前仅支持 websocket
mahadapter = mirai.MiraiAPIHTTPAdapter()
@mahadapter.action_handler # 注册命令处理器
async def handler(bot: bot.Bot, connection_type: connection.ConnectionType, data: dict) -> typing.Any:
print(bot, connection_type, data)
asyncio.run(mahadapter.run(bots=[bot_account]))
# 发送事件
data = {
"type": "FriendMessage",
"sender": {"id": 1010553892, "nickname": "Rock", "remark": ""},
"messageChain": [
{"type": "Source", "id": 123456, "time": int(time.time())},
{"type": "Plain", "text": "你好"},
],
}
await mahadapter.emit_event(bots=[bot_account], event=data)
await mahadapter.kill() # 断开连接、关闭服务
Metadata
Release files for skittles 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| skittles-0.1.1.tar.gz | 19.1 kB | Without provenance | Details for skittles-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| skittles-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for skittles-0.1.1-py3-none-any.whl |
Total release size: 38.7 kB
Release files / skittles-0.1.1.tar.gz
| Download URL | skittles-0.1.1.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f66282052509c87d4705f42172b845369abd16fb3d812bd635c34d74c3b50dc
|
|
BLAKE2b-256 checksum How to use checksums |
e95cd9af2dc64ef063928e2c87de9be5e5c65bfe237a73231d514f5b66a3045e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Release files / skittles-0.1.1-py3-none-any.whl
| Download URL | skittles-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71f4d939c6de597343eb5cf51c19b3d2aa9cb09f8f2572a4d2eeb278451d891c
|
|
BLAKE2b-256 checksum How to use checksums |
1cd98d33fcde1d925da943582cd337e1fcd7a2d23c08ca4b201a9d9a96b6df47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Security for skittles 0.1.1
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.