mirror of
https://github.com/moan0s/alertbot.git
synced 2024-06-26 03:32:09 +00:00
Add fix #2
This commit is contained in:
parent
0852881a79
commit
71d27f5176
|
@ -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
|
# September 2022
|
||||||
|
|
||||||
* Add [uptime-kuma](https://github.com/louislam/uptime-kuma) example
|
* Add [uptime-kuma](https://github.com/louislam/uptime-kuma) example
|
|
@ -3,6 +3,7 @@ from maubot.handlers import web, command
|
||||||
from aiohttp.web import Request, Response, json_response
|
from aiohttp.web import Request, Response, json_response
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
|
from mautrix.errors.request import MForbidden
|
||||||
|
|
||||||
helpstring = f"""# Alertbot
|
helpstring = f"""# Alertbot
|
||||||
|
|
||||||
|
@ -186,7 +187,11 @@ class AlertBot(Plugin):
|
||||||
@web.post("/webhook/{room_id}")
|
@web.post("/webhook/{room_id}")
|
||||||
async def webhook_room(self, req: Request) -> Response:
|
async def webhook_room(self, req: Request) -> Response:
|
||||||
room_id = req.match_info["room_id"].strip()
|
room_id = req.match_info["room_id"].strip()
|
||||||
|
try:
|
||||||
await self.send_alert(req, room=room_id)
|
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"})
|
return json_response({"status": "ok"})
|
||||||
|
|
||||||
@command.new()
|
@command.new()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: de.hyteck.alertbot
|
id: de.hyteck.alertbot
|
||||||
version: 1.1.0
|
version: 1.1.1
|
||||||
license: AGPL-3.0-or-later
|
license: AGPL-3.0-or-later
|
||||||
modules:
|
modules:
|
||||||
- alertbot
|
- alertbot
|
||||||
|
|
Loading…
Reference in New Issue
Block a user