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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
import json
import re
import asyncio
from pathlib import Path
from random import choice, randint
from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent
from nonebot.adapters.cqhttp.message import Message, MessageSegment
from ATRI.service import Service as sv
from ATRI.utils.limit import is_too_exciting
from ATRI.rule import is_in_service
from ATRI.utils.request import post_bytes
from ATRI.utils.translate import to_simple_string
from ATRI.exceptions import RequestError
__doc__ = """
看不懂的笑话
权限组:所有人
用法:
来句笑话
"""
get_laugh = sv.on_command(cmd="来句笑话", docs=__doc__, rule=is_in_service("来句笑话"))
@get_laugh.handle()
async def _get_laugh(bot: Bot, event: MessageEvent) -> None:
user_name = event.sender.nickname
laugh_list = []
FILE = Path(".") / "ATRI" / "data" / "database" / "funny" / "laugh.txt"
with open(FILE, "r", encoding="utf-8") as r:
for line in r:
laugh_list.append(line.strip("\n"))
result = choice(laugh_list)
await get_laugh.finish(result.replace("%name", user_name))
me_to_you = sv.on_message(priority=5)
@me_to_you.handle()
async def _me_to_you(bot: Bot, event: MessageEvent) -> None:
if randint(0, 15) == 5:
msg = str(event.message)
if "我" in msg and "CQ" not in msg:
await me_to_you.finish(msg.replace("我", "你"))
__doc__ = """
伪造转发
权限组:所有人
用法:
/fakemsg qq*name*msg...
补充:
qq: QQ号
name: 消息中的ID
msg: 对应信息
示例:
/fakemsg 123456789*生草人*草 114514*仙贝*臭死了
"""
fake_msg = sv.on_command(cmd="/fakemsg", docs=__doc__, rule=is_in_service("fakemsg"))
@fake_msg.handle()
async def _fake_msg(bot: Bot, event: GroupMessageEvent) -> None:
msg = str(event.message).split(" ")
user = event.user_id
group = event.group_id
node = list()
check = is_too_exciting(user, 1, seconds=600)
if check:
for i in msg:
args = i.split("*")
qq = args[0]
name = args[1].replace("[", "[")
name = name.replace("]", "]")
repo = args[2].replace("[", "[")
repo = repo.replace("]", "]")
dic = {"type": "node", "data": {"name": name, "uin": qq, "content": repo}}
node.append(dic)
await bot.send_group_forward_msg(group_id=group, messages=node)
EAT_URL = "https://wtf.hiigara.net/api/run/{}"
eat_wat = sv.on_regex(r"[今|明|后|大后]天(.*?)吃什么", rule=is_in_service("今天吃什么"))
@eat_wat.handle()
async def _eat(bot: Bot, event: MessageEvent) -> None:
msg = str(event.message).strip()
user = event.user_id
user_n = event.sender.nickname
arg = re.findall(r"[今|明|后|大后]天(.*?)吃什么", msg)[0]
nd = re.match(r"[今|明|后|大后][天]", msg)[0]
if arg == "中午":
a = f"LdS4K6/{randint(0, 999999)}"
url = EAT_URL.format(a)
params = {"event": "ManualRun"}
try:
data = json.loads(await post_bytes(url, params))
except RequestError:
raise RequestError("Request failed!")
text = to_simple_string(data["text"]).replace("今天", nd)
get_a = re.search(r"非常(.*?)的", text)[0]
result = f"> {MessageSegment.at(user)}\n" + text.replace(get_a, "")
elif arg == "晚上":
a = f"KaTMS/{randint(0, 999999)}"
url = EAT_URL.format(a)
params = {"event": "ManualRun"}
try:
data = json.loads(await post_bytes(url, params))
except RequestError:
raise RequestError("Request failed!")
text = to_simple_string(data["text"]).replace("今天", "")
result = f"> {MessageSegment.at(user)}\n" + text
else:
rd = randint(1, 10)
if rd == 5:
result = "吃我吧 ❤"
else:
a = f"JJr1hJ/{randint(0, 999999)}"
url = EAT_URL.format(a)
params = {"event": "ManualRun"}
try:
data = json.loads(await post_bytes(url, params))
except RequestError:
raise RequestError("Request failed!")
text = to_simple_string(data["text"]).replace("今天", nd)
get_a = re.match(r"(.*?)的智商", text)[0]
result = f"> {MessageSegment.at(user)}\n" + text.replace(
get_a, f"{user_n}的智商"
)
await eat_wat.finish(Message(result))
|