fix deal with invalid url

This commit is contained in:
2024-06-24 02:17:26 +08:00
parent 23128af96a
commit e7ccd70e56
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -41,6 +41,8 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
return return
logger.info(f"Query: {query}") logger.info(f"Query: {query}")
async with Telegram(query) as tweet: async with Telegram(query) as tweet:
if not tweet:
return
await update.inline_query.answer(tweet.inline_query_result()) await update.inline_query.answer(tweet.inline_query_result())
+2
View File
@@ -17,6 +17,8 @@ class Telegram:
elif PIXIV_REFRESH_TOKEN and 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
else:
return None
async def __aexit__(self, exc_type, exc_val, exc_tb): async def __aexit__(self, exc_type, exc_val, exc_tb):
pass pass