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
84
85
86
87
88
89
90
91
92
93
94
|
import re
from random import choice, random
from nonebot.matcher import Matcher
from nonebot.params import CommandArg, ArgPlainText
from nonebot.adapters.onebot.v11 import Message
from nonebot.adapters.onebot.v11.helpers import Cooldown
from ATRI.service import Service
from .data_source import Encrypt, Yinglish, roll_dice
plugin = Service("小工具").document("非常实用(?)的工具们!")
roll = plugin.on_command("/roll", "骰子~用法: 1d10 或 2d10+2d10+more")
@roll.handle()
async def _ready_roll(matcher: Matcher, args: Message = CommandArg()):
msg = args.extract_plain_text()
if msg:
matcher.set_arg("roll", args)
@roll.got("roll", "参数呢?! 格式: 1d10 或 2d10+2d10+more")
async def _deal_roll(roll_msg: str = ArgPlainText("roll")):
match = re.match(r"^([\dd+\s]+?)$", roll_msg)
if not match:
await roll.finish("阿——! 参数不对! 格式: 1d10 或 2d10+2d10+more")
msg = roll_dice(roll_msg)
await roll.finish(msg)
encrypt_en = plugin.on_command("加密", "我们之间的秘密❤")
@encrypt_en.handle()
async def _ready_en(matcher: Matcher, args: Message = CommandArg()):
msg = args.extract_plain_text()
if msg:
matcher.set_arg("encr_en_text", args)
@encrypt_en.got("encr_en_text", "内容呢?!")
async def _deal_en(text: str = ArgPlainText("encr_en_text")):
is_ok = len(text)
if is_ok < 10:
await encrypt_en.reject("太短不加密!")
en = Encrypt()
result = en.encode(text)
await encrypt_en.finish(result)
encrypt_de = plugin.on_command("解密", "解开我们的秘密❤")
@encrypt_de.handle()
async def _ready_de(matcher: Matcher, args: Message = CommandArg()):
msg = args.extract_plain_text()
if msg:
matcher.set_arg("encr_de_text", args)
@encrypt_de.got("encr_de_text", "内容呢?!")
async def _deal_de(text: str = ArgPlainText("encr_de_text")):
en = Encrypt()
result = en.decode(text)
await encrypt_de.finish(result)
sepi = plugin.on_command("涩批一下", "将正常的句子涩一涩~")
_sepi_flmt_notice = choice(["涩批爬", "✌🥵✌"])
@sepi.handle([Cooldown(3, prompt=_sepi_flmt_notice)])
async def _ready_sepi(matcher: Matcher, args: Message = CommandArg()):
msg = args.extract_plain_text()
if msg:
matcher.set_arg("sepi_text", args)
@sepi.got("sepi_text", "内容呢?!")
async def _deal_sepi(msg: str = ArgPlainText("sepi_text")):
if len(msg) < 4:
await sepi.finish("这么短?涩不起来!")
result = Yinglish(msg).deal(random())
await sepi.finish(result)
|