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
|
from random import choice
from nonebot.matcher import Matcher
from nonebot.params import CommandArg, ArgPlainText
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, Message
from nonebot.adapters.onebot.v11.helpers import Cooldown
from ATRI.service import Service
from ATRI.message import MessageBuilder
_repo_flmt_notice = choice(["慢...慢一..点❤", "冷静1下", "歇会歇会~~"])
_REPO_FORMAT = (
MessageBuilder("来自用户{user}反馈:")
.text("{msg}")
.text("- 如有类似 CQ 一类关键词出现")
.text("- 无需担心, 关注其它内容即可")
.done()
)
_REPO_FORMAT = MessageBuilder("来自用户{user}反馈:").text("{msg}").done()
plugin = Service("反馈").document("向维护者发送消息")
reporter = plugin.on_command("来杯红茶", "向维护者发送消息", aliases={"反馈", "报告"})
@reporter.handle([Cooldown(120, prompt=_repo_flmt_notice)])
async def _ready_repo(matcher: Matcher, args: Message = CommandArg()):
msg = args.extract_plain_text()
if msg:
matcher.set_arg("repo", args)
@reporter.got("repo", "需要反馈的内容呢?~")
async def _deal_repo(
bot: Bot,
event: MessageEvent,
repo_msg: str = ArgPlainText("repo"),
):
user_id = event.get_user_id()
repo_0 = _REPO_FORMAT.format(user=user_id, msg=repo_msg)
try:
await plugin.send_to_master(repo_0)
except Exception:
await reporter.finish("发送失败了呢...")
await reporter.finish("吾辈的心愿已由咱转告维护者!")
|