-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
83 lines (66 loc) · 2.6 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from loguru import logger
from graia.saya import Saya
from graia.ariadne.app import Ariadne
from prompt_toolkit.styles import Style
from graia.ariadne.console import Console
from graia.scheduler import GraiaScheduler
from prompt_toolkit.formatted_text import HTML
from graia.broadcast.interrupt import InterruptControl
from graia.ariadne.console.saya import ConsoleBehaviour
from graia.scheduler.saya import GraiaSchedulerBehaviour
from graia.saya.builtins.broadcast import BroadcastBehaviour
from graia.ariadne.entry import config, HttpClientConfig, WebsocketClientConfig
import asyncio
import contextlib
from libs.config import BotConfig
# Initializing bot
host = BotConfig.Mirai.mirai_host
app = Ariadne(
config(
BotConfig.Mirai.account,
BotConfig.Mirai.verify_key,
HttpClientConfig(host),
WebsocketClientConfig(host)
),
)
console = Console(
broadcast=app.broadcast,
prompt=HTML("<bbbot> BBbot </bbbot>> "),
style=Style(
[
("bbbot", "fg:#ffffff"),
]
),
)
app.create(GraiaScheduler)
saya = app.create(Saya)
saya.install_behaviours(
app.create(BroadcastBehaviour),
app.create(GraiaSchedulerBehaviour),
ConsoleBehaviour(console),
app.create(InterruptControl),
)
with saya.module_context():
saya.require("libs.function.command.announcement")
saya.require("libs.function.command.function_off")
saya.require("libs.function.command.function_on")
# saya.require("libs.function.event.bot_launch")
saya.require("libs.function.usr_cmd.member_permission_test")
saya.require("libs.function.usr_cmd.group_permission_test")
saya.require("libs.function.event.repeater")
saya.require("libs.function.event.sample_player")
saya.require("libs.function.event.no_du")
saya.require("libs.function.usr_cmd.fashenme.fashenme")
saya.require("libs.function.usr_cmd.fashenme.fashenme_add")
saya.require("libs.function.usr_cmd.fashenme.fashenme_x10")
# saya.require("libs.function.usr_cmd.fashenme.fashenme_remove")
# saya.require("libs.function.usr_cmd.fashenme.fashenme_too_long")
saya.require("libs.function.usr_cmd.play.play_chinese_number_notation")
saya.require("libs.function.usr_cmd.play.play_abc_notation")
saya.require("libs.function.usr_cmd.play.random_taffy")
saya.require("libs.function.usr_cmd.solidot")
saya.require("libs.function.usr_cmd.jijin")
saya.require("libs.function.usr_cmd.smzdm.smzdm")
with contextlib.suppress(KeyboardInterrupt, asyncio.exceptions.CancelledError):
app.launch_blocking()
logger.info("BBbot is shutting down...")