mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-18 10:40:03 +08:00
update v0.0.5.0
This commit is contained in:
@@ -8,10 +8,25 @@ from utils.utils import get_message_text, get_message_at
|
||||
from utils.message_builder import image
|
||||
import re
|
||||
from utils.image_utils import CreateImg
|
||||
from asyncio.exceptions import TimeoutError
|
||||
|
||||
__plugin_name__ = "我有一个朋友"
|
||||
|
||||
__plugin_usage__ = "用法:我有一个朋友说/问 [消息] [at](不艾特则群员随机)"
|
||||
__zx_plugin_name__ = "我有一个朋友"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
我有一个朋友他...,不知道是不是你
|
||||
指令:
|
||||
我有一个朋友想问问 [文本] ?[at]: 当at时你的朋友就是艾特对象
|
||||
""".strip()
|
||||
__plugin_des__ = "我有一个朋友想问问..."
|
||||
__plugin_cmd__ = ["我有一个朋友想问问[文本] ?[at]"]
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["我有一个朋友想问问", "我有一个朋友"],
|
||||
}
|
||||
|
||||
one_friend = on_regex(
|
||||
"^我.*?朋友.*?(想问问|说|让我问问|想问|让我问|想知道|让我帮他问问|让我帮他问|让我帮忙问|让我帮忙问问|问).*",
|
||||
@@ -23,8 +38,13 @@ one_friend = on_regex(
|
||||
async def get_pic(qq):
|
||||
url = f"http://q1.qlogo.cn/g?b=qq&nk={qq}&s=100"
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url, timeout=5) as response:
|
||||
return await response.read()
|
||||
for _ in range(3):
|
||||
try:
|
||||
async with session.get(url, timeout=5) as response:
|
||||
return await response.read()
|
||||
except TimeoutError:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
@one_friend.handle()
|
||||
@@ -40,11 +60,11 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
|
||||
)
|
||||
]
|
||||
)
|
||||
user_name = '朋友'
|
||||
user_name = "朋友"
|
||||
else:
|
||||
qq = qq[0]
|
||||
at_user = await bot.get_group_member_info(group_id=event.group_id, user_id=qq)
|
||||
user_name = at_user['card'] if at_user['card'] else at_user['nickname']
|
||||
user_name = at_user["card"] if at_user["card"] else at_user["nickname"]
|
||||
msg = re.search(
|
||||
r"^我.*?朋友.*?(想问问|说|让我问问|想问|让我问|想知道|让我帮他问问|让我帮他问|让我帮忙问|让我帮忙问问|问)(.*)", msg
|
||||
)
|
||||
@@ -52,7 +72,11 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
|
||||
if not msg:
|
||||
msg = "都不知道问什么"
|
||||
msg = msg.replace("他", "我").replace("她", "我").replace("它", "我")
|
||||
ava = CreateImg(100, 100, background=BytesIO(await get_pic(qq)))
|
||||
x = await get_pic(qq)
|
||||
if x:
|
||||
ava = CreateImg(100, 100, background=BytesIO(await get_pic(qq)))
|
||||
else:
|
||||
ava = CreateImg(100, 100, color=(0, 0, 0))
|
||||
ava.circle()
|
||||
text = CreateImg(300, 30, font_size=30)
|
||||
text.text((0, 0), user_name)
|
||||
|
||||
Reference in New Issue
Block a user