Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #171 from GrafeasGroup/fix/no-author-messages
Browse files Browse the repository at this point in the history
Gracefully degrade if mods message us
  • Loading branch information
itsthejoker committed Nov 12, 2019
2 parents f4a8210 + 64d6ca1 commit f998bc2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [UNRELEASED]

- Replaces `setup.py` with Poetry tooling for development and packaging ease
- Fixes no-author condition if the mods message the bot

## [3.11.2] - 2019-09-14

Expand Down
29 changes: 19 additions & 10 deletions tor/core/user_interaction.py
Expand Up @@ -342,16 +342,25 @@ def process_message(message: RedditMessage, cfg):
dm_body = i18n['responses']['direct_message']['dm_body']

author = message.author
username = author.name
username = author.name if author else None

author.message(dm_subject, dm_body)

send_to_modchat(
f'DM from <{reddit_url.format("/u/" + username)}|u/{username}> -- '
f'*{message.subject}*:\n{message.body}', cfg
)

logging.info(
f'Received DM from {username}. \n Subject: '
f'{message.subject}\n\nBody: {message.body} '
)
if username:
send_to_modchat(
f'DM from <{reddit_url.format("/u/" + username)}|u/{username}> -- '
f'*{message.subject}*:\n{message.body}', cfg
)
logging.info(
f'Received DM from {username}. \n Subject: '
f'{message.subject}\n\nBody: {message.body} '
)
else:
send_to_modchat(
f'DM with no author -- '
f'*{message.subject}*:\n{message.body}', cfg
)
logging.info(
f'Received DM with no author. \n Subject: '
f'{message.subject}\n\nBody: {message.body} '
)

0 comments on commit f998bc2

Please sign in to comment.