mirror of
https://github.com/YunoHost/webhooks.git
synced 2024-09-03 19:56:54 +02:00
Switch to matrix for notifications
This commit is contained in:
parent
698f13ef32
commit
3489e10774
1 changed files with 14 additions and 4 deletions
14
server.py
14
server.py
|
@ -37,11 +37,21 @@ async def notify(message, repository="dev"):
|
|||
chan = other_chans.get(repository, "dev")
|
||||
|
||||
print(f"{chan} -> {message}")
|
||||
|
||||
for char in ["'", "`", "!", ";", "$"]:
|
||||
message = message.replace(char, "")
|
||||
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
f"python ./to_room.py '{gitbot_password}' '{message}' '{chan}'"
|
||||
f"/var/www/webhooks/matrix-commander -m '{message}' -c /var/www/webhooks/credentials.json --store /var/www/webhooks/store --room 'yunohost-{chan}'"
|
||||
)
|
||||
try:
|
||||
await proc.communicate()
|
||||
await proc.wait()
|
||||
except Exception as e:
|
||||
if type(e).__name__ == "CancelledError":
|
||||
pass
|
||||
else:
|
||||
raise Exception(f" {type(e).__name__} while trying to notify about commit '{commit_message}' on {repository}/{branch}: {e}")
|
||||
|
||||
|
||||
@app.route("/github", methods=["GET"])
|
||||
|
@ -500,4 +510,4 @@ async def index(request):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run("localhost", port="4567")
|
||||
app.run('127.0.0.1', port="4567")
|
||||
|
|
Loading…
Reference in a new issue