@ScaRS_S

Хочу использовать метод schedule, но он не срабатывает, как правильно его поставить?

В ошибку выкидывает 'foo' missing 1 positional argument 'message'

import telebot
from telebot import types
import schedule
import time
import random
from threading import Thread
from schedule import repeat, every

bot = telebot.TeleBot("***")

def schedule_checker():
    while True:
        schedule.run_pending()
        time.sleep(1)


@bot.message_handler(content_types=['text'])
def foo(message):
    keyboard = types.InlineKeyboardMarkup()
    url_button = types.InlineKeyboardButton(text="Перейти на опрос", url="https://docs.google.com/forms/d/e/***")
    keyboard.add(url_button)
    msg=bot.send_message(message.chat.id, "Привет! Нажми на кнопку и перейди в опрос.",reply_markup=keyboard)
    return bot.register_next_step_handler(msg, chat)

def chat(message):
    lines = open("test.txt", encoding="utf8").read().splitlines()
    randomline1 = random.choice(lines)
    time.sleep(5)
    msg=bot.send_message(message.chat.id, text=randomline1)
    print(randomline1)
    return bot.register_next_step_handler(msg, doo)

def doo(message):
    keyboard = types.InlineKeyboardMarkup()
    url_button = types.InlineKeyboardButton(text="Перейти на опрос2",url="https://docs.google.com/forms/d/e/***")
    keyboard.add(url_button)
    msg=bot.send_message(message.chat.id, "Привет! Нажми на кнопку и перейди в опрос.2",reply_markup=keyboard)
    return bot.register_next_step_handler(msg, chat2)

def chat2(message):
    lines = open("test.txt", encoding="utf8").read().splitlines()
    randomline1 = random.choice(lines)
    time.sleep(5)
    bot.send_message(message.chat.id, text=randomline1)
    print(randomline1)
if __name__=="__main__":

    schedule.every().day.at("19:11").do(foo) and schedule.every().day.at("19:12").do(doo)
    Thread(target=schedule_checker).start()



while True:
    schedule.run_pending()
    bot.polling(none_stop=True)
    time.sleep(1)
  • Вопрос задан
  • 99 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
SpectrumData Екатеринбург
от 150 000 до 200 000 ₽
Гринатом Москва
от 150 000 ₽
Greenway Global Новосибирск
от 150 000 ₽
16 июн. 2024, в 08:11
1000 руб./за проект
16 июн. 2024, в 07:58
600 руб./в час
16 июн. 2024, в 07:57
10000 руб./за проект