This commit removes the BotAdapter.erased_callback function, which
served as a generic version of BotAdapter.callback that was legible
for zircon.MessageClosure.
However, it is clearer to document how that mechanism works. Therefore
we remove the BotAdapter.erased_callback and instead makes
BotAdapter.callback match the zircon.MessageClosure.callbackFn
signature.
This commit updates the function to match the naming conventions used
in Zig, where variables and fields are snake_case, but functions are
camelCase and types are PascalCase.
This commit moves the logic that governs what action to take when a
message is heard by the bot from the BotAdapter (which should be a
layer only responsible for translating IRC messages to our internal
representation) to the Bot. This makes it possible to test full
conversations in the bot tests.
Clearer what it actually does (i.e. record a message in the backlog)
and also unlocks that name for a dispatch function where we hear any
message and decide what to do with it. Currently that dispatch logic
lives inside BotAdapter in main.zig and that is not ideal.
The response type holds represents the way a bot can respond to a
message it executes and allows us to move the IRC dependency out of
bot and into only the main module.
Found while the IRC users tried to find bugs in the code base.
Currently the bot does not "hear" the commands of users, which means
that of the following conversation:
```
<jassob> helo, world!
<jassob> s/helo/hello/
```
the only heard messages in the backlog would be the first ("helo,
world!"), the substitution would be parsed and executed, but not added
to the backlog and hence not possible to update.
This commit reduces the repetitions in the tests when we create new
messages. It hardcodes a bunch of fields that are currently not used,
but might be eventually.
There was a bug in the parsing logic that caused a substitution
command like `s/typo/correction` to crash the bot.
Correct command is of course `s/typo/correction/`, but now it at least
shouldn't crash.
There was a bug in how we parsed admin commands, apparently we never
tested if we could parse `!backlog X` or unknown admin commands.
This commit also make updates to the backlog command construction to
make sure that we don't try to access messages in the backlog that
don't exist.
This commit creates a bunch of new modules that contain code and tests
for various concepts/implementations that used to exist inside
bot.zig.
Notable amongst these are:
- buffer.zig, which contain the circular buffer containing both
backlog and outbox messages.
- parser.zig, which contain the parser used to parse commands from IRC
messages.
This commit introduces a Bot struct which is the main type of this
project. The Bot holds a backlog of messages to be able to update a
typo in a message and so on.
So far there is no IRC/TLS implementation, it is only the base logic.