Bot into main #71
@ -8,8 +8,10 @@ __license__ = "None"
|
||||
|
||||
from shares.share_fetcher import get_share_price
|
||||
import time
|
||||
import datetime
|
||||
from bot import bot
|
||||
import sys
|
||||
from multiprocessing import Process
|
||||
|
||||
'''
|
||||
* * * * * code
|
||||
@ -34,8 +36,53 @@ def main_loop():
|
||||
:rtype: none
|
||||
"""
|
||||
|
||||
current_time = time.ctime()
|
||||
send_to_user(current_time)
|
||||
current_time_datetime = datetime.datetime.now()
|
||||
|
||||
print(time.ctime()) # Debug
|
||||
|
||||
p1 = Process(target= update_crontab, args=(current_time_datetime, )) #Test threading instead of multiprocessing
|
||||
p1.start()
|
||||
p3 = Process(target= update_based_on_crontab, args=(current_time_datetime, ) )
|
||||
p3.daemon = True
|
||||
p3.start()
|
||||
p1.join()
|
||||
p3.terminate()
|
||||
p1.terminate()
|
||||
|
||||
|
||||
def update_crontab(pCurrent_Time):
|
||||
""" Updating crontab lists every hour
|
||||
:type pCurrent_Time: time when starting crontab update
|
||||
:param pCurrent_Time: datetime
|
||||
|
||||
:raises: none
|
||||
|
||||
:rtype: none
|
||||
"""
|
||||
|
||||
# Update user info now
|
||||
|
||||
print('in update_crontab')
|
||||
|
||||
user_ids.clear() # Example for me (Florian Kellermann)
|
||||
user_crontab.clear()
|
||||
user_ids.append(1770205310)
|
||||
user_crontab.append("0 8 * * *")
|
||||
|
||||
while True:
|
||||
time_difference = datetime.datetime.now() - pCurrent_Time
|
||||
if float(str(time_difference).split(':')[0]) >=1:
|
||||
update_crontab(datetime.datetime.now())
|
||||
|
||||
|
||||
def update_based_on_crontab(pCurrent_Time):
|
||||
current_time_ctime = time.ctime()
|
||||
for i in range(len(user_crontab)):
|
||||
print('tbd')
|
||||
|
||||
|
||||
time.sleep(60)
|
||||
|
||||
|
||||
|
||||
def send_to_user(pText, pUser_id = 1770205310):
|
||||
|
Loading…
Reference in New Issue
Block a user