Commit Graph

70 Commits

Author SHA1 Message Date
997033a4e2 Add OMNIBOT_CONFIG environment variable config
If you want to supply an OMNIBOT_CONFIG environment variable value, it's
available.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-04 20:09:31 -07:00
316b91a9fd Remove a couple of old comments
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-04 18:00:00 -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
6a18a2161c Move another module to the top of the example config because it has full explanations of everything going on
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 20:45:52 -07:00
6707b59a73 Move nickserv config documentation up in the file, since it's pretty important
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 20:40:27 -07:00
2df0e62166 Add nickserv config documentation
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 20:38:36 -07:00
74c98696e4 Add config example for markov bot
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 19:55:26 -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
a823871039 Add log level config option
* Log levels can now be set via the command line and the configuration
  file.
* ServerConfig.load() function takes a file-like object now, rather than
  a string

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-03 17:21:20 -07:00
418a69c263 Remove unused server.py file
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-01 23:47:44 -07:00
8e60196588 Remove a couple of unused imports from __main__.py
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-01 23:29:54 -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
98f8dc12bd Set log level to INFO by default
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 20:25:09 -07:00
0d60f6434a Add docker-compose and Dockerfile
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 20:17:21 -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
a0070fca38 Small fix for plugins that accept non-channel messages
There's a long explanation in the code of this commit that says this:

> TL;DR OF THE BELOW: if the first parameter looks like a channel in
> addition to message type, then filter by channel. Otherwise, don't
> filter by channel.
>
> Here's the issue: plugins are *usually* multiplexed by channel. But
> that's only for messages that target channels, such as PRIVMSG and JOIN.
> For non-channel messages, such as server status messages (such as 001 on
> connect, or 372 for MOTD, etc) we want to ignore the channel aspect of
> plugin multiplexing. In order to accomplish this, we just check if the
> first parameter looks like a channel - i.e., starts with an octothorpe #.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 19:43:39 -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
061cf9ee7b Add get_message_types() to plugin API
This allows plugins to specify the types of messages they handle. This
will be used specifically for the nickserv plugin, but could be useful
for other things too.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 18:14:48 -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
f105ba4eef Add words.txt for wordbot
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:40:17 -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
1b4084322b Fix markov import tool to use the new plugin API
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:16:22 -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
7b88d861fe Update Plugins to keep a reference to the Bot object instead of server_config
Plugins now use Bots instead of server_configs, this is useful for
checking the currently joined channels and perhaps using the connection
when there isn't one available in the current method.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-05-30 17:03:28 -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
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