Python:
from aiogram import Bot, types
from aiogram.contrib.middlewares.logging import LoggingMiddleware
from aiogram.dispatcher import Dispatcher
from aiogram.dispatcher.webhook import SendMessage
from aiogram.utils.executor import start_webhook
API_TOKEN = '63179018№№№№№AAGCgv1AnIh900AWkhalSm0ELsQF8wFoysE'
tokens = ('6317901836:№№№№№№AnIh900AWkhalSm0ELsQF8wFoysE','58740№№№№№EpGQBBRqyQIB52cv6ERzvM1MZt-tM')
# webhook settings
WEBHOOK_HOST = 'ngrok'
WEBHOOK_PATH = ''
WEBHOOK_URL = f"https://37cf-37-20-130-247.ngrok.io{WEBHOOK_PATH}"
# webserver settings
WEBAPP_HOST = 'localhost' # or ip
WEBAPP_PORT = 8000
bot = Bot(token=tokens)
dp = Dispatcher(bot)
@dp.message_handler(text='/start')
async def echo(message: types.Message):
await message.answer('Привет')
async def on_startup(dp):
await bot.set_webhook(WEBHOOK_URL)
async def on_shutdown(dp):
await bot.delete_webhook()
await dp.storage.close()
await dp.storage.wait_closed()
if __name__ == '__main__':
start_webhook(
dispatcher=dp,
webhook_path=WEBHOOK_PATH,
on_startup=on_startup,
on_shutdown=on_shutdown,
skip_updates=True,
host=WEBAPP_HOST,
port=WEBAPP_PORT,
)