Guest User

Untitled

a guest
May 7th, 2020
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import telebot
  2. from telebot import types
  3.  
  4. bot = telebot.TeleBot("***")
  5. CHANNEL_ID = -1001411197591
  6.  
  7. @bot.message_handler(commands=['start'])
  8. def send_welcome(message):
  9. markup = types.InlineKeyboardMarkup()
  10. but_1 = (types.InlineKeyboardButton("Subscribe to the channel", url="https://t.me/Powerful_IELTS")) #text, kanal
  11. confirmkb = types.InlineKeyboardMarkup()
  12. but_2 = types.InlineKeyboardButton(text="Confrim", callback_data="Confirm")
  13. confirmkb.add(but_1,but_2)
  14. send_mess = f"<b>Hello {message.from_user.first_name} {message.from_user.last_name}</b>!\nIn order to get free books you must subscribe to our channel"
  15. bot.send_message(message.chat.id, send_mess, parse_mode='html', reply_markup=confirmkb)
  16.  
  17.  
  18.  
  19. @bot.callback_query_handler(func=lambda callback:True)
  20. def callback(callback):
  21. if callback.data == "Confirm":
  22. status = bot.get_chat_member(CHANNEL_ID,message.from_user.id).status
  23. if status in ["administrator","member","creator"]:
  24. bot.send_message(message.chat.id,"Congratulations")
  25. bot.forward_message(message.chat.id,'-1001287717578', '2' ) #(чат в боте, канал, пост)
  26. else:
  27. bot.send_message(message.chat.id, "I'm sorry, you have not subscribed yet. Make sure to subscribe and then type CONFIRM")
  28.  
  29. bot.polling(none_stop=True)
Add Comment
Please, Sign In to add comment