Commit Graph

86 Commits

Author SHA1 Message Date
de477210b1 Add on_connect callback and joined_channels property
* on_connect is called on all plugins on the first message received from
  the IRC server
* joined_channels property gets all of the channels that this bot has
  currently joined in IRC

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 16:31:01 -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
44f0f8a79f Add data/markov/ dir to .gitignore
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-27 19:16:44 -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
a30588111b Minor config example change
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-26 19:50:44 -07:00
63a39c3515 Add enabled documentation to config.toml
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-26 19:48:50 -07:00
585f9e5952 Add "enabled" config option
If a plugin has enabled = false, it will not load.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-26 19:47:30 -07:00
f0cfe53c8e Add on_load for plugins
This asynchronous function is called on all plugins right before the IRC
connection is made.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-26 19:06:48 -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
03f2957c8f Add markov_import script
Used to import markov chains to the given channel. No help available.
Use at your own risk.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-24 20:32:37 -07:00
1bcfae171a Add .pkl files to .gitignore
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-24 20:31:59 -07:00
9d8ff8e61d Remove bot import from __init__.py
Don't remember when this was added. We don't want it.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-24 20:31:23 -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
82e50f86d6 Add graceful exits
This sets up a set of ropes and pulleys that signal the `Bot.keepalive`
function to clean things up after a quit signal has been sent. This
allows plugins to define an `on_unload` function to save any important
datas on intentional exit.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-24 19:16:15 -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
9d144924e9 Add channels to server config
This wasn't being loaded before, now it is.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 20:55:45 -07:00
3893b37401 Add async-timeout to dependencies
For some reason, async-timeout needs to be specifically marked as >=4
when using the aiohttp package.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 20:54:54 -07:00
2504dfeee6 Fix gitignore
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 20:54:41 -07:00
87ea9e358f Remove pycache that accidentally got added
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 20:52:33 -07:00
78a4c5558d Update README and add aiohttp dependency
aiohttp has a weird issue when installing with pipenv. A workaround is
added in the README.md to at least cover that case when it comes time to
deploy on a real server.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:38:21 -07:00
240e4e5f29 Update Pipfile to only install toml when we're below Python 3.11
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:15:50 -07:00
580cf52cad Add .vscode directory
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:04:03 -07:00
163160b660 Remove import from fortune plugin
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:03:34 -07:00
b083a8ad8f Add README
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:02:53 -07:00
de1101ddfb Add config example and data/fortunes.txt
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:02:25 -07:00
cf770af2ff Add log messages for join, part, and kick
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-23 19:00:38 -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