import time
from datetime import date, timedelta
+from json import loads
+from requests import post
+
db.init_db()
app = Flask(__name__)
CORS(app, supports_credentials=True)
print("Log:", data)
return data
return "nope"
+
+@app.route("/tellCoffeebot", methods=["POST"])
+def tell_coffeebot():
+ err = "Don't worry now! There is a NEW HOPE Tonda is buying NEW PACK!"
+ if request.method == "POST":
+ what = loads(request.data.decode("utf-8"))
+ try:
+ with open(".config", "r") as f:
+ conf = loads(f.read())
+ except:
+ return "Config needed! Please find in git history how it should look."
+ try:
+ res = post(conf["coffeebot"]["url"], json=what)
+ print("res is {}".format(res))
+ except:
+ err = "No connection! No covfefe! We all die here!"
+ if not res.ok:
+ err = "Slack don't like the request! It's discrimination!"
+ return err
<center>
<div id="user"></div>
+<p id="pLastCovfefe"><input type="button" value="The last coffee pack opened!" onclick="tellCoffeebot('Yay, <@U539N17JL|Tonda>, buy me a new covfefe pack! Thanks!')" /></p>
<p>Hack me: <tt>https://rtime.felk.cvut.cz/gitweb/coffee/main.git</tt></p>
<p>Debug: <span id="log"></span></p>
</center>
function sendLog(json) {
ajax("POST", "log", json, "log");
}
+
+function tellCoffeebot(what)
+{
+ ajax("POST", "tellCoffeebot", JSON.stringify({text: what}), "log");
+}