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 show_tasks(self, date=None): | |
if date in ['today', 'tomorrow', 'yesterday']: | |
day_date_param = self.__convert_to_date(date) | |
task_cells = list(filter(lambda x: datetime.strptime(self.__num_suffix(x['Next Check-In']), '%d %B %Y').date() == day_date_param, self.sheet)) | |
if task_cells: | |
self.__perform_send_action(task_cells) | |
else: | |
return {'text': 'No task assigned to be checked in {}, try another date'.format(date)} | |
else: | |
date_param = date.replace('-', ' ') |
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 __perform_send_action(self, task_cells): | |
recipient = self.user_info['user']['id'] | |
for index, row in enumerate(task_cells): | |
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'], |
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
from flask_api import FlaskAPI | |
from config.env import app_env | |
from app.utils.slackhelper import SlackHelper | |
from flask import request, jsonify | |
from app.actions import Actions | |
from re import match | |
allowed_commands = [ | |
'show-task' |
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...') | |
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) |
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) |
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
from app.actions import Actions | |
from app.utils.slackhelper import SlackHelper | |
# Main function | |
def main(): | |
slackhelper = SlackHelper() | |
actions = Actions(slackhelper) | |
actions.notify_channel() |
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
from flask_api import FlaskAPI | |
from config.env import app_env | |
from app.utils.slackhelper import SlackHelper | |
# from flask import request, jsonify | |
# from re import match | |
# from app.actions import Actions | |
def create_app(config_name): | |
app = FlaskAPI(__name__, instance_relative_config=False) |
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
from config import get_env | |
from app import create_app | |
app = create_app(get_env('APP_ENV')) | |
if __name__ == '__main__': | |
app.run() |
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
from slackclient import SlackClient | |
from config import get_env | |
class SlackHelper: | |
def __init__(self): | |
self.slack_token = get_env('SLACK_TOKEN') | |
self.slack_client = SlackClient(self.slack_token) | |
self.slack_channel = get_env('SLACK_CHANNEL') |
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
import gspread | |
from os import path | |
from config import get_env | |
from oauth2client.service_account import ServiceAccountCredentials | |
class GappsHelper: | |
def __init__(self): | |
# setup for google sheet - Google Drive API Instance |