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
|
from random import choice
from nonebot.plugin import on_command
from nonebot.adapters.cqhttp import Bot
from ATRI.request import Request
from ATRI.utils import count_list, del_list_aim
from ATRI.config import CURSE_CONFIG
from ATRI.exceptions import InvalidRequest
from ATRI.service.plugin import Plugin
from ATRI.rule import is_in_ban_list, is_in_service, is_in_dormant, to_bot
# ===========================[Begin Command Processing]===========================
__plugin_name__ = 'curse'
__doc__ = """口臭一下"""
Plugin.register(__plugin_name__, "func", __doc__,
CURSE_CONFIG['curse']['command'])
curse = on_command(CURSE_CONFIG['curse']['command'][0],
aliases=set(CURSE_CONFIG['curse']['command']),
rule=is_in_ban_list() & is_in_dormant()
& is_in_service(__plugin_name__)
& to_bot())
@curse.handle()
async def _(bot: Bot, event) -> None:
await bot.send(
event, await Function().curse(str(event.get_user_id())))
# ===========================[End Command Processing]=============================
curse_list = []
class Function:
async def curse(self, user: str):
global curse_list
if count_list(curse_list, user) == 3:
curse_list.append(user)
return choice(CURSE_CONFIG['curse']['times'][3]['repo'])
elif count_list(curse_list, user) == 6:
curse_list = del_list_aim(curse_list, user)
return choice(CURSE_CONFIG['curse']['times'][6]['repo'])
else:
try:
curse_list.append(user)
return str(await Request.get_text(
url=CURSE_CONFIG['curse']['url']))
except InvalidRequest:
raise InvalidRequest('请求失败')
|