Last active
July 11, 2018 09:40
-
-
Save jattoabdul/657a107663d1c747cb2a6e208b19552f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def notify_channel(self): | |
print('Worker is running..., waiting till 8:00') | |
while True: | |
curent_time = datetime.now() | |
current_hour = curent_time.hour | |
current_minute = curent_time.minute | |
if current_hour - 8 > 0: | |
sleep_time = 24 - current_hour + 8 - (current_minute / 60) | |
elif current_hour - 8 < 0: | |
sleep_time = 8 - current_hour - (current_minute / 60) | |
elif current_hour == 8: | |
if current_minute == 0: | |
sleep_time = 0 | |
else: | |
sleep_time = 24 - current_hour + 8 - (current_minute / 60) | |
for index, row in enumerate(self.sheet): | |
check_date = datetime.strptime(self._num_suffix(row['Next Check-In']), '%d %B %Y').date() | |
todays_date = datetime.now().date() | |
send_notif_date = check_date - todays_date | |
if send_notif_date.days == 0: | |
text_detail = ( | |
'*Task #{} for {}:* \n\n' | |
'*Hey {},* Today is the check-in day for your writeup titled\n' | |
'`{}`.\n\n' | |
'Whats the status of the article?\n' | |
'PS: Please reply to this thread, the managers will review and reply you ASAP').format( | |
str(index + 1), row['Next Check-In'], row['Name'], | |
row['Most Recent Learning Experience you\'d like to write about']) | |
self.slackhelper.post_message_to_channel(text_detail) | |
print('message sent or no tasks for today-waiting till 8:00a.m next day') | |
time.sleep(sleep_time * 3600) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment