# keyboard
share_keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
share_button = types.KeyboardButton(text="Share", request_contact=True)
share_keyboard.add(share_button)
@dp.message_handler(ChatTypeFilter(chat_type=types.ChatType.PRIVATE))
async def understand_message_handler(message: types.message):
if message.text == "Register" and not await check_user(message.from_user.id):
await message.answer("Enter phone number:",
reply_markup=share_keyboard)
await Registration.registration_number.set()
@dp.message_handler(state=Registration.registration_number)
async def input_number(message: types.Message, state: FSMContext):
await state.finish()
telephone = message.contact.phone_number
connection = await get_connection()
sql = f"INSERT INTO users(id, number) VALUES ({message.from_user.id}, {telephone})"
cursor = connection.cursor()
cursor.execute(sql)
connection.commit()
# ERROR
'NoneType' object has no attribute 'phone_number'
我使用AIOgram,这不起作用,但是有了telebot,它就能工作了。请告诉我我怎样才能得到im AIOgram号码?
发布于 2022-04-20 23:25:29
默认情况下,消息处理程序只接受文本消息-需要通过添加筛选器content_types=types.ContentType.CONTACT
来更改此行为。
https://stackoverflow.com/questions/71944251
复制相似问题