Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from telebot import types
- from config import token, channel_link, channel_name, redirect_link, redirect_name
- bot = telebot.TeleBot(token, parse_mode='html')
- @bot.message_handler(commands=['start'])
- def start(message):
- try:
- a = bot.get_chat_member(chat_id=channel_link, user_id=message.from_user.id)
- if not a.status == 'left':
- keyboard = types.InlineKeyboardMarkup(row_width=1)
- btn = types.InlineKeyboardButton(url=redirect_link, text=redirect_name)
- keyboard.add(btn)
- bot.send_message(message.chat.id, f'Наша актуальная ссылка 👇🏻👇🏻👇🏻', reply_markup=keyboard)
- else:
- keyboard = types.InlineKeyboardMarkup(row_width=1)
- btn = [
- types.InlineKeyboardButton(url=f'https://t.me/{channel_link.replace("@", "")}', text=f'{channel_name}'),
- types.InlineKeyboardButton(text='Я подписался ✅', callback_data='check')
- ]
- keyboard.add(*btn)
- with open('static/welc.webp', 'rb') as photo:
- bot.send_photo(message.chat.id, photo, caption=f'Для использования бота необходимо пройти проверку!', reply_markup=keyboard)
- except Exception as e:
- print(e)
- bot.send_message(message.chat.id, f'ошибка')
- @bot.callback_query_handler(func=lambda call: True)
- def buttons(call):
- if call.data == 'check':
- try:
- a = bot.get_chat_member(chat_id=channel_link, user_id=call.from_user.id)
- if not a.status == 'left':
- keyboard = types.InlineKeyboardMarkup(row_width=1)
- btn = types.InlineKeyboardButton(url=redirect_link,
- text=redirect_name)
- keyboard.add(btn)
- bot.send_message(call.message.chat.id, f'ЖМИ 👇🏻👇🏻👇🏻', reply_markup=keyboard)
- else:
- bot.send_message(call.message.chat.id, f'Вы не подписались на все каналы')
- keyboard = types.InlineKeyboardMarkup(row_width=1)
- btn = [
- types.InlineKeyboardButton(url=f'https://t.me/{channel_link.replace("@", "")}',
- text=channel_name),
- types.InlineKeyboardButton(text='Я подписался ✅', callback_data='check')
- ]
- keyboard.add(*btn)
- with open('static/welc.webp', 'rb') as photo:
- bot.send_photo(call.message.chat.id, photo, caption=f'Для использования бота необходимо пройти проверку!', reply_markup=keyboard)
- except:
- pass
- try:
- bot.polling(none_stop=True)
- except Exception as e:
- print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement