def run_multibot(bot: Bot, apis: Iterable["ABCAPI"], polling_type: Type["ABCPolling"] = BotPolling): """Add run_polling with polling constructed from derived apis :param bot: Bot main instance (api is not required) :param apis: Iterable of apis :param polling_type: polling type to be ran """ for i, api_instance in enumerate(apis): logger.debug("Connecting API (index: {})", i) polling = polling_type().construct(api_instance) api_instance.http_client = SingleAiohttpClient() bot.loop_wrapper.add_task(bot.run_polling(custom_polling=polling)) bot.loop_wrapper.run_forever()
def __init__( self, token: "Token", ignore_errors: bool = False, http_client: Optional["ABCHTTPClient"] = None, request_rescheduler: Optional["ABCRequestRescheduler"] = None, ): self.token_generator = get_token_generator(token) self.ignore_errors = ignore_errors self.http_client = http_client or SingleAiohttpClient() self.request_rescheduler = request_rescheduler or BlockingRequestRescheduler() self.response_validators: List["ABCResponseValidator"] = DEFAULT_RESPONSE_VALIDATORS self.request_validators: List["ABCRequestValidator"] = DEFAULT_REQUEST_VALIDATORS # type: ignore self.captcha_handler: Optional[CaptchaHandler] = None
async def test_client_init(): client = AiohttpClient(test="test") assert client._session_params["test"] == "test" singleton_client = SingleAiohttpClient(test="test") assert singleton_client._session_params["test"] == "test"