Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import telegram
  2. from telegram import KeyboardButton
  3. from telegram import ReplyKeyboardMarkup
  4. from telegram.ext import Updater, CommandHandler, MessageHandler
  5. bot_token = "TOKEN"
  6. updater = Updater(token=bot_token, use_context=True)
  7. dispatcher = updater.dispatcher
  8.  
  9. def start(update, context):
  10. contact_keyboard = telegram.KeyboardButton(text="Share contact", request_contact=True)
  11. custom_keyboard = (contact_keyboard)
  12. reply_markup = telegram.ReplyKeyboardMarkup (custom_keyboard)
  13. first_name = update.message.from_user.first_name
  14. msg = "Hello {} to access the group you need to share your phone contact".format (first_name)
  15. context.bot.sendMessage(chat_id=update.message.chat_id, text=msg)
  16. start_handler = CommandHandler('start', start)
  17. dispatcher.add_handler(start_handler)
  18.  
  19.  
  20.  
  21. def echo(update, context):
  22. context.bot.sendMessage(chat_id=update.message.chat_id,text="Error,enter your contact number")
  23. echo_handler=MessageHandler(Filters.text,echo)
  24. dispatcher.add_handler(echo_handler)
  25.  
  26. updater.start_polling()
  27. updater.idle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement