mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-07 12:43:26 +08:00
🐛 修复@别人时显示自己头像(#468)
This commit is contained in:
parent
f95300ae6f
commit
4bb2a9e88b
@ -18,10 +18,10 @@ sv_export_gacha_log = SV('导出抽卡记录')
|
||||
@sv_gacha_log.on_fullmatch(('抽卡记录'))
|
||||
async def send_gacha_log_card_info(bot: Bot, ev: Event):
|
||||
await bot.logger.info('开始执行[抽卡记录]')
|
||||
uid = await get_uid(bot, ev)
|
||||
uid, user_id = await get_uid(bot, ev, True)
|
||||
if uid is None:
|
||||
return await bot.send(UID_HINT)
|
||||
im = await draw_gachalogs_img(uid, ev.user_id)
|
||||
im = await draw_gachalogs_img(uid, user_id)
|
||||
await bot.send(im)
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import re
|
||||
from typing import Union, Optional
|
||||
from typing import Tuple, Union, Optional, overload
|
||||
|
||||
from gsuid_core.bot import Bot
|
||||
from gsuid_core.models import Event
|
||||
@ -10,14 +10,30 @@ from .error_reply import VERIFY_HINT
|
||||
from ..gsuid_utils.api.mys.models import AbyssData, IndexData
|
||||
|
||||
|
||||
async def get_uid(bot: Bot, ev: Event):
|
||||
uid = re.findall(r'\d{9}', ev.text)
|
||||
@overload
|
||||
async def get_uid(bot: Bot, ev: Event) -> Optional[str]:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
async def get_uid(
|
||||
bot: Bot, ev: Event, get_user_id: bool = True
|
||||
) -> Tuple[Optional[str], str]:
|
||||
...
|
||||
|
||||
|
||||
async def get_uid(
|
||||
bot: Bot, ev: Event, get_user_id: bool = False
|
||||
) -> Union[Optional[str], Tuple[Optional[str], str]]:
|
||||
uid_data = re.findall(r'\d{9}', ev.text)
|
||||
user_id = ev.at if ev.at else ev.user_id
|
||||
if uid:
|
||||
uid = uid[0]
|
||||
if uid_data:
|
||||
uid: Optional[str] = uid_data[0]
|
||||
else:
|
||||
sqla = get_sqla(ev.bot_id)
|
||||
uid = await sqla.get_bind_uid(user_id)
|
||||
if get_user_id:
|
||||
return uid, user_id
|
||||
return uid
|
||||
|
||||
|
||||
|
16
poetry.lock
generated
16
poetry.lock
generated
@ -668,19 +668,19 @@ test = ["aiosqlite (>=0.15.0)", "jinja2 (>=2.11.2,<4.0.0)", "pytest (>=6.2.4)",
|
||||
|
||||
[[package]]
|
||||
name = "filelock"
|
||||
version = "3.10.4"
|
||||
version = "3.10.6"
|
||||
description = "A platform independent file lock."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "filelock-3.10.4-py3-none-any.whl", hash = "sha256:6d332dc5c896f18ba93a21d987155e97c434a96d3fe4042ca70d0b3b46e3b470"},
|
||||
{file = "filelock-3.10.4.tar.gz", hash = "sha256:9fc1734dbddcdcd4aaa02c160dd94db5272b92dfa859b44ec8df28e160b751f0"},
|
||||
{file = "filelock-3.10.6-py3-none-any.whl", hash = "sha256:52f119747b2b9c4730dac715a7b1ab34b8ee70fd9259cba158ee53da566387ff"},
|
||||
{file = "filelock-3.10.6.tar.gz", hash = "sha256:409105becd604d6b176a483f855e7e8903c5cb2873e47f2c64f66a370c046aaf"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2022.12.7)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)"]
|
||||
testing = ["covdefaults (>=2.3)", "coverage (>=7.2.2)", "pytest (>=7.2.2)", "pytest-cov (>=4)", "pytest-timeout (>=2.1)"]
|
||||
testing = ["covdefaults (>=2.3)", "coverage (>=7.2.2)", "diff-cover (>=7.5)", "pytest (>=7.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"]
|
||||
|
||||
[[package]]
|
||||
name = "flake8"
|
||||
@ -1544,19 +1544,19 @@ tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "pa
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "3.1.1"
|
||||
version = "3.2.0"
|
||||
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "platformdirs-3.1.1-py3-none-any.whl", hash = "sha256:e5986afb596e4bb5bde29a79ac9061aa955b94fca2399b7aaac4090860920dd8"},
|
||||
{file = "platformdirs-3.1.1.tar.gz", hash = "sha256:024996549ee88ec1a9aa99ff7f8fc819bb59e2c3477b410d90a16d32d6e707aa"},
|
||||
{file = "platformdirs-3.2.0-py3-none-any.whl", hash = "sha256:ebe11c0d7a805086e99506aa331612429a72ca7cd52a1f0d277dc4adc20cb10e"},
|
||||
{file = "platformdirs-3.2.0.tar.gz", hash = "sha256:d5b638ca397f25f979350ff789db335903d7ea010ab28903f57b27e1b16c2b08"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)"]
|
||||
test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"]
|
||||
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"]
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
|
Loading…
x
Reference in New Issue
Block a user