1

I have the following code (Aiogram 3.0.0b):

from ..forms import *

@router.message(Command(commands='register_journal'))
async def initiate_register_journal_command(message: types.Message, state: FSMContext):

    current_user_id = message.from_user.id
    await message.reply(text="Initiating registration")
    # await asyncio.sleep(3)
    await message.reply(text=JournalForm.label)
    await state.set_state(JournalForm.current_user_id)
    await state.update_data(current_user_id=current_user_id) #worked fine
    await state.set_state(JournalForm.name)



@router.message(JournalForm.name) # , CurrentUserFilter(JournalForm.current_user_id))
async def handle_registered_journal_data(message: types.Message, state: FSMContext):
    name = message.text

    if not Journal.objects.get(name=name):
        state.set_state(JournalForm.name)
        state.update_data(name=name)
        group_id = message.chat.id
        add_journal(name, group_id)
    else: message.reply(text="Error: For the platoon's assignment the journal has already been created")

THE FORM IS:

class JournalForm(StatesGroup):

    current_user_id = State()
    name = State()

    label = "Platoon number"
    сallback_text = "A journal of visits to the platoon has been created!"
    on_registration_fail_text = "An error occurred while registering a platoon, please try again later"

The problem is that when I send my platoons Name the handle_registered_journal_data is not triggered. The initiate_register_journal_command seems to work just fine.


I revealed that if I run initiate_journal_registration_command in a group (as I did before and all the time) then it is stuck. On the other hand if I try to run it in my private chat with bot, then it works fine. I assume the problem to be that bot does not process the messages sent to the group for some reason.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Dimon Agon
  • 11
  • 4
  • The problem with in-group registration was that I did not set privacy mode to False at BotFather. The instruction is to type /mybots, go bot->Bot Settings->Group Privacy and turn it off. Thanks to [solution source link](https://stackoverflow.com/questions/38565952/how-to-receive-messages-in-group-chats-using-telegram-bot-api) – Dimon Agon Apr 06 '23 at 20:01

0 Answers0