From 92aa5be1c1c177967d86b0933fe273ea93471ea8 Mon Sep 17 00:00:00 2001 From: ljh938527 <2689819155@qq.com> Date: Sat, 20 Dec 2025 22:42:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=8E=B7=E5=8F=96=E5=9B=BE?= =?UTF-8?q?=E7=89=87url=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/emoji_db.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/models/emoji_db.py b/models/emoji_db.py index 6cddbe9..f13dc10 100644 --- a/models/emoji_db.py +++ b/models/emoji_db.py @@ -70,7 +70,7 @@ def check_emoji(uuid: str, connection = connect_db()) -> bool: logger.error(f"检查UUID失败: {uuid}, 错误: {e}") return False -def get_emoji_content(uuid: str, content_index: str = 'url', connection = connect_db()) -> str | None: +def get_emoji_content(uuid: str, content_index: str, connection = connect_db()) -> str | None: """ 获取图片信息,检查图片在 approved 库中检索 approved 是否为 1,为 1 则返回获取到的索引内容 @@ -105,6 +105,22 @@ def get_emoji_content(uuid: str, content_index: str = 'url', connection = connec logger.error(f"获取失败: {uuid}, 错误: {e}") return None +def get_emoji_url(uuid: str) -> str: + """ + 获取图片的 url + + Args: + uuid: emoji 的UUID + + Returns: + content: 获取到的图片的 url + """ + url = get_emoji_content(uuid, 'url') + if url is not None: + return url + return '' + if __name__ == "__main__": - record = check_emoji("ffe1663c-44e1-4719-a5ba-01485f70a87e") - print(record) \ No newline at end of file + test_uuid = "c3151774-2c4c-48f6-a3ac-b8802cf95498" + print(check_emoji(test_uuid)) + print(get_emoji_url(test_uuid)) \ No newline at end of file