import schedule
import time
import threading
def job():
print("I'm working...")
schedule.every(1).minutes.do(job)
def go():
while 1:
schedule.run_pending()
time.sleep(1)
t = threading.Thread(target=go, name="тест")
t.start()
@bot.message_handler(commands=['info'])
def handle_text(message):
answer = 'БЛА-БЛА-БЛА.'
bot.send_message(message.chat.id, answer)
if __name__ == '__main__':
bot.polling(none_stop=True, interval=0)
for_info = {
"message.message_id": message.message_id,
"info_bu":{
"status_s": status_s,
"namber_b": namber_b,
"id_answers": id_answers_links
}
}
info_story = json.load(open("story.json"))
info_story.append(for_info)
with open("story.json", "w") as file:
json.dump(info_story, file, ensure_ascii=True)
if ts != 0:
if ts != 0 and tts != 0:
key = make_batton_imper(message, ts, tts, add_buttons="all")
elif ts != 0 and tts == 0:
key = make_batton_imper(message, ts, tts, add_buttons="pass")
answer = "бла-бла-бла с кнопками"
bot.send_message(message.chat.id, answer, reply_markup=key, parse_mode='Markdown')
else:
answer = "бла-бла-бла без кнопок"
bot.send_message_text(message.chat.id, answer, parse_mode='Markdown')
def make_batton_imper(message, ts, tts, add_buttons):
key = telebot.types.InlineKeyboardMarkup(row_width=2)
data_but = "id_"+str(ts)
but_i = telebot.types.InlineKeyboardButton(text=" + 1", callback_data=data_but)
data_but_p = "id_"+str(tts)
but_py = telebot.types.InlineKeyboardButton(text=" + 2", callback_data=data_but_p)
if add_buttons == "pass":
key.add(but_py)
elif add_buttons == "all":
key.row(but_i, but_py)
return key
def log (message):
msg_to_me=str("Сообщение от: "+ message.from_user.first_name+" ID: "+str(message.from_user.id)+ "\nТекст: "+ message.text)
bot.send_message(constants.my_chat_id, msg_to_me)
Сообщение от: Myza ID: 000000000000
Текст: Привет! Ты самый лучший бот на свете....
import fsm_telebot
from fsm_telebot.storage.memory import MemoryStorage
storage = MemoryStorage()
bot.set_state('level_1', message.chat.id)
@bot.message_handler(state='level_1')