Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from telebot import types
- bot = telebot.TeleBot("***")
- CHANNEL_ID = -1001411197591
- @bot.message_handler(commands=['start'])
- def send_welcome(message):
- markup = types.InlineKeyboardMarkup()
- but_1 = (types.InlineKeyboardButton("Subscribe to the channel", url="https://t.me/Powerful_IELTS")) #text, kanal
- confirmkb = types.InlineKeyboardMarkup()
- but_2 = types.InlineKeyboardButton(text="Confrim", callback_data="Confirm")
- confirmkb.add(but_1,but_2)
- 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"
- bot.send_message(message.chat.id, send_mess, parse_mode='html', reply_markup=confirmkb)
- @bot.callback_query_handler(func=lambda callback:True)
- def callback(callback):
- if callback.data == "Confirm":
- status = bot.get_chat_member(CHANNEL_ID,message.from_user.id).status
- if status in ["administrator","member","creator"]:
- bot.send_message(message.chat.id,"Congratulations")
- bot.forward_message(message.chat.id,'-1001287717578', '2' ) #(чат в боте, канал, пост)
- else:
- bot.send_message(message.chat.id, "I'm sorry, you have not subscribed yet. Make sure to subscribe and then type CONFIRM")
- bot.polling(none_stop=True)
Add Comment
Please, Sign In to add comment