import telebot
from telebot import types
import config
subs = types.InlineKeyboardMarkup()
sub1 = types.InlineKeyboardButton(text="Подписаться - 1", url=config.channel)
checking = types.InlineKeyboardButton(text="Проверить", callback_data="check")
subs.add(sub1, checking)
bot = telebot.TeleBot(config.token)
@bot.message_handler(commands=['start'])
def welcome(message):
bot.send_message(message.chat.id, text="Приветствую тебя <b>{0.first_name}</b>\nПодпишись что-бы продолжить!".format(message.from_user, bot.get_me()),
reply_markup=subs, parse_mode='html')
@bot.callback_query_handler(func=lambda call: True)
def callback(call):
try:
if call.message:
if call.data == "check":
status = ['creator', 'administrator', 'member']
for i in status:
if i == bot.get_chat_member(chat_id=config.channel_id, user_id=call.from_user.id).status:
cont = types.InlineKeyboardMarkup()
dalee = types.InlineKeyboardButton(text="Начать пользоваться!", callback_data="daleee")
cont.add(dalee)
chat_id = call.message.chat.id
bot.send_message(chat_id, "Поздравляю вы получили доступ к боту!", reply_markup=cont)
break
else:
chat_id = call.message.chat.id
bot.send_message(chat_id, "Проверьте подписаны ли вы на канал ещё раз!")
except Exception as e:
print(repr(e))
def start(call):
if call.data == "daleee":
chat_id = call.message.chat.id
bot.send_message(chat_id, "TEXT!")
bot.polling(none_stop=True)