mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
fix init pixiv
This commit is contained in:
@@ -12,6 +12,8 @@ from telegram.ext import (ApplicationBuilder, CallbackQueryHandler, CommandHandl
|
|||||||
import common
|
import common
|
||||||
import utils.regex as regex
|
import utils.regex as regex
|
||||||
from utils.logger import get_logger
|
from utils.logger import get_logger
|
||||||
|
from utils.net import NetClient
|
||||||
|
from utils.pixiv import ProcessPixiv
|
||||||
from utils.telegram import Telegram
|
from utils.telegram import Telegram
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -208,9 +210,9 @@ async def post_init(application: Application) -> None:
|
|||||||
DESCRIPTION = "A bot to fetch tweets from Twitter."
|
DESCRIPTION = "A bot to fetch tweets from Twitter."
|
||||||
await application.bot.set_my_description(DESCRIPTION)
|
await application.bot.set_my_description(DESCRIPTION)
|
||||||
await application.bot.set_my_short_description(DESCRIPTION)
|
await application.bot.set_my_short_description(DESCRIPTION)
|
||||||
Telegram.init_client()
|
NetClient.init_client()
|
||||||
if common.PIXIV_REFRESH_TOKEN:
|
if common.PIXIV_REFRESH_TOKEN:
|
||||||
await Pixiv.init_client(common.PIXIV_REFRESH_TOKEN)
|
await ProcessPixiv.init_client(common.PIXIV_REFRESH_TOKEN)
|
||||||
|
|
||||||
|
|
||||||
async def post_stop(application: Application) -> None:
|
async def post_stop(application: Application) -> None:
|
||||||
@@ -218,7 +220,7 @@ async def post_stop(application: Application) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def post_shutdown(application: Application) -> None:
|
async def post_shutdown(application: Application) -> None:
|
||||||
await Telegram.close_client()
|
await NetClient.close_client()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from .net import NetClient
|
from common import PIXIV_REFRESH_TOKEN
|
||||||
from .pixiv import TelegramPixiv
|
from .pixiv import TelegramPixiv
|
||||||
from .regex import pixiv_url, x_url
|
from .regex import pixiv_url, x_url
|
||||||
from .tweet import TelegramTweet
|
from .tweet import TelegramTweet
|
||||||
|
|
||||||
|
|
||||||
class Telegram(NetClient):
|
class Telegram:
|
||||||
def __init__(self, url: str):
|
def __init__(self, url: str):
|
||||||
self._url = url
|
self._url = url
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class Telegram(NetClient):
|
|||||||
if x_url.match(self._url):
|
if x_url.match(self._url):
|
||||||
async with TelegramTweet(self._url) as tweet:
|
async with TelegramTweet(self._url) as tweet:
|
||||||
return tweet
|
return tweet
|
||||||
elif pixiv_url.match(self._url):
|
elif PIXIV_REFRESH_TOKEN and pixiv_url.match(self._url):
|
||||||
async with TelegramPixiv(self._url) as pixiv:
|
async with TelegramPixiv(self._url) as pixiv:
|
||||||
return pixiv
|
return pixiv
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user