|
@@ -0,0 +1,30 @@
|
|
|
+#!/usr/bin/env python3
|
|
|
+
|
|
|
+import logging
|
|
|
+import telegram.ext
|
|
|
+from telegram.ext import Updater
|
|
|
+from time import localtime, sleep
|
|
|
+
|
|
|
+def callback(context: telegram.ext.CallbackContext):
|
|
|
+ if 0 <= localtime().tm_hour < 8:
|
|
|
+ context.job.enabled = False
|
|
|
+ return
|
|
|
+
|
|
|
+ context.bot.send_message(chat_id='<CHAT_ID>',
|
|
|
+ text='Did you wash your hands recently?')
|
|
|
+
|
|
|
+logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(7message)s',
|
|
|
+ level=logging.INFO)
|
|
|
+
|
|
|
+updater = Updater(token='<BOT_TOKEN>', use_context=True)
|
|
|
+
|
|
|
+job_queue = updater.job_queue
|
|
|
+job_hour = job_queue.run_repeating(callback, interval=3600, first=0)
|
|
|
+
|
|
|
+updater.start_polling()
|
|
|
+
|
|
|
+while True:
|
|
|
+ if localtime().tm_hour >= 8 and job_hour.enabled == False:
|
|
|
+ job_hour.enabled = True
|
|
|
+
|
|
|
+ sleep(300)
|