Skip to content

Commit

Permalink
Bug/ adjustment message in chat and slack integration (#67)
Browse files Browse the repository at this point in the history
* adjustment in the message sent by the bot

* adjustment in the message sent by the bot

* adjust the message position

* Update slack.py
  • Loading branch information
andersonj-cit authored Feb 25, 2022
1 parent 9ab62a6 commit 47b6531
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def send_messages_to_chat(projects_by_owner):
logger.info('Chat integration is not active.')
return

today_weekday=dt.today().strftime('%A')
initial_message = f'Happy {today_weekday}!'
send_message(initial_message)

for owner in projects_by_owner.keys():
user_to_mention = USERS_MAP.get(owner, owner)
message = "Hey *@{}*, I've noticed you are one of the owners of the following projects:\n\n".format(user_to_mention)
Expand Down Expand Up @@ -68,7 +72,8 @@ def send_messages_to_chat(projects_by_owner):
if send_message_to_this_owner:
send_message(message)

today_weekday=dt.today().strftime('%A')
final_of_execution_message = f'Happy {today_weekday}!!! \nZombie Projects Watcher ran successfully \
and found {number_of_notified_projects} projects with costs higher than the defined notification threshold of ${COST_MIN_TO_NOTIFY}.'
final_of_execution_message = f'\nToday I found *{number_of_notified_projects} projects* with costs higher \
than the defined notification threshold of ${COST_MIN_TO_NOTIFY}.\
\n\n_Note: Only projects whose owner is a real user (and not a Service Account) were considered._'

send_message(final_of_execution_message)
11 changes: 8 additions & 3 deletions slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def send_messages_to_slack(projects_by_owner):
logger.info('Slack integration is not active.')
return

today_weekday=dt.today().strftime('%A')
initial_message = f'Happy {today_weekday}!'
prepare_message(TEAM_CHANNEL, initial_message)

for owner in projects_by_owner.keys():
slack_user = USERS_MAP.get(owner, owner)
message = "Hey @{}, I've noticed you are one of the owners of the following projects:\n".format(slack_user)
Expand All @@ -70,9 +74,10 @@ def send_messages_to_slack(projects_by_owner):
if send_message_to_this_owner:
prepare_message(slack_user, message)

today_weekday=dt.today().strftime('%A')
final_of_execution_message = f'Happy {today_weekday}!!! \nZombie Projects Watcher ran successfully \
and found {number_of_notified_projects} projects with costs higher than the defined notification threshold ${COST_MIN_TO_NOTIFY}.'
final_of_execution_message = '\nToday I found *{number_of_notified_projects} projects* with costs higher \
than the defined notification threshold ${COST_MIN_TO_NOTIFY}.\
\n\n_Note: Only projects whose owner is a real user (and not a Service Account) were considered._'

prepare_message(TEAM_CHANNEL, final_of_execution_message)

def _send_message(channel, message):
Expand Down

0 comments on commit 47b6531

Please sign in to comment.