Как отправить за раз два запроса на сервер Python
@dp.callback_query_handler(text='mortal', state=Admin.admin1)
async def user(call: types.CallbackQuery, state: FSMContext):
a = DeleteMessage(chat_id=call.message.chat.id, message_id=call.message.message_id)
b = SendMessage(chat_id=call.message.chat.id, text=f"Добро пожаловать! {call.from_user.full_name}",
reply_markup=menu_god)
await state.finish()
return a
Как мне отправить два запроса (a,b) с помощью return
return a,b
return [a,b]
return a and b
return a or b
Они никак не помогли
Запрос отправляется в телеграм API /sendMessage /deleteMessage
import logging
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 = ''
# webhook settings
WEBHOOK_HOST = 'https://xxxxx211.eu.ngrok.io'
WEBHOOK_PATH = ''
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}"
# webserver settings
WEBAPP_HOST = 'localhost' # or ip
WEBAPP_PORT = 5000
logging.basicConfig(level=logging.INFO)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
dp.middleware.setup(LoggingMiddleware())
@dp.message_handler()
async def echo(message: types.Message):
# Regular request
# await bot.send_message(message.chat.id, message.text)
# or reply INTO webhook
return SendMessage(message.chat.id, message.text)
async def on_startup(dp):
await bot.set_webhook(WEBHOOK_URL.format(token=API_TOKEN))
with bot.with_token("token"):
await bot.set_webhook(WEBHOOK_URL.format(token="token"))
with bot.with_token("token2"):
await bot.set_webhook(WEBHOOK_URL.format(token="token2"))
async def on_shutdown(dp):
logging.warning('Shutting down..')
# insert code here to run it before shutdown
# Remove webhook (not acceptable in some cases)
await bot.delete_webhook()
with bot.with_token("token"):
await bot.delete_webhook()
with bot.with_token("token2"):
await bot.delete_webhook()
# Close DB connection (if used)
await dp.storage.close()
await dp.storage.wait_closed()
logging.warning('Bye!')
if __name__ == '__main__':
start_webhook(
dispatcher=dp,
webhook_path=WEBHOOK_PATH,
on_startup=on_startup,
on_shutdown=on_shutdown,
host=WEBAPP_HOST,
port=WEBAPP_PORT,
)
Вот полный код-пример