Added the script
This commit is contained in:
commit
11f0cdac4b
|
@ -0,0 +1,44 @@
|
|||
from flask import Flask, request
|
||||
import requests as r
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/", methods=["GET", "POST"])
|
||||
def main():
|
||||
data = request.json
|
||||
event = request.headers['X-Gitea-Event']
|
||||
msg = None
|
||||
|
||||
if event == "push":
|
||||
url_user = f"[url=https://gitea.planet-casio.com/{data['pusher']['username']}]{data['pusher']['username']}[/url]"
|
||||
url_commits = f"[url={data['compare_url']}]{len(data['commits'])} commit(s)[/url]"
|
||||
url_repository = f"[url={data['repository']['html_url']}]{data['repository']['name']}[/url]"
|
||||
msg = f"{url_user} a poussé {url_commits} dans {url_repository}"
|
||||
|
||||
if event == "issues":
|
||||
url_user = f"[url=https://gitea.planet-casio.com/{data['sender']['username']}]{data['sender']['username']}[/url]"
|
||||
url_issue = f"[url={data['issue']['html_url']}]{data['issue']['title']}[/url]"
|
||||
url_repository = f"[url={data['repository']['html_url']}]{data['repository']['name']}[/url]"
|
||||
|
||||
if data['action'] == "closed":
|
||||
msg = f"{url_user} a fermé le ticket {url_issue} dans {url_repository}"
|
||||
elif data['action'] == "created":
|
||||
msg = f"{url_user} a créé un ticket {url_issue} dans {url_repository}"
|
||||
else:
|
||||
msg = f"{url_user} a <{data['action']}> le ticket {url_issue} dans {url_repository}"
|
||||
|
||||
if event == "issue_comment":
|
||||
url_user = f"[url=https://gitea.planet-casio.com/{data['sender']['username']}]{data['sender']['username']}[/url]"
|
||||
url_issue = f"[url={data['issue']['html_url']}]{data['issue']['title']}[/url]"
|
||||
url_repository = f"[url={data['repository']['html_url']}]{data['repository']['name']}[/url]"
|
||||
|
||||
if data['action'] == "created":
|
||||
msg = f"{url_user} a répondu au ticket {url_issue} dans {url_repository}"
|
||||
|
||||
if msg:
|
||||
msg = f"[gray][i]{msg}[/i][/gray]"
|
||||
r.post("https://www.planet-casio.com/Fr/shoutbox/api/post",
|
||||
data={"message": msg, "channel": "dev"},
|
||||
cookies={"planete_casio_session":"SomeSessionCookieFromGlados"})
|
||||
|
||||
return "OK"
|
Loading…
Reference in New Issue