2017-08-21 2 views
-2

Bonjour j'ai un code ce code envoie le contactPython TelegramBot enregistrer des contacts

keyboard = types.ReplyKeyboardMarkup(one_time_keyboard=False) 
    reg_button = types.KeyboardButton(text="...", request_contact=True) 
    keyboard.add(reg_button) 
    keyboard.row('...') 
    response = bot.send_message(message.chat.id,'...', 
           reply_markup=keyboard) 
    print(response.contact) # response.contact = None here 

Pourquoi enregistrer un contact dans le fichier ou base de données. Aide s'il vous plaît :)

Répondre

0

#bot envoie les données reçues au canal

@bot.message_handler(content_types=['contact','location']) def send_welcome(message): first_name = message.from_user.first_name.decode("utf-8") user_id = message.from_user.id username = message.chat.username chat_id = message.chat.id if message.contact: pn = message.contact.phone_number cf = message.contact.first_name bot.send_message(YOUR_CHANNEL_ID, "#contact [{0}](https://telegram.me/{1})".format(user_id, username), parse_mode="Markdown", disable_web_page_preview=True) bot.send_contact(YOUR_CHANNEL_ID, phone_number=pn, first_name=cf) if message.location: bot.send_message(YOUR_CHANNEL_ID, "#location [{0}](https://telegram.me/{1})".format(user_id, username), parse_mode="Markdown", disable_web_page_preview=True) bot.send_location(YOUR_CHANNEL_ID, message.location.latitude, message.location.longitude)