2021-11-28 14:55:10 +00:00
|
|
|
|
import re
|
|
|
|
|
import secrets
|
|
|
|
|
from typing import List
|
2021-12-08 09:10:31 +00:00
|
|
|
|
from init import bot
|
2021-11-28 14:55:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def how_many(message: str) -> str:
|
|
|
|
|
while re.findall("几|多少", message):
|
2022-07-25 09:35:54 +00:00
|
|
|
|
message = message.replace("几", str(secrets.choice(range(99))), 1)
|
|
|
|
|
message = message.replace("多少", str(secrets.choice(range(99))), 1)
|
2021-11-28 14:55:10 +00:00
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def what_time(message: str) -> str:
|
|
|
|
|
time = ["早上", "中午", "晚上", "今天", "明天", "下周", "下个月", "明年"]
|
|
|
|
|
while re.findall("什么时候|啥时候", message):
|
|
|
|
|
message = message.replace("什么时候", secrets.choice(time), 1)
|
|
|
|
|
message = message.replace("啥时候", secrets.choice(time), 1)
|
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def how_long(message: str) -> str:
|
|
|
|
|
unit = ["秒", "小时", "天", "周", "月", "年", "世纪"]
|
|
|
|
|
while re.findall("多久|多长时间", message):
|
2023-01-12 13:19:54 +00:00
|
|
|
|
message = message.replace(
|
|
|
|
|
"多久", str(secrets.choice(range(99))) + secrets.choice(unit), 1
|
|
|
|
|
)
|
|
|
|
|
message = message.replace(
|
|
|
|
|
"多长时间", str(secrets.choice(range(99))) + secrets.choice(unit), 1
|
|
|
|
|
)
|
2021-11-28 14:55:10 +00:00
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def hif(message: str) -> str:
|
|
|
|
|
keyword = list(set(re.findall(r"(.)不\1", message)))
|
|
|
|
|
for k in keyword:
|
|
|
|
|
k = f"{k}不{k}"
|
|
|
|
|
if secrets.choice([True, False]):
|
|
|
|
|
message = message.replace(k, k[:1])
|
|
|
|
|
else:
|
|
|
|
|
message = message.replace(k, k[1:])
|
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def who(message: str, group_id: int) -> str:
|
|
|
|
|
group_member_list = await bot.get_chat_member(group_id)
|
2022-07-25 09:35:54 +00:00
|
|
|
|
member_list: List[str] = [n.first_name for n in group_member_list]
|
2021-11-28 14:55:10 +00:00
|
|
|
|
while "谁" in message:
|
2022-07-25 09:35:54 +00:00
|
|
|
|
member_name = member_list[secrets.choice(range(len(member_list) - 1))]
|
2021-11-28 14:55:10 +00:00
|
|
|
|
message = message.replace("谁", member_name, 1)
|
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def handle_pers(message: str) -> str:
|
|
|
|
|
message_list = list(message)
|
2022-07-25 09:35:54 +00:00
|
|
|
|
for i in range(len(message_list)):
|
2021-11-28 14:55:10 +00:00
|
|
|
|
if message_list[i] == "我":
|
|
|
|
|
message_list[i] = "你"
|
|
|
|
|
continue
|
|
|
|
|
if message[i] == "你":
|
|
|
|
|
message_list[i] = "我"
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
message = "".join(message_list)
|
|
|
|
|
|
|
|
|
|
message = message.replace("bot", "我")
|
|
|
|
|
message = message.replace("Bot", "我")
|
|
|
|
|
message = message.replace("吗", "")
|
|
|
|
|
message = message.replace("呢", "")
|
|
|
|
|
message = message.replace("?", "")
|
|
|
|
|
message = message.replace("?", "")
|
|
|
|
|
|
|
|
|
|
return message
|