|
@@ -61,24 +61,33 @@ def services():
|
|
|
def execute():
|
|
|
json = request.get_json()
|
|
|
msg = RollbotMessage.from_groupme(json)
|
|
|
- if msg.group_id in BOTS_LOOKUP:
|
|
|
- bot_id = BOTS_LOOKUP[msg.group_id]
|
|
|
- if msg.is_command:
|
|
|
- response = rollbot.run_command(msg)
|
|
|
- if response.respond:
|
|
|
- app.logger.info(f"Responding to message {message.message_id}")
|
|
|
- if response.is_success:
|
|
|
- if response.txt is not None:
|
|
|
- post_message(response.txt, bot_id=bot_id)
|
|
|
- if response.img is not None:
|
|
|
- post_message(response.img, bot_id=bot_id)
|
|
|
- else:
|
|
|
- post_message(response.failure_msg, bot_id=bot_id)
|
|
|
- else:
|
|
|
- app.logger.info(f"Skipping response to message {message.message_id}")
|
|
|
- else:
|
|
|
+
|
|
|
+ if not msg.is_command:
|
|
|
+ app.logger.debug("Received non-command message")
|
|
|
+ return "", 204
|
|
|
+
|
|
|
+ if msg.group_id not in BOTS_LOOKUP:
|
|
|
app.logger.warn(f"Received message from unknown group ID {msg.group_id}")
|
|
|
- return "200 OK"
|
|
|
+ return "Invalid group ID", 403
|
|
|
+
|
|
|
+ response = rollbot.run_command(msg)
|
|
|
+
|
|
|
+ if not response.respond:
|
|
|
+ app.logger.info(f"Skipping response to message {message.message_id}")
|
|
|
+ return "", 204
|
|
|
+
|
|
|
+ app.logger.info(f"Responding to message {message.message_id}")
|
|
|
+
|
|
|
+ bot_id = BOTS_LOOKUP[msg.group_id]
|
|
|
+ if response.is_success:
|
|
|
+ if response.txt is not None:
|
|
|
+ post_message(response.txt, bot_id=bot_id)
|
|
|
+ if response.img is not None:
|
|
|
+ post_message(response.img, bot_id=bot_id)
|
|
|
+ else:
|
|
|
+ post_message(response.failure_msg, bot_id=bot_id)
|
|
|
+
|
|
|
+ return "OK", 200
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|