Skip to content
Snippets Groups Projects
Verified Commit 146174dc authored by Timuçin Boldt's avatar Timuçin Boldt :bike:
Browse files

continue broadcasting after forbidden send request

parent a8e714cc
Branches
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ import feedparser ...@@ -26,6 +26,7 @@ import feedparser
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
from mautrix.types import (StateEvent, EventType, MessageType, RoomID, EventID, from mautrix.types import (StateEvent, EventType, MessageType, RoomID, EventID,
PowerLevelStateEventContent) PowerLevelStateEventContent)
from mautrix.errors.request import MForbidden
from maubot import Plugin, MessageEvent from maubot import Plugin, MessageEvent
from maubot.handlers import command, event from maubot.handlers import command, event
...@@ -118,12 +119,14 @@ class RSSBot(Plugin): ...@@ -118,12 +119,14 @@ class RSSBot(Plugin):
async def _broadcast(self, feed: Feed, entry: Entry, subscriptions: List[Subscription]) -> None: async def _broadcast(self, feed: Feed, entry: Entry, subscriptions: List[Subscription]) -> None:
spam_sleep = self.config["spam_sleep"] spam_sleep = self.config["spam_sleep"]
tasks = [self._send(feed, entry, sub) for sub in subscriptions] tasks = [self._send(feed, entry, sub) for sub in subscriptions]
if spam_sleep >= 0:
for task in tasks: for task in tasks:
try:
await task await task
if spam_sleep >= 0:
await asyncio.sleep(spam_sleep, loop=self.loop) await asyncio.sleep(spam_sleep, loop=self.loop)
else: except MForbidden as e:
await asyncio.gather(*tasks) self.log.warning(f"Failed to broadcast: {e}")
continue
async def _poll_once(self) -> None: async def _poll_once(self) -> None:
subs = self.db.get_feeds() subs = self.db.get_feeds()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment