'How i can add moderation
How i can add moderation(so that the administrator can reject and accept the questionnaire from the user and the corresponding message is sent to the user(I tried to make it as a new state but it didn't work(((I managed to make him send all this information, but it was impossible not to accept or reject it)) to this part of code:
@dp.message_handler(commands="order", state=None)
async def cm_start(message: types.Message):
if not db.user_exists(message.from_user.id):
db.add_user(message.from_user.id)
db.set_signup(message.from_user.id, "name")
await FSMAdmin.name.set()
await message.reply("Enter your name", reply_markup=button_case_admin)
else:
await FSMAdmin.stop.set()
await message.reply("Your booking is already being considered, if you want to cancel it, select the /cancel command",
reply_markup=button_case_admin)
@dp.message_handler(state=FSMAdmin.name)
async def name(message: types.Message, state: FSMContext):
async with state.proxy() as data:
data['name'] = message.text
db.set_name(message.from_user.id, message.text)
db.set_signup(message.from_user.id, "number")
await FSMAdmin.next()
await message.reply("Now enter your number")
# await db.add_user(message.from_user.id)
# await db.set_name(state)
@dp.message_handler(state=FSMAdmin.number)
async def number(message: types.Message, state: FSMContext):
async with state.proxy() as data:
data['number'] = message.text
db.set_number(message.from_user.id, message.text)
db.set_signup(message.from_user.id, "date")
await FSMAdmin.next()
await message.reply("Enter date")
@dp.message_handler(state=FSMAdmin.date)
async def date(message: types.Message, state: FSMContext):
async with state.proxy() as data:
data['date'] = message.text
db.set_date(message.from_user.id, message.text)
db.set_signup(message.from_user.id, "time")
await FSMAdmin.next()
await message.reply("Enter the time")
@dp.message_handler(state=FSMAdmin.time)
async def time(message: types.Message, state: FSMContext):
async with state.proxy() as data:
data['time'] = message.text
db.set_time(message.from_user.id, message.text)
db.set_signup(message.from_user.id, "people")
await FSMAdmin.next()
await message.reply("Enter the number of people")
@dp.message_handler(state=FSMAdmin.people)
async def people(message: types.Message, state: FSMContext):
async with state.proxy() as data:
data['people'] = message.text
db.set_people(message.from_user.id, message.text)
db.set_signup(message.from_user.id, "moderation")
await state.finish()
await bot.send_message(message.chat.id, "The questionnaire has been successfully completed, after verification you will receive a response.")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
