Advertisement
MyZik

Untitled

Nov 19th, 2022 (edited)
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.90 KB | None | 0 0
  1. import telebot
  2. from telebot import types
  3. from config import token, channel_link, channel_name, redirect_link, redirect_name
  4.  
  5. bot = telebot.TeleBot(token, parse_mode='html')
  6.  
  7.  
  8. @bot.message_handler(commands=['start'])
  9. def start(message):
  10.     try:
  11.         a = bot.get_chat_member(chat_id=channel_link, user_id=message.from_user.id)
  12.         if not a.status == 'left':
  13.             keyboard = types.InlineKeyboardMarkup(row_width=1)
  14.             btn = types.InlineKeyboardButton(url=redirect_link, text=redirect_name)
  15.             keyboard.add(btn)
  16.             bot.send_message(message.chat.id, f'Наша актуальная ссылка 👇🏻👇🏻👇🏻', reply_markup=keyboard)
  17.         else:
  18.             keyboard = types.InlineKeyboardMarkup(row_width=1)
  19.             btn = [
  20.                 types.InlineKeyboardButton(url=f'https://t.me/{channel_link.replace("@", "")}', text=f'{channel_name}'),
  21.                 types.InlineKeyboardButton(text='Я подписался ✅', callback_data='check')
  22.             ]
  23.             keyboard.add(*btn)
  24.             with open('static/welc.webp', 'rb') as photo:
  25.                     bot.send_photo(message.chat.id, photo, caption=f'Для использования бота необходимо пройти проверку!', reply_markup=keyboard)
  26.     except Exception as e:
  27.         print(e)
  28.         bot.send_message(message.chat.id, f'ошибка')
  29.  
  30.  
  31. @bot.callback_query_handler(func=lambda call: True)
  32. def buttons(call):
  33.     if call.data == 'check':
  34.         try:
  35.             a = bot.get_chat_member(chat_id=channel_link, user_id=call.from_user.id)
  36.             if not a.status == 'left':
  37.                 keyboard = types.InlineKeyboardMarkup(row_width=1)
  38.                 btn = types.InlineKeyboardButton(url=redirect_link,
  39.                                                  text=redirect_name)
  40.                 keyboard.add(btn)
  41.                 bot.send_message(call.message.chat.id, f'ЖМИ 👇🏻👇🏻👇🏻', reply_markup=keyboard)
  42.             else:
  43.                 bot.send_message(call.message.chat.id, f'Вы не подписались на все каналы')
  44.                 keyboard = types.InlineKeyboardMarkup(row_width=1)
  45.                 btn = [
  46.                     types.InlineKeyboardButton(url=f'https://t.me/{channel_link.replace("@", "")}',
  47.                                                text=channel_name),
  48.                     types.InlineKeyboardButton(text='Я подписался ✅', callback_data='check')
  49.                 ]
  50.                 keyboard.add(*btn)
  51.                 with open('static/welc.webp', 'rb') as photo:
  52.                     bot.send_photo(call.message.chat.id, photo, caption=f'Для использования бота необходимо пройти проверку!', reply_markup=keyboard)
  53.         except:
  54.             pass
  55.  
  56.  
  57. try:
  58.     bot.polling(none_stop=True)
  59. except Exception as e:
  60.     print(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement