-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f61ffc
commit 200fc83
Showing
6 changed files
with
751 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
Oops, something went wrong.