refactor: move imports in main.py
this change allows to avoid multiple and very specific imports in other python files Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
d363fa9afd
commit
4fbdb198ae
3 changed files with 15 additions and 17 deletions
|
@ -1,4 +1,3 @@
|
|||
from configparser import ConfigParser
|
||||
from uuid import uuid4
|
||||
|
||||
import requests
|
||||
|
@ -7,7 +6,9 @@ from telegram import Update, InlineKeyboardButton, InlineQueryResultArticle, Inp
|
|||
from telegram.constants import ParseMode
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
import main
|
||||
from extensions import humanize_tags_from_json, format_rating
|
||||
from main import config
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
|
@ -20,7 +21,6 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||
if not query.isdigit():
|
||||
return
|
||||
|
||||
from main import config
|
||||
response = requests.get(f"http://{config.get('App', 'Host')}/posts/{query}.json")
|
||||
|
||||
if response.status_code != 200:
|
||||
|
@ -29,12 +29,10 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||
|
||||
data = response.json()
|
||||
|
||||
await answer_query(update, query, config, data)
|
||||
await answer_query(update, query, data)
|
||||
|
||||
|
||||
async def answer_query(update: Update, query: str,
|
||||
config: ConfigParser, data) -> None:
|
||||
import main
|
||||
async def answer_query(update: Update, query: str, data) -> None:
|
||||
characters = humanize_tags_from_json(data['tag_string_character'], "no characters")
|
||||
copyrights = humanize_tags_from_json(data['tag_string_copyright'], "unknown copyright")
|
||||
artists = humanize_tags_from_json(data['tag_string_artist'], "unknown artist")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue