amauragis / bofhwits

BOFHWits: A Bad Bot
MIT License
0 stars 0 forks source link

Support fuzzy history searching to attempt to recognize quoted text #16

Open amauragis opened 8 years ago

amauragis commented 8 years ago

Here's the thing.

Everybody's IRC client is horrible and there isn't a consistent format for how it's displayed on screen. Because I made a Bad Decision, I chose to attempt to parse quotee from the string that is passed to !bofh. The obvious formats of

username> butts are funny
<username2> I think so too but I'm not smart
username3: haha you said butt

basically work, but if the string they are quoting has <>s or other crap who knows what will happen (it will break).

SO! Instead of trying to parse text because I hate parsing text and it's literally the worst thing in the world, I'm going to attempt to do a fuzzy pattern match and keep a circular buffer of recent history. If we store the last say, 100 lines of chat in a ring buffer, we can attempt to fuzzy-match the quoted text against the buffer. If we find a successful match, we can use the meta-information stored in the ring buffer (timestamp, person who we're quoting, etc) to not have to parse usernames!.

This also opens up the opportunity to handle multiline strings or conversations to quote as well, but that's probably harder, so I'll make that it's own thing.