Skip to content

Commit

Permalink
Merge branch 'master' into 40-parsingError
Browse files Browse the repository at this point in the history
  • Loading branch information
mzanella authored Feb 21, 2018
2 parents f7db844 + 6da42e1 commit 9c5719f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions torrearchimedebot/bot/slack_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,19 @@ def __init__(self):
SlackController.starterbot_id = \
SlackController.slack_client.api_call("auth.test")["user_id"]
while True:
command, channel = SlackController.parse_bot_commands(
SlackController.slack_client.rtm_read())
if command:
SlackController.handle_command(command, channel)
t.sleep(SlackController.RTM_READ_DELAY)
try:
command, channel = SlackController.parse_bot_commands(
SlackController.slack_client.rtm_read())
if command:
SlackController.handle_command(command, channel)
t.sleep(SlackController.RTM_READ_DELAY)
except WebSocketConnectionClosedException:
logger.getLogger().error("Lost connection to Slack, reconnecting...")
if not sc.rtm_connect():
logger.getLogger().info("Failed to reconnect to Slack")
time.sleep(SlackController.RTM_READ_DELAY)
else:
logger.getLogger().info("Reconnected to Slack")
else:
logging.getLogger().info("SLACK - Connection failed. Exception " + \
"traceback printed above.")

0 comments on commit 9c5719f

Please sign in to comment.