|
@@ -24,7 +24,6 @@ dictConfig({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
rollbot = Rollbot(app.logger)
|
|
@@ -32,6 +31,30 @@ rollbot.start_plugins()
|
|
|
atexit.register(rollbot.shutdown_plugins)
|
|
|
|
|
|
|
|
|
+@app.route("/teamspeak", methods=["GET"])
|
|
|
+def teamspeak():
|
|
|
+ response = rollbot.run_command(RollbotMessage.from_web("!teamspeak"))
|
|
|
+ if response.is_success:
|
|
|
+ response = response.txt
|
|
|
+ else:
|
|
|
+ response = response.failure_msg
|
|
|
+ return render_template("teamspeak.html", r=response)
|
|
|
+
|
|
|
+
|
|
|
+@app.route("/services", methods=["GET", "POST"])
|
|
|
+def services():
|
|
|
+ if request.method == "POST":
|
|
|
+ msg = RollbotMessage.from_web(request.form["cmd"])
|
|
|
+ if msg.is_command:
|
|
|
+ response = rollbot.run_command(msg)
|
|
|
+ if response.is_success:
|
|
|
+ txt = response.txt
|
|
|
+ img = response.img
|
|
|
+ else:
|
|
|
+ txt = response.failure_msg
|
|
|
+ img = None
|
|
|
+ return render_template("services.html", r=response.respond, txt=txt, img=img)
|
|
|
+ return render_template("services.html", r=None)
|
|
|
|
|
|
|
|
|
@app.route("/rollbot", methods=["POST"])
|
|
@@ -42,15 +65,15 @@ def execute():
|
|
|
bot_id = BOTS_LOOKUP[msg.group_id]
|
|
|
if msg.is_command:
|
|
|
response = rollbot.run_command(msg)
|
|
|
- if result.respond:
|
|
|
+ if response.respond:
|
|
|
app.logger.info(f"Responding to message {message.message_id}")
|
|
|
- if result.is_success():
|
|
|
- if result.txt is not None:
|
|
|
- post_message(result.txt, bot_id=bot_id)
|
|
|
- if result.img is not None:
|
|
|
- post_message(result.img, bot_id=bot_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(result.failure_msg, bot_id=bot_id)
|
|
|
+ post_message(response.failure_msg, bot_id=bot_id)
|
|
|
else:
|
|
|
app.logger.info(f"Skipping response to message {message.message_id}")
|
|
|
else:
|
|
@@ -60,4 +83,4 @@ def execute():
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
# default deployment in debug mode
|
|
|
- app.run(host="localhost", port=6071, debug=True)
|
|
|
+ app.run(host="0.0.0.0", port=6071, debug=True)
|