M
M
Mak_Sweet2022-02-13 16:33:29
Python
Mak_Sweet, 2022-02-13 16:33:29

After clicking on Check it gives NameError: name 'call' is not defined. Did you mean: 'call'?

import os
import telebot  
import config
from telebot import types

if os.name == "nt":
  os.system("cls")
else:
  os.system("clear")

bot = telebot.TeleBot(config.TOKEN)


@bot.message_handler(commands=['start'])
def start(message):

  sub = telebot.types.InlineKeyboardMarkup()

  sub.add(telebot.types.InlineKeyboardButton("Подписаться - 1", callback_data="Sub1", url=config.URL_CHANNEL))
  sub.add(telebot.types.InlineKeyboardButton("Проверить", callback_data="check_sub"))

  bot.send_message(message.chat.id, text="Приветствую тебя <b>{0.first_name}</b>!\nПеред началом нужно подписаться на канал что-бы получить доступ!".format(message.from_user, bot.get_me()), reply_markup=sub ,
  		parse_mode="html")

@bot.callback_query_handler(func=lambda call: True)
def check(сall):
  if call.data == "check_sub":
    
      status = ['creator', 'administrator', 'member']
      
      for i in status:
        if i == bot.get_chat_member(chat_id=config.ID_CHANNEL, user_id=message.from_user.id).status:
          chat_id = message.chat.id
          bot.send_message(chat_id, "Проверка прошла успешно")
          break

  else:
    chat_id = message.chat.id
    bot.send_message(chat_id, text = "Проверка не пройдена")

bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-02-13
@Mak_Sweet

"c" - Cyrillic

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question