|
@@ -4,6 +4,7 @@ from threading import Thread
|
|
|
|
|
|
from flask import Flask, request
|
|
|
import requests
|
|
|
+import requests.exceptions
|
|
|
|
|
|
from rollbot import Rollbot, RollbotMessage, RollbotPlugin
|
|
|
|
|
@@ -34,15 +35,19 @@ dictConfig({
|
|
|
|
|
|
def post_groupme_message(msg, group_id):
|
|
|
bot_id = BOTS_LOOKUP[group_id]
|
|
|
- requests.post(
|
|
|
- "https://api.groupme.com/v3/bots/post",
|
|
|
- json={
|
|
|
- "bot_id": bot_id,
|
|
|
- "text": msg
|
|
|
- },
|
|
|
- timeout=10
|
|
|
- )
|
|
|
-
|
|
|
+ try:
|
|
|
+ requests.post(
|
|
|
+ "https://api.groupme.com/v3/bots/post",
|
|
|
+ json={
|
|
|
+ "bot_id": bot_id,
|
|
|
+ "text": msg
|
|
|
+ },
|
|
|
+ timeout=10
|
|
|
+ )
|
|
|
+ except requests.exceptions.Timeout as t:
|
|
|
+ app.logger.error(f"GroupMe timed out sending {msg} as {bot_id}", exc_info=t)
|
|
|
+ except requests.exceptions.HTTPError as h:
|
|
|
+ app.log_exception(h)
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
app.config["PROPAGATE_EXCEPTIONS"] = True
|