Commit Graph

42 Commits

Author SHA1 Message Date
6b73cccda0 markov: Add !markov help and help_timeout config
* !markov help will display a pretty crude help message. It's funny to
  me, I dunno.
* help_timeout config option limits the number of times that `!markov
  help` is allowed to run. This is because the help message is a lot of
  lines, and it could cause problems if `!markov help` is spammed or
  abused. It can be set to 0 or less to disable.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-11-30 23:18:35 -08:00
5aa282143e wordbot: Fix latest wordbot patch (whoopsie)
Last patch was creating a set of the list of all matches, instead of a
set of all matches. This fixes that, and also makes the regex a raw
string.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-03-30 20:13:50 -07:00
Max Marrone
232527cd3a wordbot: Recognize words adjacent to punctuation.
If there was an unmatched word 'foo', and someone wrote 'foo. bar.', wordbot would not recognize the match because it was only splitting the string on spaces, not punctuation.

This treats as a word any contiguous sequence of letters, numbers (just in case) and hyphens (just in case).

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-03-30 20:04:07 -07:00
8e639d50fa markov: Remove allchain
The allchain has been a source of headaches because it takes up a lot of
memory and slows everything down. However, with the new database
model, we can generate markov sentences using all of the rows since they
are a flat collection. This helps reduce disk space and increases the
import speed significantly.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-23 14:29:02 -07:00
8c4bb5ac60 markov: Finish up chain database implementation
Markov now uses a sqlite3 database instead of flat JSON files. This
should significantly speed up saving time, plus reduce the amount of RAM
that it uses. Saving and loading large JSON files was very slow and
caused issues with other plugins, especially when messages were
received. Additionally, in order to save RAM, a cache was used and
periodically flushed when not used, adding some complications to the
implementation. This has all been removed since things get committed on
the fly with the database implementation. The main trade-off we have to
make is the disk space used by the database. This is OK though, because
disk space is cheap while RAM is not.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-23 12:29:19 -07:00
086ba7706e markov: Trying out a sqlite3-based model
This is a lot simpler from a concurrency perspective. Training values
can get committed to the database immediately, rather than in
long-running flat file batches.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-23 12:00:33 -07:00
737e032783 linkbot: Minor fix with log message
Returned value could be None, so this accounts for that

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-23 10:16:46 -07:00
cac2cc20fb Fix linkbot title bug
If an HTML title was parsed with whitespace, it would not strip that
surrounding whitespace. This fixes that.

Also, there are some new debug log messages in linkbot. Hooray!

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-23 09:58:12 -07:00
ed9c3ddaa2 markov: Reply chance is loaded lazily
Just like the actual chain data structure, this value is now loaded
lazily, since it's stored in the filesystem.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-04 16:16:52 -07:00
171b4bea81 markov: Add random replies
Forgot to implement this, oops

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-04 15:55:48 -07:00
2e7825510e markov: Add some more log messages
Nothing major, just more log messages.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 19:07:09 -07:00
1d016c5164 markov: Add up process-scheduled saving
This allows markov to save (hopefully) in parallel using a
ProcessPoolExecutor. Since objects are sent over-the-wire and copied,
pruning in parallel is not an issue.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 18:24:25 -07:00
04c0d05208 markov: More refined usage of Chain.__touch()
This moves the self.__touch() call around in markov's Chain class such
that it will only access truly available data.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 18:21:34 -07:00
da7d1501e2 markov: Add utility method for last access time update
* Chain.__touch() is a new function that updates the last time a markov
  chain was accessed
* Fix a bug that would not reliably update the last access time of the
  chain during Chain.add()

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 18:18:18 -07:00
b684e07dfc markov: Move prune behavior to Bot, from Chain
Markov chains used to prune the chains themselves from memory, but now
that behavior is specifically delegated up the chain to the Bot
structure instead.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-01 23:05:06 -07:00
baa2d285ee Set default save_every on markov to 1800 seconds, or 30 minutes
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-01 23:03:41 -07:00
10ffeaf63a Minor fixups in linkbot on the most recent changes for HTML decoding
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-01 21:50:22 -07:00
57e1d211a3 Update linkbot to use a fancier parser, and add HTML decoding
* Linkbot parser also looks for <meta> tags and uses an actual HTML
  parser.
* Inner title HTML is decoded before being displayed.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-01 21:43:45 -07:00
741bd85ff7 Add nick to wordbot score message
Whoever scored a point gets a notification for such.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 20:43:48 -07:00
56e99c237b Add nickserv plugin
This allows the bot to register itself and login.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 19:45:49 -07:00
94c4ef47ed Add nickname to fortune plugin response
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 18:21:12 -07:00
0bb17050ec Add a couple of debug log messages to wordbot when a new round is started/finished
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:42:18 -07:00
5cf12406f7 Remove user ping from wordbot leaderboard
When a user's name is used in the !wordbot leaderboard command, we make
every effort to not ping them by interleaving zero-width space
characters in the nickname.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:38:32 -07:00
de2b1c1761 Add !wordbot leaderboard command
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:33:37 -07:00
dd4b7f2223 Add initial wordbot implementation
This matches the old database format that was written a while back.
There's an "end_now" command that's been left in there for debugging
purposes, that'll be gone soon enough.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:05:02 -07:00
9bed657f5f Fix a couple small bugs in markov bot
* .items() call required when loading a markov chain into memory
* `who.nick` instead of `who~ for get_chain call

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:02:09 -07:00
c27ea72c85 Add feedback for markov bot reply chance
This will just send a message to the user who just updated their markov
reply chance with the final value it was set to, so there are no
surprises.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 14:36:28 -07:00
6a1ed5c372 Add random reply chance to markov bot
Whenever someone says something, there's a chance that markov will
interject his opinion. Users can also set the chance between 0.0 and the
default value (in the config) if they want to see markov replies less
often.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 14:29:37 -07:00
57dd547233 Convert values passed in config in markov bot
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-29 21:37:34 -07:00
887c8dc278 Add dirty flag to markov chains
If something is changed in a markov chain it gets flagged as dirty,
which is used to determine whether the chain should be saved.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-27 18:58:06 -07:00
cc30df8706 Move markov nodes to be single strings
Separating strings by spaces is more memory-friendly than using tuples.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-27 18:41:17 -07:00
b4857e3b4a Add naiive markov all and allchain
Markov all grows fast and 5 years of data uses about 2gb in memory. We
can do better.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-27 17:56:52 -07:00
a4958d371e Finally settle on a good model for markov
If you don't use/access your chain every N seconds (300 by default), it
will unload your chain from memory and save it to disk.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-26 20:59:06 -07:00
85d48d368c Add Markov.add function
This is basically just a shorthand, but also abstracts away adding a
line to a markov chain

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-25 19:18:37 -07:00
5c594fc03e Add PLUGIN_TYPE to markov.py
Forgot to add this, whoopsie

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-24 20:40:53 -07:00
116baccc2a Remove unused MutableMapping import from markov.py
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-24 20:17:46 -07:00
9c188e30b1 Add initial markov bot plugin
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-24 19:30:42 -07:00
ffb2d4204e Move message size limit logic to base plugin
This is beneficial for all plugins so the bot doesn't accidentally
spam things because the plugin writer didn't check their inputs

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 21:11:04 -07:00
3476c06e16 Add message length limit to linkbot plugin
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 21:06:53 -07:00
48f182e41a Add linkbot and config example for linkbot
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 21:02:51 -07:00
163160b660 Remove import from fortune plugin
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:03:34 -07:00
a901c2351a Initial commit with functional framework(!) and example plugin
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 18:47:28 -07:00