Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSS feeds which exceed IRC maximum message length are cut off #1533

Open
TehPeGaSuS opened this issue Apr 30, 2023 · 5 comments
Open

RSS feeds which exceed IRC maximum message length are cut off #1533

TehPeGaSuS opened this issue Apr 30, 2023 · 5 comments

Comments

@TehPeGaSuS
Copy link
Contributor

So, I've set my bot to spit RSS feeds in the format [Feed Name] $title :: $link :: $description. what happens is that sometimes descriptions are big and are cut off. it'd be nice if we could figure out when the message is exceeding the maximum length, cut it before the last word and add something like ... to the end instead.

Example: [Ubuntu Security Notices] USN-6049-1: Netty vulnerabilities :: https://ubuntu.com/security/notices/USN-6049-1 :: It was discovered that Netty's Zlib decoders did not limit memory allocations. A remote attacker ...

@TehPeGaSuS
Copy link
Contributor Author

Here's an example that I took from Bitbot, that kinda shows what I mean:

(bitbot) [issue] progval commented on #369 ([Important] Bot crashes when parsing the URL of certain RSS feeds): That's because `{}` in the entry is inserted by `.replace("$longtitle", feed_title_str)`, and[...] - https://github.com/bitbot-irc/bitbot/issues/369#issuecomment-1589764538

@progval
Copy link
Owner

progval commented Jun 13, 2023

Here is how I'd fix it: in format_entry, we could compute total message size (len(str(ircmsgs.privmsg(channel, normalized_entry))) and if it's over 512, then subtract 512 to the message size and truncate this many bytes (not characters! sigh) from entry["description"], then format and normalize again.

@TehPeGaSuS
Copy link
Contributor Author

We just need to be careful so we don't remove anything from the URL (GitHub URLs tend to be quite big), otherwise we'll end up with a broken link.

@TehPeGaSuS
Copy link
Contributor Author

TehPeGaSuS commented Sep 20, 2023

Small addendum: it would be nice to decide also what to do if the message would exceed the 512 bytes limit, like spit out the whole message (that could be 2+ lines), etc.

A bit like the supybot.reply.mores.instant option but automatically.

@ThatLurker
Copy link

ThatLurker commented Oct 25, 2024

The safest way to do this would be to do a cut at the last space. This in most cases prevents breaking stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@progval @ThatLurker @TehPeGaSuS and others