summaryrefslogtreecommitdiff
path: root/ATRI/plugins/funny.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/funny.py')
-rw-r--r--ATRI/plugins/funny.py83
1 files changed, 37 insertions, 46 deletions
diff --git a/ATRI/plugins/funny.py b/ATRI/plugins/funny.py
index 39b9f28..574aaa1 100644
--- a/ATRI/plugins/funny.py
+++ b/ATRI/plugins/funny.py
@@ -22,28 +22,26 @@ __doc__ = """
来句笑话
"""
-get_laugh = sv.on_command(
- cmd='来句笑话',
- docs=__doc__,
- rule=is_in_service('来句笑话')
-)
+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:
+
+ 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'))
-
+ 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:
@@ -65,43 +63,34 @@ __doc__ = """
/fakemsg 123456789*生草人*草 114514*仙贝*臭死了
"""
-fake_msg = sv.on_command(
- cmd="/fakemsg",
- docs=__doc__,
- rule=is_in_service('fakemsg')
-)
+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(' ')
+ 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('*')
+ 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
- }
- }
+ 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 = sv.on_regex(r"[今|明|后|大后]天(.*?)吃什么", rule=is_in_service("今天吃什么"))
+
@eat_wat.handle()
async def _eat(bot: Bot, event: MessageEvent) -> None:
@@ -110,7 +99,7 @@ async def _eat(bot: Bot, event: MessageEvent) -> None:
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)
@@ -118,12 +107,12 @@ async def _eat(bot: Bot, event: MessageEvent) -> None:
try:
data = json.loads(await post_bytes(url, params))
except RequestError:
- raise RequestError('Request failed!')
-
- text = to_simple_string(data['text']).replace('今天', nd)
+ 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, '')
-
+ result = f"> {MessageSegment.at(user)}\n" + text.replace(get_a, "")
+
elif arg == "晚上":
a = f"KaTMS/{randint(0, 999999)}"
url = EAT_URL.format(a)
@@ -131,11 +120,11 @@ async def _eat(bot: Bot, event: MessageEvent) -> None:
try:
data = json.loads(await post_bytes(url, params))
except RequestError:
- raise RequestError('Request failed!')
-
- text = to_simple_string(data['text']).replace('今天', '')
+ 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:
@@ -147,10 +136,12 @@ async def _eat(bot: Bot, event: MessageEvent) -> None:
try:
data = json.loads(await post_bytes(url, params))
except RequestError:
- raise RequestError('Request failed!')
-
- text = to_simple_string(data['text']).replace('今天', nd)
+ 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}的智商')
-
+ result = f"> {MessageSegment.at(user)}\n" + text.replace(
+ get_a, f"{user_n}的智商"
+ )
+
await eat_wat.finish(Message(result))