格式化代码并优化导入

This commit is contained in:
luoshuijs 2022-06-09 15:12:06 +08:00
parent 6b9e06a2e3
commit 56c8ee3591
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
26 changed files with 55 additions and 54 deletions

View File

@ -1,6 +1,7 @@
import ujson
import os
import ujson
class Config(object):
def __init__(self):

View File

@ -1,17 +1,15 @@
from typing import Optional
from telegram.ext import CommandHandler, MessageHandler, filters, ConversationHandler, \
CallbackQueryHandler, InlineQueryHandler
from telegram.ext import CommandHandler, MessageHandler, filters, CallbackQueryHandler, InlineQueryHandler
from plugins.admin import Admin
from plugins.auth import Auth
from plugins.base import NewChatMembersHandler
from plugins.cookies import Cookies
from plugins.daily_note import DailyNote
from plugins.errorhandler import error_handler
from plugins.gacha import Gacha
from plugins.help import Help
from plugins.uid import Uid
from plugins.daily_note import DailyNote
from plugins.inline import Inline
from plugins.job_queue import JobQueue
from plugins.post import Post
@ -19,6 +17,7 @@ from plugins.quiz import Quiz
from plugins.sign import Sign
from plugins.start import start, ping, reply_keyboard_remove, unknown_command
from plugins.strategy import Strategy
from plugins.uid import Uid
from plugins.weapon import Weapon
from service import BaseService
@ -82,4 +81,3 @@ def register_handlers(application, service: BaseService = None):
application.job_queue.run_once(job_queue.start_job, when=3, name="start_job")
application.add_handler(MessageHandler(filters.COMMAND & filters.ChatType.PRIVATE, unknown_command))
application.add_error_handler(error_handler, block=False)

View File

@ -1,7 +1,8 @@
import logging
from logging.handlers import RotatingFileHandler
import colorlog
import os
from logging.handlers import RotatingFileHandler
import colorlog
from config import config

View File

@ -1,16 +1,15 @@
import asyncio
from typing import Optional
from warnings import filterwarnings
from telegram.ext import Application
from telegram.warnings import PTBUserWarning
from config import config
from handler import register_handlers
from logger import Log
from service import StartService
from service.repository import AsyncRepository
from config import config
from service.cache import RedisCache
from service.repository import AsyncRepository
# 无视相关警告
# 该警告说明在官方GITHUB的WIKI中Frequently Asked Questions里的What do the per_* settings in ConversationHandler do?

View File

@ -1,3 +1,3 @@
from .hyperion import *
from .hoyolab import *
from .gacha import *
from .hoyolab import *
from .hyperion import *

View File

@ -1,8 +1,10 @@
import asyncio
import re
from typing import List
import httpx
from httpx import AsyncClient
from .base import HyperionResponse, ArtworkImage, BaseResponseData
from .helpers import get_ds, get_device_id

View File

@ -1,13 +1,14 @@
import hashlib
import os
from typing import List
import aiofiles
import httpx
from httpx import UnsupportedProtocol
from telegram import Bot
from logger import Log
from service.cache import RedisCache
import aiofiles
USER_AGENT: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " \
"Chrome/90.0.4430.72 Safari/537.36"

View File

@ -1,16 +1,15 @@
import time
import datetime
import random
import time
from typing import Tuple
from numpy.random import Generator, MT19937
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, ChatPermissions
from telegram.constants import ParseMode
from telegram.error import BadRequest
from telegram.ext import CallbackContext
from telegram.helpers import escape_markdown
from numpy.random import Generator, MT19937
from logger import Log
from model.helpers import get_admin_list
from service import BaseService

View File

@ -1,8 +1,8 @@
from http.cookies import SimpleCookie
import ujson
import genshin
from genshin import InvalidCookies, GenshinException, DataNotPublic
import genshin
import ujson
from genshin import InvalidCookies, GenshinException, DataNotPublic
from telegram import Update, ReplyKeyboardRemove, ReplyKeyboardMarkup
from telegram.ext import CallbackContext, CommandHandler, MessageHandler, filters, ConversationHandler
from telegram.helpers import escape_markdown

View File

@ -1,5 +1,5 @@
import os
import datetime
import os
import genshin
from genshin import GenshinException, DataNotPublic

View File

@ -6,14 +6,13 @@ import ujson
from aiohttp import ClientConnectorError
from genshin import InvalidCookies, GenshinException, TooManyRequests
from httpx import ConnectTimeout
from telegram import Update, ReplyKeyboardRemove
from telegram.constants import ParseMode
from telegram.error import BadRequest, TimedOut
from telegram.ext import CallbackContext, ConversationHandler
from logger import Log
from config import config
from logger import Log
try:
notice_chat_id = config.TELEGRAM["notice"]["ERROR"]["chat_id"]
@ -36,7 +35,6 @@ async def send_user_notification(update: Update, _: CallbackContext, text: str):
def conversation_error_handler(func: Callable) -> Callable:
async def decorator(*args, **kwargs):
update: Optional[Update] = None
context: Optional[CallbackContext] = None

View File

@ -1,14 +1,14 @@
import os
from pyppeteer import launch
from telegram import Update
from telegram.constants import ChatAction
from telegram.ext import CallbackContext, ConversationHandler, filters
from logger import Log
from metadata.metadata import metadat
from plugins.base import BasePlugins, RestrictsCalls
from service import BaseService
from pyppeteer import launch
from metadata.metadata import metadat
from service.wish import WishCountInfo, get_one

View File

@ -1,6 +1,7 @@
from typing import cast
from urllib.parse import urlparse, urlencode, ParseResult
from uuid import uuid4
from telegram import InlineQueryResultArticle, InputTextMessageContent, Update, InlineQuery, InlineQueryResultPhoto
from telegram.constants import ParseMode
from telegram.error import BadRequest
@ -8,9 +9,9 @@ from telegram.ext import CallbackContext
from telegram.helpers import escape_markdown
from logger import Log
from metadata.metadata import metadat
from service import BaseService
from service.base import QuestionData
from metadata.metadata import metadat
class Inline:

View File

@ -1,6 +1,6 @@
from typing import Optional, List
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup
from telegram import Update, ReplyKeyboardMarkup, ReplyKeyboardRemove, InputMediaPhoto
from telegram.constants import ParseMode
from telegram.error import BadRequest

View File

@ -1,5 +1,5 @@
import time
import datetime
import time
import genshin
from genshin import Game, GenshinException, AlreadyClaimed

View File

@ -5,11 +5,11 @@ from telegram.constants import ChatAction, ParseMode
from telegram.ext import CallbackContext, filters
from logger import Log
from metadata.shortname import roleToName
from model.helpers import url_to_file
from plugins.base import BasePlugins
from plugins.errorhandler import conversation_error_handler
from service import BaseService
from metadata.shortname import roleToName
class Strategy(BasePlugins):

View File

@ -5,12 +5,12 @@ from telegram.constants import ChatAction
from telegram.ext import CallbackContext, filters
from logger import Log
from metadata.metadata import metadat
from metadata.shortname import weaponToName
from model.helpers import url_to_file
from plugins.base import BasePlugins
from plugins.errorhandler import conversation_error_handler
from service import BaseService
from metadata.shortname import weaponToName
from metadata.metadata import metadat
class Weapon(BasePlugins):

View File

@ -1,9 +1,9 @@
from service.admin import AdminService
from service.cache import RedisCache
from service.gacha import GachaService
from service.game import GetGameInfo
from service.quiz import QuizService
from service.repository import AsyncRepository
from service.cache import RedisCache
from service.template import TemplateService
from service.user import UserInfoFormDB

View File

@ -4,8 +4,8 @@ from pymysql import IntegrityError
from config import config
from logger import Log
from service.repository import AsyncRepository
from service.cache import RedisCache
from service.repository import AsyncRepository
class AdminService:

View File

@ -10,7 +10,7 @@ from service.base import QuestionData, AnswerData
class RedisCache:
def __init__(self, host="127.0.0.1", port=6379, db=0,loop=None):
def __init__(self, host="127.0.0.1", port=6379, db=0, loop=None):
self._loop = asyncio.get_event_loop()
# Redis 官方文档显示 默认创建POOL连接池
Log.debug(f'获取Redis配置 [host]: {host}')

View File

@ -1,6 +1,6 @@
from model.apihelper import GachaInfo
from service.repository import AsyncRepository
from service.cache import RedisCache
from service.repository import AsyncRepository
class GachaService:

View File

@ -1,6 +1,6 @@
from model.apihelper import Hyperion
from service.repository import AsyncRepository
from service.cache import RedisCache
from service.repository import AsyncRepository
class GetGameInfo:

View File

@ -2,9 +2,9 @@ from typing import List
import ujson
from service.repository import AsyncRepository
from service.cache import RedisCache
from service.base import QuestionData
from service.cache import RedisCache
from service.repository import AsyncRepository
class QuizService:

View File

@ -2,6 +2,7 @@ import asyncio
import os
import time
from typing import Optional
from jinja2 import PackageLoader, Environment, Template
from playwright.async_api import async_playwright, Browser, ViewportSize, Playwright
@ -10,7 +11,7 @@ from logger import Log
class TemplateService:
def __init__(self, template_package_name: str = "resources", cache_dir_name: str = "cache",loop=None):
def __init__(self, template_package_name: str = "resources", cache_dir_name: str = "cache", loop=None):
self._template_package_name = template_package_name
self._browser: Optional[Browser] = None
self._playwright: Optional[Playwright] = None