summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitrii Morozov <snoopdesigns@gmail.com>2024-03-21 21:15:43 +0100
committerDmitrii Morozov <snoopdesigns@gmail.com>2024-03-21 21:15:43 +0100
commit98c1bd81415aa539c6de8a5037c6f62ecf1b673f (patch)
treeef50d5a0ec91dd736771b5e951d687040d0174e7
parentfba09f086bc7fba298bdc2b679adae559019277b (diff)
test
-rwxr-xr-xtgbot.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/tgbot.py b/tgbot.py
index ccc8738..97dcbd0 100755
--- a/tgbot.py
+++ b/tgbot.py
@@ -1,6 +1,7 @@
#!/usr/bin/python3
import os
+import time, threading, schedule
from telebot import TeleBot
from fortniteStatusWrapper import formatFortniteStatus
from pythonFortniteStatus.FortniteStatus import *
@@ -23,4 +24,30 @@ def fortniteStatusCommand(message):
parse_mode='MarkdownV2'
)
-bot.polling(none_stop=True, interval=0) \ No newline at end of file
+#bot.polling(none_stop=True, interval=0)
+
+def beep(chat_id) -> None:
+ """Send the beep message."""
+ bot.send_message(chat_id, text='Beep!')
+
+
+@bot.message_handler(commands=['set'])
+def set_timer(message):
+ args = message.text.split()
+ if len(args) > 1 and args[1].isdigit():
+ sec = int(args[1])
+ schedule.every(sec).seconds.do(beep, message.chat.id).tag(message.chat.id)
+ else:
+ bot.reply_to(message, 'Usage: /set <seconds>')
+
+
+@bot.message_handler(commands=['unset'])
+def unset_timer(message):
+ schedule.clear(message.chat.id)
+
+
+if __name__ == '__main__':
+ threading.Thread(target=bot.infinity_polling, name='bot_infinity_polling', daemon=True).start()
+ while True:
+ schedule.run_pending()
+ time.sleep(1) \ No newline at end of file