mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
格式化代码并优化导入
This commit is contained in:
parent
6b9e06a2e3
commit
56c8ee3591
@ -1,6 +1,7 @@
|
||||
import ujson
|
||||
import os
|
||||
|
||||
import ujson
|
||||
|
||||
|
||||
class Config(object):
|
||||
def __init__(self):
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
5
main.py
5
main.py
@ -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?
|
||||
|
@ -1,3 +1,3 @@
|
||||
from .hyperion import *
|
||||
from .hoyolab import *
|
||||
from .gacha import *
|
||||
from .hoyolab import *
|
||||
from .hyperion import *
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
import os
|
||||
import datetime
|
||||
import os
|
||||
|
||||
import genshin
|
||||
from genshin import GenshinException, DataNotPublic
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
import time
|
||||
import datetime
|
||||
import time
|
||||
|
||||
import genshin
|
||||
from genshin import Game, GenshinException, AlreadyClaimed
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user