Stuff
This commit is contained in:
parent
1e6e84fdf1
commit
6d91c74e2e
4 changed files with 27 additions and 0 deletions
BIN
mp3/2019-6-21.mp3
Normal file
BIN
mp3/2019-6-21.mp3
Normal file
Binary file not shown.
BIN
mp3/wave.mp3
Normal file
BIN
mp3/wave.mp3
Normal file
Binary file not shown.
25
run.py
25
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()
|
||||
|
|
2
sendDays/.gitignore
vendored
Normal file
2
sendDays/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
!.gitignore
|
||||
2*
|
Reference in a new issue