From 90a90d4a340d162fd3e6e2c375523ecda5e532e8 Mon Sep 17 00:00:00 2001 From: _run Date: Sat, 9 Jul 2022 22:30:36 +0500 Subject: [PATCH] Divided async and sync versions into aio & sync folders --- examples/asynchronous_telebot/webhooks/run_webhooks.py | 2 +- examples/webhook_examples/run_webhooks.py | 2 +- setup.py | 1 - telebot/__init__.py | 4 ++-- telebot/async_telebot.py | 4 ++-- telebot/{extensions => ext}/__init__.py | 0 telebot/{extensions/asynchronous => ext/aio}/__init__.py | 0 telebot/{extensions/asynchronous => ext/aio}/webhooks.py | 0 telebot/{extensions/synchronous => ext/sync}/__init__.py | 0 telebot/{extensions/synchronous => ext/sync}/webhooks.py | 0 10 files changed, 6 insertions(+), 7 deletions(-) rename telebot/{extensions => ext}/__init__.py (100%) rename telebot/{extensions/asynchronous => ext/aio}/__init__.py (100%) rename telebot/{extensions/asynchronous => ext/aio}/webhooks.py (100%) rename telebot/{extensions/synchronous => ext/sync}/__init__.py (100%) rename telebot/{extensions/synchronous => ext/sync}/webhooks.py (100%) diff --git a/examples/asynchronous_telebot/webhooks/run_webhooks.py b/examples/asynchronous_telebot/webhooks/run_webhooks.py index fa145fc..3b74c33 100644 --- a/examples/asynchronous_telebot/webhooks/run_webhooks.py +++ b/examples/asynchronous_telebot/webhooks/run_webhooks.py @@ -11,7 +11,7 @@ bot = AsyncTeleBot('TOKEN') WEBHOOK_SSL_CERT = './webhook_cert.pem' # Path to the ssl certificate WEBHOOK_SSL_PRIV = './webhook_pkey.pem' # Path to the ssl private key -DOMAIN = '123.12.33.22' # either domain, or ip address of vps +DOMAIN = '1.2.3.4' # either domain, or ip address of vps # Quick'n'dirty SSL certificate generation: # diff --git a/examples/webhook_examples/run_webhooks.py b/examples/webhook_examples/run_webhooks.py index 8332d30..eeac2d1 100644 --- a/examples/webhook_examples/run_webhooks.py +++ b/examples/webhook_examples/run_webhooks.py @@ -12,7 +12,7 @@ bot = telebot.TeleBot(API_TOKEN) WEBHOOK_SSL_CERT = './webhook_cert.pem' # Path to the ssl certificate WEBHOOK_SSL_PRIV = './webhook_pkey.pem' # Path to the ssl private key -DOMAIN = '123.12.33.22' # either domain, or ip address of vps +DOMAIN = '1.2.3.4' # either domain, or ip address of vps # Quick'n'dirty SSL certificate generation: # diff --git a/setup.py b/setup.py index 5552a43..2e60d91 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,6 @@ setup(name='pyTelegramBotAPI', 'redis': 'redis>=3.4.1', 'aioredis': 'aioredis', 'aiohttp': 'aiohttp', - 'flask': 'flask', 'fastapi': 'fastapi', 'uvicorn': 'uvicorn', }, diff --git a/telebot/__init__.py b/telebot/__init__.py index 8d73f63..1c88c17 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -372,8 +372,8 @@ class TeleBot: ssl_context = (certificate, certificate_key) if certificate else (None, None) # webhooks module try: - from telebot.extensions.synchronous import SyncWebhookListener - except NameError: + from telebot.ext.sync import SyncWebhookListener + except (NameError, ImportError): raise ImportError("Please install uvicorn and fastapi in order to use `run_webhooks` method.") self.webhook_listener = SyncWebhookListener(self, secret_token, listen, port, ssl_context, '/'+url_path, debug) self.webhook_listener.run_app() diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 1257e73..e9ee889 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -1515,8 +1515,8 @@ class AsyncTeleBot: ssl_context = (certificate, certificate_key) if certificate else (None, None) # for webhooks try: - from telebot.extensions.asynchronous import AsyncWebhookListener - except NameError: + from telebot.ext.aio import AsyncWebhookListener + except (NameError, ImportError): raise ImportError("Please install uvicorn and fastapi in order to use `run_webhooks` method.") self.webhook_listener = AsyncWebhookListener(self, secret_token, listen, port, ssl_context, '/'+url_path, debug) await self.webhook_listener.run_app() diff --git a/telebot/extensions/__init__.py b/telebot/ext/__init__.py similarity index 100% rename from telebot/extensions/__init__.py rename to telebot/ext/__init__.py diff --git a/telebot/extensions/asynchronous/__init__.py b/telebot/ext/aio/__init__.py similarity index 100% rename from telebot/extensions/asynchronous/__init__.py rename to telebot/ext/aio/__init__.py diff --git a/telebot/extensions/asynchronous/webhooks.py b/telebot/ext/aio/webhooks.py similarity index 100% rename from telebot/extensions/asynchronous/webhooks.py rename to telebot/ext/aio/webhooks.py diff --git a/telebot/extensions/synchronous/__init__.py b/telebot/ext/sync/__init__.py similarity index 100% rename from telebot/extensions/synchronous/__init__.py rename to telebot/ext/sync/__init__.py diff --git a/telebot/extensions/synchronous/webhooks.py b/telebot/ext/sync/webhooks.py similarity index 100% rename from telebot/extensions/synchronous/webhooks.py rename to telebot/ext/sync/webhooks.py