···2233A very clever kitty
4455-Current features:
66-77-- [Markov chain](https://en.wikipedia.org/wiki/Markov_chain) for a "smart"
88- chatbot
99-1010-## Pre-reqs
1111-1212-- Python 3.12
1313-- UV
1414-1515-## Environment Setup
1616-1717-`uv sync`
1818-1919-### .env
2020-2121-Minimal needed is an env var called `TOKEN` that contains the bot's token.
2222-2323-## Cog Docs
2424-2525-### [Markov](src/bingus/cogs/markov.py)
2626-2727-A markov chain is an incredibly simple model where it decides the next token
2828-based on previous knowledge of what tokens the current token has been proceeded
2929-by.
3030-3131-#### Markov Commands
3232-3333-> **\*** = Requires being bot owner
3434-3535-- `/markov`: Make bingus try and reply to a prompt passed, use this to bypass
3636- the 80% change that bingus usually has to reply
3737-- `/scan_history`*: Scan the history of the current channel and add it to the
3838- chain. Since Bingus only learns from*new\* messages while he's active, you may
3939- need to do this when restarting him. This command can take a while depending
4040- on the number of messages.
4141-- `/dump_chain`\*: Dumps the entire underlying markov chain as a JSON file and
4242- sends it
4343-- `/load_chain`\*: Loads a markov chain JSON (as generated by `/dump_chain`)
4444- additively
4545-- `/weights`: Dump the weights of the specified token to other tokens
4646-4747-#### Markov Config
4848-4949-- `REPLY_CHANNELS`: A _comma-delimited_ list of channel IDs that the bot should
5050- have have a chance to reply to messages in. The bot still learns from all
5151- channels in realtime, but these channels it'll have an 80% of replying to any
5252- message
5353-5454-- `BRAIN_FILE`: Path to file where the chain will be persisted. This file will
5555- automatically be created if it doesn't exist already. The file itself is
5656- msgpack compressed with brotli, so it's recommended to give it a `msgpackz`
5757- extension. By default it will be set to `$PWD/brain.msgpackz`
55+Simple markov chain-based auto replies to user messages.
5865959-## Adding Cogs
77+## Installation
6086161-To start, you can run `poetry run add_cog`.
99+Use the NixOS module in this flake or build/set it up yourself. Just need Rust.
62106363-Follow the steps and you'll get a new cog in `src/bingus/cogs`. Here is where
6464-you can add commands, event listeners, etc.
1111+## Configuration
65126666-See the file generated for some simple examples, review the
6767-[PyCord docs](https://guide.pycord.dev/introduction) for more help and
6868-information.
1313+### `TOKEN_FILE`
69147070-### Utilities
1515+Path to the file containing the bot's token.
71167272-#### Requiring Owner
1717+### `BRAIN_FILE`
73187474-To require the calling user to be a bot owner for slash commands, you can use
7575-[permissions.require_owner](src/bingus/lib/permissions.py). Simply put this as a
7676-decorator **above** the slash command one like so:
1919+Path to the file Bingus will save state in. The file will be created if not present. This will be a brotli-compressed MsgPack file.
77207878-```py
7979-from ..lib.permissions import require_owner
2121+### `REPLY_CHANNELS`
80228181-class MyCog(discord.commands.Cog):
8282- @require_owner
8383- @commands.slash_command()
8484- async def hello_owner(self, ctx: discord.ApplicationContext):
8585- await ctx.respond("Hello Owner!")
8686-```
2323+Comma-delimited list of channel IDs that Bingus should auto reply in.
87248888-This will print an ephemeral error message to all non-owner users and "Hello
8989-Owner!" otherwise.
9090-9191-### Best Practices
9292-9393-Generally you'll want to make all state, config, etc. locallized to your cog
9494-file. That way we can easily disable it if needed and nothing will break.
9595-9696-#### Cog Config
2525+Bingus will learn from all channels he has access to but will only auto-reply in these ones.
97269898-For simplicity we'll just use env vars for config.
2727+## Commands
9928100100-Try to documents these options within this README file under the
101101-[The individual cogs docs](#cog-docs). Create a third-level heading with your
102102-cog's name, and a link to its source code.
2929+Commands with `*` require you to be the owner of the bot. Create a team in the Discord
3030+dev portal to make multiple people owner.
10331104104-#### Formatting
3232+- `/markov`: For a reply from Bingus in the current channel
3333+- `/weights`: View the weights for a specific token
3434+- `/dump_chain`: Dump Bingus' "brain", his entire database of known words and relations
3535+- `/load_chain`: Additively load a brain file into Bingus
10536106106-Try to run `poetry run format` every-so-often to format your code.