zorael / kameloso

IRC bot with Twitch support
Boost Software License 1.0
9 stars 3 forks source link

Bash plugin rewrite #177

Closed zorael closed 6 months ago

zorael commented 6 months ago

bash.org seems to be permanently dead, but there is apparently a mirror at bashforever.com. The layout is slightly different however and our previous dom parsing doesn't apply, so it's a good opportunity to just rewrite the plugin.

It makes sense to perform the lookups in a separate thread, as it can take up to Timeout.httpGET (10) seconds for a query to fail, during which the bot would stall if it did it in a synchronous fashion. The original approach was to spawn a new thread for each lookup, pass it a copy of the plugin state cast to shared, and then send the resulting output via concurrency messages to the main thread, to be sent to the channel and/or logged to the screen. It has obvious drawbacks and various smells.

The new approach is to spawn a worker thread on end of MOTD, which stays alive until plugin teardown. Queries are sent to it via concurrency messages, and it stores its lookup results in a MutexedAA!(BashLookupResult[string]), much like the Webtitle and Twitch plugins do. This also has drawbacks, but it's not as smelly and seems to work well enough.

The minimum user class required to invoke !bash is now configurable, as it is a DoS vector.