mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-06 19:53:44 +08:00
添加QQ官方机器人头像获取
This commit is contained in:
parent
fa7702537b
commit
b049810b22
@ -1,68 +1,68 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from gsuid_core.sv import SV
|
from gsuid_core.sv import SV
|
||||||
from gsuid_core.bot import Bot
|
from gsuid_core.bot import Bot
|
||||||
from gsuid_core.models import Event
|
from gsuid_core.models import Event
|
||||||
from gsuid_core.utils.error_reply import UID_HINT
|
from gsuid_core.utils.error_reply import UID_HINT
|
||||||
|
|
||||||
from ..utils.convert import get_uid
|
from ..utils.convert import get_uid
|
||||||
from ..utils.sr_prefix import PREFIX
|
from ..utils.sr_prefix import PREFIX
|
||||||
from .draw_abyss_card import draw_abyss_img
|
from .draw_abyss_card import draw_abyss_img
|
||||||
|
|
||||||
sv_srabyss = SV('sr查询深渊')
|
sv_srabyss = SV('sr查询深渊')
|
||||||
|
|
||||||
|
|
||||||
@sv_srabyss.on_command(
|
@sv_srabyss.on_command(
|
||||||
(
|
(
|
||||||
f'{PREFIX}查询深渊',
|
f'{PREFIX}查询深渊',
|
||||||
f'{PREFIX}sy',
|
f'{PREFIX}sy',
|
||||||
f'{PREFIX}查询上期深渊',
|
f'{PREFIX}查询上期深渊',
|
||||||
f'{PREFIX}sqsy',
|
f'{PREFIX}sqsy',
|
||||||
f'{PREFIX}上期深渊',
|
f'{PREFIX}上期深渊',
|
||||||
f'{PREFIX}深渊',
|
f'{PREFIX}深渊',
|
||||||
),
|
),
|
||||||
block=True,
|
block=True,
|
||||||
)
|
)
|
||||||
async def send_srabyss_info(bot: Bot, ev: Event):
|
async def send_srabyss_info(bot: Bot, ev: Event):
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', ev.text))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', ev.text))
|
||||||
if name:
|
if name:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
await bot.logger.info('开始执行[sr查询深渊信息]')
|
await bot.logger.info('开始执行[sr查询深渊信息]')
|
||||||
get_uid_ = await get_uid(bot, ev, True)
|
get_uid_ = await get_uid(bot, ev, True)
|
||||||
if get_uid_ is None:
|
if get_uid_ is None:
|
||||||
return await bot.send(UID_HINT)
|
return await bot.send(UID_HINT)
|
||||||
uid, user_id = get_uid_
|
uid, user_id = get_uid_
|
||||||
if uid is None:
|
if uid is None:
|
||||||
return await bot.send(UID_HINT)
|
return await bot.send(UID_HINT)
|
||||||
await bot.logger.info(f'[sr查询深渊信息]uid: {uid}')
|
await bot.logger.info(f'[sr查询深渊信息]uid: {uid}')
|
||||||
|
|
||||||
if 'sq' in ev.command or '上期' in ev.command:
|
if 'sq' in ev.command or '上期' in ev.command:
|
||||||
schedule_type = '2'
|
schedule_type = '2'
|
||||||
else:
|
else:
|
||||||
schedule_type = '1'
|
schedule_type = '1'
|
||||||
await bot.logger.info(f'[sr查询深渊信息]深渊期数: {schedule_type}')
|
await bot.logger.info(f'[sr查询深渊信息]深渊期数: {schedule_type}')
|
||||||
|
|
||||||
if ev.text in ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十']:
|
if ev.text in ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十']:
|
||||||
floor = (
|
floor = (
|
||||||
ev.text.replace('一', '1')
|
ev.text.replace('一', '1')
|
||||||
.replace('二', '2')
|
.replace('二', '2')
|
||||||
.replace('三', '3')
|
.replace('三', '3')
|
||||||
.replace('四', '4')
|
.replace('四', '4')
|
||||||
.replace('五', '5')
|
.replace('五', '5')
|
||||||
.replace('六', '6')
|
.replace('六', '6')
|
||||||
.replace('七', '7')
|
.replace('七', '7')
|
||||||
.replace('八', '8')
|
.replace('八', '8')
|
||||||
.replace('九', '9')
|
.replace('九', '9')
|
||||||
.replace('十', '10')
|
.replace('十', '10')
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
floor = ev.text
|
floor = ev.text
|
||||||
if floor and floor.isdigit():
|
if floor and floor.isdigit():
|
||||||
floor = int(floor)
|
floor = int(floor)
|
||||||
else:
|
else:
|
||||||
floor = None
|
floor = None
|
||||||
await bot.logger.info(f'[sr查询深渊信息]深渊层数: {floor}')
|
await bot.logger.info(f'[sr查询深渊信息]深渊层数: {floor}')
|
||||||
im = await draw_abyss_img(user_id, uid, floor, schedule_type)
|
im = await draw_abyss_img(user_id, uid, floor, schedule_type, ev.sender)
|
||||||
await bot.send(im)
|
await bot.send(im)
|
||||||
return None
|
return None
|
||||||
|
@ -152,6 +152,7 @@ async def draw_abyss_img(
|
|||||||
uid: str,
|
uid: str,
|
||||||
floor: Optional[int] = None,
|
floor: Optional[int] = None,
|
||||||
schedule_type: str = '1',
|
schedule_type: str = '1',
|
||||||
|
sender,
|
||||||
) -> Union[bytes, str]:
|
) -> Union[bytes, str]:
|
||||||
raw_abyss_data = await mys_api.get_srspiral_abyss_info(uid, schedule_type)
|
raw_abyss_data = await mys_api.get_srspiral_abyss_info(uid, schedule_type)
|
||||||
|
|
||||||
@ -185,6 +186,8 @@ async def draw_abyss_img(
|
|||||||
_id = str(qid)
|
_id = str(qid)
|
||||||
if _id.startswith('http'):
|
if _id.startswith('http'):
|
||||||
char_pic = await get_qq_avatar(avatar_url=_id)
|
char_pic = await get_qq_avatar(avatar_url=_id)
|
||||||
|
elif sender.get('avatar') is not None:
|
||||||
|
char_pic = await get_qq_avatar(avatar_url=sender['avatar'])
|
||||||
else:
|
else:
|
||||||
char_pic = await get_qq_avatar(qid=qid)
|
char_pic = await get_qq_avatar(qid=qid)
|
||||||
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
||||||
|
@ -1,95 +1,95 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from gsuid_core.sv import SV
|
from gsuid_core.sv import SV
|
||||||
from gsuid_core.bot import Bot
|
from gsuid_core.bot import Bot
|
||||||
from gsuid_core.models import Event
|
from gsuid_core.models import Event
|
||||||
from gsuid_core.utils.error_reply import UID_HINT
|
from gsuid_core.utils.error_reply import UID_HINT
|
||||||
|
|
||||||
from ..utils.convert import get_uid
|
from ..utils.convert import get_uid
|
||||||
from ..utils.sr_prefix import PREFIX
|
from ..utils.sr_prefix import PREFIX
|
||||||
from .draw_rogue_card import draw_rogue_img, draw_rogue_locust_img
|
from .draw_rogue_card import draw_rogue_img, draw_rogue_locust_img
|
||||||
|
|
||||||
sv_srabyss = SV('sr查询模拟宇宙')
|
sv_srabyss = SV('sr查询模拟宇宙')
|
||||||
sv_srabyss_locust = SV('sr查询寰宇蝗灾')
|
sv_srabyss_locust = SV('sr查询寰宇蝗灾')
|
||||||
|
|
||||||
|
|
||||||
@sv_srabyss.on_command(
|
@sv_srabyss.on_command(
|
||||||
(
|
(
|
||||||
f'{PREFIX}查询宇宙',
|
f'{PREFIX}查询宇宙',
|
||||||
f'{PREFIX}yz',
|
f'{PREFIX}yz',
|
||||||
f'{PREFIX}查询上期宇宙',
|
f'{PREFIX}查询上期宇宙',
|
||||||
f'{PREFIX}sqyz',
|
f'{PREFIX}sqyz',
|
||||||
f'{PREFIX}上期宇宙',
|
f'{PREFIX}上期宇宙',
|
||||||
f'{PREFIX}宇宙',
|
f'{PREFIX}宇宙',
|
||||||
f'{PREFIX}查询模拟宇宙',
|
f'{PREFIX}查询模拟宇宙',
|
||||||
f'{PREFIX}上期模拟宇宙',
|
f'{PREFIX}上期模拟宇宙',
|
||||||
f'{PREFIX}查询上期模拟宇宙',
|
f'{PREFIX}查询上期模拟宇宙',
|
||||||
),
|
),
|
||||||
block=True,
|
block=True,
|
||||||
)
|
)
|
||||||
async def send_srabyss_info(bot: Bot, ev: Event):
|
async def send_srabyss_info(bot: Bot, ev: Event):
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', ev.text))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', ev.text))
|
||||||
if name:
|
if name:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
await bot.logger.info('开始执行[sr查询模拟宇宙信息]')
|
await bot.logger.info('开始执行[sr查询模拟宇宙信息]')
|
||||||
get_uid_ = await get_uid(bot, ev, True)
|
get_uid_ = await get_uid(bot, ev, True)
|
||||||
if get_uid_ is None:
|
if get_uid_ is None:
|
||||||
return await bot.send(UID_HINT)
|
return await bot.send(UID_HINT)
|
||||||
uid, user_id = get_uid_
|
uid, user_id = get_uid_
|
||||||
if uid is None:
|
if uid is None:
|
||||||
return await bot.send(UID_HINT)
|
return await bot.send(UID_HINT)
|
||||||
await bot.logger.info(f'[sr查询模拟宇宙信息]uid: {uid}')
|
await bot.logger.info(f'[sr查询模拟宇宙信息]uid: {uid}')
|
||||||
|
|
||||||
if 'sq' in ev.command or '上期' in ev.command:
|
if 'sq' in ev.command or '上期' in ev.command:
|
||||||
schedule_type = '2'
|
schedule_type = '2'
|
||||||
else:
|
else:
|
||||||
schedule_type = '3'
|
schedule_type = '3'
|
||||||
await bot.logger.info(f'[sr查询模拟宇宙信息]模拟宇宙期数: {schedule_type}')
|
await bot.logger.info(f'[sr查询模拟宇宙信息]模拟宇宙期数: {schedule_type}')
|
||||||
|
|
||||||
if ev.text in ['一', '二', '三', '四', '五', '六']:
|
if ev.text in ['一', '二', '三', '四', '五', '六']:
|
||||||
floor = (
|
floor = (
|
||||||
ev.text.replace('一', '1')
|
ev.text.replace('一', '1')
|
||||||
.replace('二', '2')
|
.replace('二', '2')
|
||||||
.replace('三', '3')
|
.replace('三', '3')
|
||||||
.replace('四', '4')
|
.replace('四', '4')
|
||||||
.replace('五', '5')
|
.replace('五', '5')
|
||||||
.replace('六', '6')
|
.replace('六', '6')
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
floor = ev.text
|
floor = ev.text
|
||||||
if floor and floor.isdigit():
|
if floor and floor.isdigit():
|
||||||
floor = int(floor)
|
floor = int(floor)
|
||||||
else:
|
else:
|
||||||
floor = None
|
floor = None
|
||||||
await bot.logger.info(f'[sr查询模拟宇宙信息]模拟宇宙世界数: {floor}')
|
await bot.logger.info(f'[sr查询模拟宇宙信息]模拟宇宙世界数: {floor}')
|
||||||
im = await draw_rogue_img(user_id, uid, floor, schedule_type)
|
im = await draw_rogue_img(user_id, uid, floor, schedule_type, ev.sender)
|
||||||
await bot.send(im)
|
await bot.send(im)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@sv_srabyss_locust.on_command(
|
@sv_srabyss_locust.on_command(
|
||||||
(
|
(
|
||||||
f'{PREFIX}寰宇蝗灾',
|
f'{PREFIX}寰宇蝗灾',
|
||||||
f'{PREFIX}hyhz',
|
f'{PREFIX}hyhz',
|
||||||
f'{PREFIX}查询寰宇蝗灾',
|
f'{PREFIX}查询寰宇蝗灾',
|
||||||
f'{PREFIX}sqhyhz',
|
f'{PREFIX}sqhyhz',
|
||||||
),
|
),
|
||||||
block=True,
|
block=True,
|
||||||
)
|
)
|
||||||
async def send_srabyss_locust_info(bot: Bot, ev: Event):
|
async def send_srabyss_locust_info(bot: Bot, ev: Event):
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', ev.text))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', ev.text))
|
||||||
if name:
|
if name:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
await bot.logger.info('开始执行[sr查询寰宇蝗灾信息]')
|
await bot.logger.info('开始执行[sr查询寰宇蝗灾信息]')
|
||||||
get_uid_ = await get_uid(bot, ev, True)
|
get_uid_ = await get_uid(bot, ev, True)
|
||||||
if get_uid_ is None:
|
if get_uid_ is None:
|
||||||
return await bot.send(UID_HINT)
|
return await bot.send(UID_HINT)
|
||||||
uid, user_id = get_uid_
|
uid, user_id = get_uid_
|
||||||
if uid is None:
|
if uid is None:
|
||||||
return await bot.send(UID_HINT)
|
return await bot.send(UID_HINT)
|
||||||
await bot.logger.info(f'[sr查询寰宇蝗灾信息]uid: {uid}')
|
await bot.logger.info(f'[sr查询寰宇蝗灾信息]uid: {uid}')
|
||||||
im = await draw_rogue_locust_img(user_id, uid)
|
im = await draw_rogue_locust_img(user_id, uid, ev.sender)
|
||||||
await bot.send(im)
|
await bot.send(im)
|
||||||
return None
|
return None
|
||||||
|
@ -250,6 +250,7 @@ async def draw_rogue_img(
|
|||||||
uid: str,
|
uid: str,
|
||||||
floor: Optional[int] = None,
|
floor: Optional[int] = None,
|
||||||
schedule_type: str = '3',
|
schedule_type: str = '3',
|
||||||
|
sender,
|
||||||
) -> Union[bytes, str]:
|
) -> Union[bytes, str]:
|
||||||
raw_rogue_data = await mys_api.get_rogue_info(uid, '3')
|
raw_rogue_data = await mys_api.get_rogue_info(uid, '3')
|
||||||
|
|
||||||
@ -325,6 +326,8 @@ async def draw_rogue_img(
|
|||||||
_id = str(qid)
|
_id = str(qid)
|
||||||
if _id.startswith('http'):
|
if _id.startswith('http'):
|
||||||
char_pic = await get_qq_avatar(avatar_url=_id)
|
char_pic = await get_qq_avatar(avatar_url=_id)
|
||||||
|
elif sender.get('avatar') is not None:
|
||||||
|
char_pic = await get_qq_avatar(avatar_url=sender['avatar'])
|
||||||
else:
|
else:
|
||||||
char_pic = await get_qq_avatar(qid=qid)
|
char_pic = await get_qq_avatar(qid=qid)
|
||||||
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
||||||
@ -533,6 +536,7 @@ async def draw_rogue_img(
|
|||||||
async def draw_rogue_locust_img(
|
async def draw_rogue_locust_img(
|
||||||
qid: Union[str, int],
|
qid: Union[str, int],
|
||||||
uid: str,
|
uid: str,
|
||||||
|
sender,
|
||||||
) -> Union[bytes, str]:
|
) -> Union[bytes, str]:
|
||||||
raw_rogue_data = await mys_api.get_rogue_locust_info(uid, '3')
|
raw_rogue_data = await mys_api.get_rogue_locust_info(uid, '3')
|
||||||
|
|
||||||
@ -608,6 +612,8 @@ async def draw_rogue_locust_img(
|
|||||||
_id = str(qid)
|
_id = str(qid)
|
||||||
if _id.startswith('http'):
|
if _id.startswith('http'):
|
||||||
char_pic = await get_qq_avatar(avatar_url=_id)
|
char_pic = await get_qq_avatar(avatar_url=_id)
|
||||||
|
elif sender.get('avatar') is not None:
|
||||||
|
char_pic = await get_qq_avatar(avatar_url=sender['avatar'])
|
||||||
else:
|
else:
|
||||||
char_pic = await get_qq_avatar(qid=qid)
|
char_pic = await get_qq_avatar(qid=qid)
|
||||||
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
||||||
|
@ -43,5 +43,5 @@ async def send_detail_info(bot: Bot, ev: Event):
|
|||||||
|
|
||||||
logger.info(f'[sr查询信息]UID: {uid}')
|
logger.info(f'[sr查询信息]UID: {uid}')
|
||||||
await bot.logger.info('开始执行[sr查询信息]')
|
await bot.logger.info('开始执行[sr查询信息]')
|
||||||
await bot.send(await get_detail_img(user_id, uid))
|
await bot.send(await get_detail_img(user_id, uid, ev.sender))
|
||||||
return None
|
return None
|
||||||
|
@ -70,8 +70,8 @@ async def get_role_img(uid: str) -> Union[bytes, str]:
|
|||||||
return await draw_role_card(uid)
|
return await draw_role_card(uid)
|
||||||
|
|
||||||
|
|
||||||
async def get_detail_img(qid: Union[str, int], uid: str) -> Union[bytes, str]:
|
async def get_detail_img(qid: Union[str, int], uid: str, sender) -> Union[bytes, str]:
|
||||||
return await get_detail_card(qid, uid)
|
return await get_detail_card(qid, uid, sender)
|
||||||
|
|
||||||
|
|
||||||
def _lv(level: int) -> str:
|
def _lv(level: int) -> str:
|
||||||
@ -376,7 +376,7 @@ async def _draw_detail_card(
|
|||||||
|
|
||||||
|
|
||||||
async def get_detail_card(
|
async def get_detail_card(
|
||||||
qid: Union[str, int], sr_uid: str
|
qid: Union[str, int], sr_uid: str, sender
|
||||||
) -> Union[bytes, str]:
|
) -> Union[bytes, str]:
|
||||||
# 获取角色列表
|
# 获取角色列表
|
||||||
avatar_list = await mys_api.get_avatar_info(sr_uid, 1001)
|
avatar_list = await mys_api.get_avatar_info(sr_uid, 1001)
|
||||||
@ -398,6 +398,8 @@ async def get_detail_card(
|
|||||||
_id = str(qid)
|
_id = str(qid)
|
||||||
if _id.startswith('http'):
|
if _id.startswith('http'):
|
||||||
char_pic = await get_qq_avatar(avatar_url=_id)
|
char_pic = await get_qq_avatar(avatar_url=_id)
|
||||||
|
elif sender.get('avatar') is not None:
|
||||||
|
char_pic = await get_qq_avatar(avatar_url=sender['avatar'])
|
||||||
else:
|
else:
|
||||||
char_pic = await get_qq_avatar(qid=qid)
|
char_pic = await get_qq_avatar(qid=qid)
|
||||||
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
char_pic = await draw_pic_with_ring(char_pic, 250, None, False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user