From 8814979ceff496105f957ff7d898f19327905f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Wed, 22 Mar 2023 13:09:24 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Update=20timeout=20config=20of?= =?UTF-8?q?=20`Hyperion`=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/apihelper/client/components/hyperion.py | 4 ++-- plugins/admin/post.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/apihelper/client/components/hyperion.py b/modules/apihelper/client/components/hyperion.py index ccecc00..0fff33a 100644 --- a/modules/apihelper/client/components/hyperion.py +++ b/modules/apihelper/client/components/hyperion.py @@ -25,8 +25,8 @@ class Hyperion: "Chrome/90.0.4430.72 Safari/537.36" ) - def __init__(self): - self.client = HyperionRequest(headers=self.get_headers()) + def __init__(self, *args, **kwargs): + self.client = HyperionRequest(headers=self.get_headers(), *args, **kwargs) @staticmethod def extract_post_id(text: str) -> int: diff --git a/plugins/admin/post.py b/plugins/admin/post.py index dab424a..6960054 100644 --- a/plugins/admin/post.py +++ b/plugins/admin/post.py @@ -1,6 +1,7 @@ from typing import List, Optional, Tuple, TYPE_CHECKING, Union from bs4 import BeautifulSoup +from httpx import Timeout from telegram import ( InlineKeyboardButton, InlineKeyboardMarkup, @@ -47,7 +48,14 @@ class Post(Plugin.Conversation): MENU_KEYBOARD = ReplyKeyboardMarkup([["推送频道", "添加TAG"], ["编辑文字", "删除图片"], ["退出"]], True, True) def __init__(self): - self.bbs = Hyperion() + self.bbs = Hyperion( + timeout=Timeout( + connect=config.connect_timeout, + read=config.read_timeout, + write=config.write_timeout, + pool=config.pool_timeout, + ) + ) self.last_post_id_list: List[int] = [] async def initialize(self):