@dp.message_handler(state=Form.mail)
async def mail(message: types.Message, state: FSMContext):
pay = message.text
async with state.proxy() as data:
quantit = data['quantit']
address = data['address']
want_to_do = data['want_to_do']
begin = data['begin']
if quantit > 1 and quantit < 5:
quantit = "нужно " + str(quantit) + " человека"
elif quantit == 1:
quantit = "нужен " + str(quantit) + " человек"
elif quantit < 9 and quantit > 4:
quantit = "нужно " + str(quantit) + " человек"
db.add_work(quantit, address, want_to_do, begin, pay)
ids = db.id_exists()
work_data = db.work_data(ids)
for row in work_data:
work = "1"
results = db.mailling()
async with state.proxy() as data:
quantit = data['quantit']
buttons = "keyboard_" + str(quantit)
for result in results:
await bot.send_message(result[0], work)
id = int(f"{row[7]}")
message_id = message.message_id
db.add_message_id(id, message_id)
print(message.message_id)
print(message.chat.id)
await state.finish()
#### изменение текста заявки
@dp.callback_query_handler(lambda c: c.data == "edit_statuss")
async def edit_status(call: types.callback_query):
await bot.edit_message_text(text="выберите статус заявки", chat_id=call.message.chat.id, message_id=call.message.message_id)
@dp.callback_query_handler(lambda c: c.data == "status_closed")
async def status_closed(call: types.callback_query):
await bot.edit_message_text(text="Введите id заявки", chat_id=call.message.chat.id, message_id=call.message.message_id)
await Form.status_closed_mess_id.set()
@dp.message_handler(state=Form.status_closed_mess_id)
async def status_closed_mail(message: types.Message, state: FSMContext):
id = message.text
chat_id = 1623734733 #мой id
works_list = db.works_list(id)
for row in works_list:
await bot.edit_message_text(chat_id=chat_id, message_id=row[8], text='2')