refactor(bot): rename bot.hear to bot.store

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.
This commit is contained in:
Jacob Jonsson 2026-03-15 13:49:07 +01:00
parent 4d1f22194c
commit 958c00ce6f
Signed by: Jassob
GPG key ID: 7E30B9B047F7202E
2 changed files with 7 additions and 7 deletions

View file

@ -216,7 +216,7 @@ test "hear and deinit has no leaks" {
defer bot.deinit();
const testMessage = try newTestMessage(allocator, "test");
bot.hear(testMessage);
bot.store(testMessage);
try std.testing.expectEqual(0, bot.backlog.top);
}
@ -228,7 +228,7 @@ test "a few hears and deinit has no leaks" {
for (0..2) |_| {
const testMessage = try newTestMessage(std.testing.allocator, "test");
bot.hear(testMessage);
bot.store(testMessage);
}
try std.testing.expectEqual(1, bot.backlog.top);
@ -240,7 +240,7 @@ test "hear wraps" {
for (0..1025) |_| {
const testMessage = try newTestMessage(std.testing.allocator, "test");
bot.hear(testMessage);
bot.store(testMessage);
}
try std.testing.expectEqual(0, bot.backlog.top);
@ -266,7 +266,7 @@ test "execute substitution" {
// hear original message with typo
const msg = try newTestMessage(allocator, "What");
bot.hear(msg);
bot.store(msg);
// execute substitution
const cmd = UserCommand.init_substitute("jassob", "What", "what", false);
@ -287,7 +287,7 @@ test "execute substitution with no matching needle" {
// hear original message
const msg = try newTestMessage(std.testing.allocator, "original");
bot.hear(msg);
bot.store(msg);
// execute substitution
const cmd = UserCommand.init_substitute("jassob", "something else", "weird", false);
@ -300,7 +300,7 @@ test "recursive substitutions does not cause issues" {
// hear original message
const msg = try newTestMessage(std.testing.allocator, "original");
bot.hear(msg);
bot.store(msg);
// execute substitution
const cmd = UserCommand.init_substitute("jassob", "original", "something else", false);

View file

@ -85,7 +85,7 @@ pub const BotAdapter = struct {
msg.targets,
msg.text,
) catch |err| return report_error(err);
self.bot.hear(bot_msg);
self.bot.store(bot_msg);
return null;
},
.JOIN => |msg| {