diff --git a/mp3/2019-6-21.mp3 b/mp3/2019-6-21.mp3 new file mode 100644 index 0000000..3fd2e43 Binary files /dev/null and b/mp3/2019-6-21.mp3 differ diff --git a/mp3/wave.mp3 b/mp3/wave.mp3 new file mode 100644 index 0000000..3fd2e43 Binary files /dev/null and b/mp3/wave.mp3 differ diff --git a/run.py b/run.py index 6d8dfde..c16b988 100644 --- a/run.py +++ b/run.py @@ -1,12 +1,17 @@ from telegram.ext import CommandHandler +import os +import datetime +import telegram import logging import json from config import updater +from config import bot logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) +j = updater.job_queue def hello(bot, update): @@ -58,11 +63,31 @@ def saveUser(users): f.write(j) f.close() +def sendAudio(a, b): + print(datetime.datetime.now().hour) + day = str(datetime.datetime.now().year)+"-"+str(datetime.datetime.now().month)+"-"+str(datetime.datetime.now().day) + print("DAY: "+str(day)) + if datetime.datetime.now().hour >= 6: + if not os.path.exists('./sendDays/'+day): + f = open("./sendDays/"+day, "w") + f.write("DONE") + f.close() + if os.path.exists('mp3/'+day+'.mp3'): + a.send_message(chat_id='184170946', text='Der frühe Vogel fängt den Wurm, und hier ist deine motivation für heute:') + a.send_audio(chat_id='184170946', audio=open('mp3/'+day+'.mp3', 'rb')) + else: + a.send_message(chat_id='184170946', text='Für heute habe ich keine Motivierende nachricht gefunden, das wird bestimmt ein scheiß tag :(') + + + updater.dispatcher.add_handler(CommandHandler('hello', hello)) updater.dispatcher.add_handler(CommandHandler('subscribe', subscribe)) updater.dispatcher.add_handler(CommandHandler('unsubscribe', unsubscribe)) updater.dispatcher.add_handler(CommandHandler('start', start)) +job_minute = j.run_repeating(sendAudio, interval=60, first=0) + +#bot.send_audio(chat_id=184170946, audio=open('mp3/wave.mp3', 'rb')) updater.start_polling() updater.idle() diff --git a/sendDays/.gitignore b/sendDays/.gitignore new file mode 100644 index 0000000..862dd6e --- /dev/null +++ b/sendDays/.gitignore @@ -0,0 +1,2 @@ +!.gitignore +2*