Platitude

Untitled

May 10th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. class Form_registration(StatesGroup):
  2.     name = State()
  3.  
  4. @dp.callback_query_handler(lambda c: c.data == 'edit_name')
  5. async def send_name(callback_query: types.CallbackQuery):
  6.     await bot.answer_callback_query(callback_query.id)
  7.     await Form_registration.name.set()
  8.     await bot.send_message(callback_query.from_user.id, 'Укажите имя: ')
  9.  
  10.  
  11. @dp.message_handler(state=Form_registration.name)
  12. async def send_password(message: types.Message, state: FSMContext):
  13.     async with state.proxy() as data:
  14.         data['name'] = message.text
  15.     user_id = message.chat.id
  16.     r = requests.post(http_getusertoken, json={"password": "1488", "telegram_id": int(user_id)})
  17.     TOKEN_USER = r.json()["access_token"]
  18.     headers = {"Authorization": "Bearer " + TOKEN_USER}
  19.     requests.post(http_setown, json={"firstName": message.text},
  20.                   headers=headers)
  21.     await bot.send_message(message.chat.id, "Вы успешно изменили имя")
Add Comment
Please, Sign In to add comment