Skip to main content

Saaya is a Python framework based on Mirai

Project description

Saaya Framework on Mirai

目前最新版本为: 2.0.1 dev

Saaya 以迁移至 mirai-api-http v2,下载时请注意版本

此框架目前正在开发中,请暂时使用 PyCharm 以获得较好的代码内文档体验

Saaya 是一个为了与群内 cdd 对抗而开发的基于 mirai-api-http 的轻量机器人框架,使用语言为 Python

快速开始

Saaya 基于 mirai-api-http ,因此你的第一步应该是安装服务端,这里推荐使用 MCL

服务端部署

  1. 参见 MCL 提供的教程,安装服务端程序,并运行一次生成对应文件
  2. 参考 mirai-api-http ,安装对应的插件
  3. 运行一次 MCL 并关闭,修改配置文件,配置 qq 自动登录并打开 mirai-api-httpwebsocket 选项

你的第一个应用

编写主函数 main.py

from saaya.session import Bot
from private import address, verifyKey, botqq

if __name__ == '__main__':
    bot = Bot(address, verifyKey)  # 创建一个 Bot 实例
    bot.bind(botqq)  # 登陆 Bot (注意:需要主程序已登陆对应 qq)

    bot.registerPlugins([
        # 'plugins.turing.main',
        'plugins.base.reply'
    ])  # 插件注册,规范如上

    bot.loop()  # 开始监听事件循环

插件规范

在上一步中,我们注册了一个名为 plugins.base.reply 的插件,在 BrickBot 中,插件以目录的最深层为终点,也就是说明这个插件的路径应该是 plugins/base/reply.py,如下便是一个最简单的插件

from saaya.utils import PluginManager
from saaya.event import GroupMessage
from private import test_groups


@PluginManager.registerEvent('GroupMessage')
async def hello(event: GroupMessage):
    if event.group.uid in test_groups:
        if event.message.getContent() == 'ping':
            event.group.sendMessage('pong')

Hello world

将插件放置到相应的目录,并运行 main.py

img.png

可以看到插件已经成功加载,并且机器人回复了你 pong

鸣谢

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saaya-2.0.1.macosx-10.14-arm64.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

saaya-2.0.1-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file saaya-2.0.1.macosx-10.14-arm64.tar.gz.

File metadata

  • Download URL: saaya-2.0.1.macosx-10.14-arm64.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for saaya-2.0.1.macosx-10.14-arm64.tar.gz
Algorithm Hash digest
SHA256 f6ec8bb30d2cf4726d755cdcb4cf451c4ed07b0a334743bde7c09a4f73ebc579
MD5 d6dad46b5bf17ccc0033636591f9c94d
BLAKE2b-256 675863feba6dce3244631f955cffe080ab89b1180010def9b2766192db5acd71

See more details on using hashes here.

File details

Details for the file saaya-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: saaya-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for saaya-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1465df4160de566734cf2ca690a22441d931d37e4f50eaf8c5c50a5175e2ea1
MD5 8475a9c054f40e4ddbc06dfbff020038
BLAKE2b-256 709df3199388e07f0b897f7a64835d1f6150ce361234ea73b6efcb80fc1d243c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page