mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
⬆ Update PTB related dependencies and add version check
This commit is contained in:
parent
da0faf6d98
commit
84e8d00831
13
core/bot.py
13
core/bot.py
@ -10,6 +10,7 @@ from typing import Any, Callable, ClassVar, Dict, Iterator, List, NoReturn, Opti
|
||||
import genshin
|
||||
import pytz
|
||||
from async_timeout import timeout
|
||||
from telegram import __version__ as tg_version
|
||||
from telegram.error import NetworkError, TimedOut
|
||||
from telegram.ext import (
|
||||
AIORateLimiter,
|
||||
@ -40,6 +41,18 @@ __all__ = ["bot"]
|
||||
T = TypeVar("T")
|
||||
PluginType = TypeVar("PluginType", bound=_Plugin)
|
||||
|
||||
try:
|
||||
from telegram import __version_info__ as tg_version_info
|
||||
except ImportError:
|
||||
tg_version_info = (0, 0, 0, 0, 0) # type: ignore[assignment]
|
||||
|
||||
if tg_version_info < (20, 0, 0, "alpha", 6):
|
||||
logger.warning(
|
||||
"Bot与当前PTB版本 [cyan bold]%s[/] [red bold]不兼容[/],请更新到最新版本后使用 [blue bold]poetry install[/] 重新安装依赖",
|
||||
tg_version,
|
||||
extra={"markup": True},
|
||||
)
|
||||
|
||||
|
||||
class Bot:
|
||||
_lock: ClassVar[Lock] = Lock()
|
||||
|
@ -1,9 +1,9 @@
|
||||
import contextlib
|
||||
import datetime
|
||||
import json
|
||||
from io import BytesIO
|
||||
from os import PathLike
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple, Optional
|
||||
from typing import List, Tuple, Optional, IO, Union
|
||||
|
||||
import aiofiles
|
||||
from genshin import Client, InvalidAuthkey
|
||||
@ -600,10 +600,10 @@ class GachaLog:
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def convert_xlsx_to_uigf(data: BytesIO, zh_dict: dict) -> dict:
|
||||
def convert_xlsx_to_uigf(file: Union[str, PathLike[str], IO[bytes]], zh_dict: dict) -> dict:
|
||||
"""转换 paimone.moe 或 非小酋 导出 xlsx 数据为 UIGF 格式
|
||||
:param file: 导出的 xlsx 文件
|
||||
:param zh_dict:
|
||||
:param data: paimon.moe 导出的 xlsx 数据
|
||||
:return: UIGF 格式数据
|
||||
"""
|
||||
|
||||
@ -654,7 +654,7 @@ class GachaLog:
|
||||
uigf_gacha_type=uigf_gacha_type,
|
||||
)
|
||||
|
||||
wb = load_workbook(data)
|
||||
wb = load_workbook(file)
|
||||
wb_len = len(wb.worksheets)
|
||||
|
||||
if wb_len == 6:
|
||||
|
@ -109,14 +109,13 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation):
|
||||
await message.reply_text("文件过大,请发送小于 2 MB 的文件")
|
||||
return
|
||||
try:
|
||||
data = BytesIO()
|
||||
await (await document.get_file()).download(out=data)
|
||||
out = BytesIO()
|
||||
await (await document.get_file()).download_to_memory(out=out)
|
||||
if file_type == "json":
|
||||
# bytesio to json
|
||||
data = data.getvalue().decode("utf-8")
|
||||
data = json.loads(data)
|
||||
data = json.loads(out.getvalue().decode("utf-8"))
|
||||
elif file_type == "xlsx":
|
||||
data = self.gacha_log.convert_xlsx_to_uigf(data, self.zh_dict)
|
||||
data = self.gacha_log.convert_xlsx_to_uigf(out, self.zh_dict)
|
||||
except PaimonMoeGachaLogFileError as exc:
|
||||
await message.reply_text(
|
||||
"导入失败,PaimonMoe的抽卡记录当前版本不支持\n" f"支持抽卡记录的版本为 {exc.support_version},你的抽卡记录版本为 {exc.file_version}"
|
||||
|
59
poetry.lock
generated
59
poetry.lock
generated
@ -159,7 +159,7 @@ python-versions = ">=3.5"
|
||||
dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"]
|
||||
docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"]
|
||||
tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"]
|
||||
tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"]
|
||||
tests_no_zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"]
|
||||
|
||||
[[package]]
|
||||
name = "backports.zoneinfo"
|
||||
@ -234,7 +234,7 @@ optional = false
|
||||
python-versions = ">=3.6.0"
|
||||
|
||||
[package.extras]
|
||||
unicode-backport = ["unicodedata2"]
|
||||
unicode_backport = ["unicodedata2"]
|
||||
|
||||
[[package]]
|
||||
name = "click"
|
||||
@ -385,7 +385,7 @@ python-versions = ">=3.7"
|
||||
[[package]]
|
||||
name = "genshin"
|
||||
version = "1.4.0"
|
||||
description = ""
|
||||
description = "An API wrapper for Genshin Impact."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
@ -405,7 +405,7 @@ geetest = ["rsa"]
|
||||
type = "git"
|
||||
url = "https://github.com/thesadru/genshin.py"
|
||||
reference = "HEAD"
|
||||
resolved_reference = "7d0b3353d8f92323f9343a9a14ec9a65b794b4f9"
|
||||
resolved_reference = "dbebc29f485f01e352e75c6e389e754369101a9c"
|
||||
|
||||
[[package]]
|
||||
name = "gitdb"
|
||||
@ -479,7 +479,7 @@ test = ["Cython (>=0.29.24,<0.30.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "httpx"
|
||||
version = "0.23.0"
|
||||
version = "0.23.1"
|
||||
description = "The next generation HTTP client."
|
||||
category = "main"
|
||||
optional = false
|
||||
@ -487,7 +487,7 @@ python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
certifi = "*"
|
||||
httpcore = ">=0.15.0,<0.16.0"
|
||||
httpcore = ">=0.15.0,<0.17.0"
|
||||
rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]}
|
||||
sniffio = "*"
|
||||
|
||||
@ -841,24 +841,29 @@ cli = ["click (>=5.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "python-telegram-bot"
|
||||
version = "20.0a4"
|
||||
version = "20.0a6"
|
||||
description = "We have made you a wrapper you can't refuse"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
aiolimiter = {version = ">=1.0.0,<1.1.0", optional = true, markers = "extra == \"rate-limiter\""}
|
||||
APScheduler = ">=3.9.1,<3.10.0"
|
||||
cachetools = ">=5.2.0,<5.3.0"
|
||||
httpx = ">=0.23.0,<0.24.0"
|
||||
pytz = ">=2018.6"
|
||||
tornado = ">=6.2,<7.0"
|
||||
aiolimiter = {version = ">=1.0.0,<1.1.0", optional = true, markers = "extra == \"ext\""}
|
||||
APScheduler = {version = ">=3.9.1,<3.10.0", optional = true, markers = "extra == \"ext\""}
|
||||
cachetools = {version = ">=5.2.0,<5.3.0", optional = true, markers = "extra == \"ext\""}
|
||||
httpx = ">=0.23.1,<0.24.0"
|
||||
pytz = {version = ">=2018.6", optional = true, markers = "extra == \"ext\""}
|
||||
tornado = {version = ">=6.2,<7.0", optional = true, markers = "extra == \"ext\""}
|
||||
|
||||
[package.extras]
|
||||
all = ["APScheduler (>=3.9.1,<3.10.0)", "aiolimiter (>=1.0.0,<1.1.0)", "cachetools (>=5.2.0,<5.3.0)", "cryptography (>=3.0,!=3.4,!=3.4.1,!=3.4.2,!=3.4.3)", "httpx[socks]", "pytz (>=2018.6)", "tornado (>=6.2,<7.0)"]
|
||||
callback-data = ["cachetools (>=5.2.0,<5.3.0)"]
|
||||
ext = ["APScheduler (>=3.9.1,<3.10.0)", "aiolimiter (>=1.0.0,<1.1.0)", "cachetools (>=5.2.0,<5.3.0)", "pytz (>=2018.6)", "tornado (>=6.2,<7.0)"]
|
||||
job-queue = ["APScheduler (>=3.9.1,<3.10.0)", "pytz (>=2018.6)"]
|
||||
passport = ["cryptography (>=3.0,!=3.4,!=3.4.1,!=3.4.2,!=3.4.3)"]
|
||||
rate-limiter = ["aiolimiter (>=1.0.0,<1.1.0)"]
|
||||
socks = ["httpx[socks]"]
|
||||
webhooks = ["tornado (>=6.2,<7.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "pytz"
|
||||
@ -958,7 +963,7 @@ falcon = ["falcon (>=1.4)"]
|
||||
fastapi = ["fastapi (>=0.79.0)"]
|
||||
flask = ["blinker (>=1.1)", "flask (>=0.11)"]
|
||||
httpx = ["httpx (>=0.16.0)"]
|
||||
pure-eval = ["asttokens", "executing", "pure-eval"]
|
||||
pure_eval = ["asttokens", "executing", "pure-eval"]
|
||||
pymongo = ["pymongo (>=3.1)"]
|
||||
pyspark = ["pyspark (>=2.4.4)"]
|
||||
quart = ["blinker (>=1.1)", "quart (>=0.16.1)"]
|
||||
@ -1037,19 +1042,19 @@ aiomysql = ["aiomysql", "greenlet (!=0.4.17)"]
|
||||
aiosqlite = ["aiosqlite", "greenlet (!=0.4.17)", "typing_extensions (!=3.10.0.1)"]
|
||||
asyncio = ["greenlet (!=0.4.17)"]
|
||||
asyncmy = ["asyncmy (>=0.2.3,!=0.2.4)", "greenlet (!=0.4.17)"]
|
||||
mariadb-connector = ["mariadb (>=1.0.1,!=1.1.2)"]
|
||||
mariadb_connector = ["mariadb (>=1.0.1,!=1.1.2)"]
|
||||
mssql = ["pyodbc"]
|
||||
mssql-pymssql = ["pymssql"]
|
||||
mssql-pyodbc = ["pyodbc"]
|
||||
mssql_pymssql = ["pymssql"]
|
||||
mssql_pyodbc = ["pyodbc"]
|
||||
mypy = ["mypy (>=0.910)", "sqlalchemy2-stubs"]
|
||||
mysql = ["mysqlclient (>=1.4.0)", "mysqlclient (>=1.4.0,<2)"]
|
||||
mysql-connector = ["mysql-connector-python"]
|
||||
mysql_connector = ["mysql-connector-python"]
|
||||
oracle = ["cx_oracle (>=7)", "cx_oracle (>=7,<8)"]
|
||||
postgresql = ["psycopg2 (>=2.7)"]
|
||||
postgresql-asyncpg = ["asyncpg", "greenlet (!=0.4.17)"]
|
||||
postgresql-pg8000 = ["pg8000 (>=1.16.6,!=1.29.0)"]
|
||||
postgresql-psycopg2binary = ["psycopg2-binary"]
|
||||
postgresql-psycopg2cffi = ["psycopg2cffi"]
|
||||
postgresql_asyncpg = ["asyncpg", "greenlet (!=0.4.17)"]
|
||||
postgresql_pg8000 = ["pg8000 (>=1.16.6,!=1.29.0)"]
|
||||
postgresql_psycopg2binary = ["psycopg2-binary"]
|
||||
postgresql_psycopg2cffi = ["psycopg2cffi"]
|
||||
pymysql = ["pymysql", "pymysql (<1)"]
|
||||
sqlcipher = ["sqlcipher3_binary"]
|
||||
|
||||
@ -1281,7 +1286,7 @@ test = ["pytest", "pytest-asyncio", "flaky"]
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.8"
|
||||
content-hash = "8ace0efe60f2b3917062367b82b331530d7edb334a8e21a548da26e906756c56"
|
||||
content-hash = "48beacc925cc4637c5ee31cb25c69491b3ade0d4042381b0aafa9707a99e4f01"
|
||||
|
||||
[metadata.files]
|
||||
aiofiles = [
|
||||
@ -1704,8 +1709,8 @@ httptools = [
|
||||
{file = "httptools-0.5.0.tar.gz", hash = "sha256:295874861c173f9101960bba332429bb77ed4dcd8cdf5cee9922eb00e4f6bc09"},
|
||||
]
|
||||
httpx = [
|
||||
{file = "httpx-0.23.0-py3-none-any.whl", hash = "sha256:42974f577483e1e932c3cdc3cd2303e883cbfba17fe228b0f63589764d7b9c4b"},
|
||||
{file = "httpx-0.23.0.tar.gz", hash = "sha256:f28eac771ec9eb4866d3fb4ab65abd42d38c424739e80c08d8d20570de60b0ef"},
|
||||
{file = "httpx-0.23.1-py3-none-any.whl", hash = "sha256:0b9b1f0ee18b9978d637b0776bfd7f54e2ca278e063e3586d8f01cda89e042a8"},
|
||||
{file = "httpx-0.23.1.tar.gz", hash = "sha256:202ae15319be24efe9a8bd4ed4360e68fde7b38bcc2ce87088d416f026667d19"},
|
||||
]
|
||||
idna = [
|
||||
{file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"},
|
||||
@ -2085,8 +2090,8 @@ python-dotenv = [
|
||||
{file = "python_dotenv-0.21.0-py3-none-any.whl", hash = "sha256:1684eb44636dd462b66c3ee016599815514527ad99965de77f43e0944634a7e5"},
|
||||
]
|
||||
python-telegram-bot = [
|
||||
{file = "python-telegram-bot-20.0a4.tar.gz", hash = "sha256:3ec10b5169d40697aba77f245538ecdf989e9ae429fcaddc69a202579b4a6dcb"},
|
||||
{file = "python_telegram_bot-20.0a4-py3-none-any.whl", hash = "sha256:79ce5a179017baeae362382c86c19951413a277ac8dd3f736824da36432ed2e9"},
|
||||
{file = "python-telegram-bot-20.0a6.tar.gz", hash = "sha256:aac039b54043d5c1778b182d506f2d51ddccef746eeb36e6ca9a236c4cd1c848"},
|
||||
{file = "python_telegram_bot-20.0a6-py3-none-any.whl", hash = "sha256:0279d0d727ab36e4b42a8819656098485bcd0724961c2f5fced3218b15b26c02"},
|
||||
]
|
||||
pytz = [
|
||||
{file = "pytz-2022.4-py2.py3-none-any.whl", hash = "sha256:2c0784747071402c6e99f0bafdb7da0fa22645f06554c7ae06bf6358897e9c91"},
|
||||
|
@ -8,10 +8,11 @@ readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
httpx= "^0.23.1"
|
||||
ujson = "^5.5.0"
|
||||
genshin = { git = "https://github.com/thesadru/genshin.py" }
|
||||
Jinja2 = "^3.1.2"
|
||||
python-telegram-bot = { version = "^20.0a4", extras = ["rate-limiter"] }
|
||||
python-telegram-bot = { version = "^20.0a6", extras = ["ext", "rate-limiter"] }
|
||||
Pillow = "^9.3.0"
|
||||
sqlmodel = "^0.0.8"
|
||||
colorlog = "^6.7.0"
|
||||
|
Loading…
Reference in New Issue
Block a user