es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Tag: AIOGRAM

Usar el comando “await” con threading.

Estoy teniendo un problema al usar el threading. Necesito enviar la función Start en un hilo separado. Start función: async def Start(bot, message): await bot.send_message(message.chat.id, 'hola') @dp.message_handler(state=UpdateTime.UpdateTime) async def process_name(message: types.Message, state: FSMContext): if message.text.isdigit(): th = Thread(target= Start, args=(bot, message)) th.start() await state.finish() Error: RuntimeWarning: coroutine 'Start' was never . . . Read more

No puedo obtener el ID de usuario.

Estaba escribiendo un bot y estaba lidiando con este problema. ¿Quién sabe cómo arreglarlo? from aiogram import Bot, types from aiogram.dispatcher import Dispatcher from aiogram.types import message from aiogram.utils import executor import os bot = Bot(token=os.getenv(‘TOKEN’)) dp = Dispatcher(bot) @dp.message_handler(commands=[‘start’, ‘help’]) async def commands_start(message: types.Message): await bot.send_message(message.from_user.id, “¡Hola, ¿quién eres?”) . . . Read more

Cómo reiniciar el estado en aiogram FSM sin reiniciar los datos.

Estoy desarrollando un bot de Telegram utilizando Python 3.9.7 y aiogram 2.16. Al final de mi función, quiero restablecer el estado del usuario sin borrar los datos almacenados. Intenté usar state.finish(), pero este método elimina todos los datos guardados del almacenamiento. Aquí está el código: if user_data.get(“chosen_groups”) == “fired”: # . . . Read more