Skip to content

Commit

Permalink
Add fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
moan0s committed Dec 14, 2022
1 parent 0852881 commit 71d27f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion alertbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from aiohttp.web import Request, Response, json_response
import json
import datetime
from mautrix.errors.request import MForbidden

helpstring = f"""# Alertbot
Expand Down Expand Up @@ -186,7 +187,11 @@ async def send_alert(self, req, room):
@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()
Expand Down
2 changes: 1 addition & 1 deletion maubot.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 71d27f5

Please sign in to comment.