This commit is contained in:
Julian-Samuel Gebühr 2022-12-14 17:56:26 +01:00
parent 0852881a79
commit 71d27f5176
3 changed files with 12 additions and 2 deletions

View File

@ -1,3 +1,8 @@
# December 2022
* Handle sending an alert to a room where the bot is not allowed to send messages [#2](https://github.com/moan0s/alertbot/issues/2)
* Add [uptime-kuma](https://github.com/louislam/uptime-kuma) resolved message with proper formatting
# September 2022
* Add [uptime-kuma](https://github.com/louislam/uptime-kuma) example

View File

@ -3,6 +3,7 @@ from maubot.handlers import web, command
from aiohttp.web import Request, Response, json_response
import json
import datetime
from mautrix.errors.request import MForbidden
helpstring = f"""# Alertbot
@ -186,7 +187,11 @@ class AlertBot(Plugin):
@web.post("/webhook/{room_id}")
async def webhook_room(self, req: Request) -> Response:
room_id = req.match_info["room_id"].strip()
await self.send_alert(req, room=room_id)
try:
await self.send_alert(req, room=room_id)
except MForbidden:
self.log.error(f"Could not send to {room_id}: Forbidden. Most likely the bot is not invited in the room.")
return json_response('{"status": "forbidden", "error": "forbidden"}', status=403)
return json_response({"status": "ok"})
@command.new()

View File

@ -1,6 +1,6 @@
maubot: 0.1.0
id: de.hyteck.alertbot
version: 1.1.0
version: 1.1.1
license: AGPL-3.0-or-later
modules:
- alertbot