Как в функции вызвать другую функцию?

Рейтинг: -2Ответов: 1Опубликовано: 02.08.2023
@bot.message_handler(func=lambda message: True)
def echo_message(message):
    text = message.text
    global flag
    global filmCode
    chat_id = message.chat.id
    if flag == False:
        if text == "Бот":
            check(call)**ТУТ ВЫЗОВ ФУНКЦИИ**
            bot.send_message(chat_id, "#", reply_markup=start_markup())
            
        else:
            check(call)**ТУТ ВЫЗОВ ФУНКЦИИ**
            bot.send_message(chat_id, "#", reply_markup=start_markup())
    else:
        check(call)**ТУТ ВЫЗОВ ФУНКЦИИ**


def check(call):
    status = ['creator', 'administrator', 'member']
    global flag
    for i in status:
        if i == bot.get_chat_member(chat_id="-1001983985312",user_id=call.message.chat.id).status:
            flag = True
            print(flag)
            check2(call)
            break
    else:
        bot.send_message(call.message.chat.id, "#", reply_markup=start_markup())
        flag = False

Нудно вызвать функцию check(call), написав в функции echo_message check(call) Выдает ошибку "NameError: name 'call' is not defined"

Ответы

▲ 0

Тести ;)

@bot.message_handler(func=lambda message: True)
def echo_message(message, call=None):
    text = message.text
    global flag
    global filmCode
    chat_id = message.chat.id
    if flag == False:
        if text == "Бот":
            check(call)
            bot.send_message(chat_id, "#", reply_markup=start_markup())
        else:
            check(call)
            bot.send_message(chat_id, "#", reply_markup=start_markup())
    else:
        check(call)