Skip to content

Commit

Permalink
🎉 初次提交
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibuxiangx committed Nov 26, 2024
1 parent 1f61ffc commit 200fc83
Show file tree
Hide file tree
Showing 6 changed files with 751 additions and 0 deletions.
Binary file added BUDDIES.silk
Binary file not shown.
26 changes: 26 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# src/main.py
from cocotst.app import Cocotst
from cocotst.network.model import WebHookConfig
from creart import it
from graia.saya import Saya
from graia.saya.builtins.broadcast import BroadcastBehaviour

app = Cocotst(
appid="", # 你的 APPID
clientSecret="", # 你的 ClientSecret
webhook_config=WebHookConfig(host="127.0.0.1", port=2099), # 你的 WebHook 配置
is_sand_box=True,
)

# 创建 Saya 实例
saya = it(Saya)
# 安装 BroadcastBehaviour
saya.install_behaviours(BroadcastBehaviour(broadcast=app.broadcast))

# 使用 Saya 的模块上下文管理器加载插件
with saya.module_context():
# 加载插件
saya.require("module.ping")

if __name__ == "__main__":
app.launch_blocking()
10 changes: 10 additions & 0 deletions module/ping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from cocotst.event.message import GroupMessage
from cocotst.message.parser.base import QCommandMatcher
from cocotst.network.model import Target
from cocotst.app import Cocotst
from graia.saya.builtins.broadcast.shortcut import listen, decorate

@listen(GroupMessage)
@decorate(QCommandMatcher("ping"))
async def hello_listener(app: Cocotst, target: Target):
await app.send_group_message(target, content="pong!")
11 changes: 11 additions & 0 deletions module/voice/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from cocotst.event.message import GroupMessage
from cocotst.message.parser.base import QCommandMatcher
from cocotst.network.model import Target
from cocotst.app import Cocotst
from cocotst.message.element import Voice
from graia.saya.builtins.broadcast.shortcut import listen, decorate

@listen(GroupMessage)
@decorate(QCommandMatcher("music"))
async def hello_listener(app: Cocotst, target: Target):
await app.send_group_message(target, element=Voice(path="./BUDDIES.silk"))
Loading

0 comments on commit 200fc83

Please sign in to comment.