mirror of
https://github.com/maubot/rss.git
synced 2025-04-19 06:45:47 -04:00
Split long messages to prevent matrix event too large errors
This commit is contained in:
parent
e0a992396e
commit
ed4b34a788
11
rss/bot.py
11
rss/bot.py
@ -117,11 +117,16 @@ class RSSBot(Plugin):
|
||||
**attr.asdict(entry),
|
||||
}
|
||||
)
|
||||
|
||||
msgtype = MessageType.NOTICE if sub.send_notice else MessageType.TEXT
|
||||
msgchunks = [message[i:i + 30000] for i in range(0, len(message), 30000)]
|
||||
self.log.debug(f"Message length: {len(message)} Content length: {len(entry.content)} Chunks: {len(msgchunks)}")
|
||||
try:
|
||||
return await self.client.send_markdown(
|
||||
sub.room_id, message, msgtype=msgtype, allow_html=True
|
||||
)
|
||||
for chunk in msgchunks:
|
||||
returnval = await self.client.send_markdown(
|
||||
sub.room_id, chunk, msgtype=msgtype, allow_html=True
|
||||
)
|
||||
return returnval
|
||||
except Exception as e:
|
||||
self.log.warning(f"Failed to send {entry.id} of {feed.id} to {sub.room_id}: {e}")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user