From 7d444204efc1c2d3544724003844d0e25cea71c6 Mon Sep 17 00:00:00 2001 From: Jacob Jonsson Date: Sun, 15 Mar 2026 15:13:29 +0100 Subject: [PATCH] docs(main): add comments to functions and types --- src/main.zig | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.zig b/src/main.zig index c41ad19..0caba3b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -49,6 +49,16 @@ pub const Adapter = struct { callbackFn: *const fn (*anyopaque, zircon.Message) ?zircon.Message, }; +/// BotAdapter is the closure that we register in zircon as the +/// message callback. +/// +/// Whenever a message is received by the zircon client it will invoke +/// BotAdapter.callback (through some indirection) with the received +/// message. +/// +/// The main responsibility of BotAdapter is to serve as the +/// translation layer between our own internal types and the zircon +/// IRC types. pub const BotAdapter = struct { bot: Bot, allocator: std.mem.Allocator, @@ -64,6 +74,14 @@ pub const BotAdapter = struct { self.bot.deinit(); } + /// callback gets called for every message that we receive. + /// + /// This is where we can extend the bot to support more types of + /// messages if needed. + /// + /// See + /// - https://modern.ircdocs.horse/, for what kinds of messages exists in the IRC protocol documentation, + /// - https://github.com/Jassob/zircon/blob/main/src/message.zig, for zircon documentation. pub fn callback(self: *BotAdapter, message: zircon.Message) ?zircon.Message { switch (message) { .PRIVMSG => |msg| { @@ -97,6 +115,7 @@ pub const BotAdapter = struct { } } + /// report errors as private message to admin channel. fn reportError(err: Error) zircon.Message { const err_msg = switch (err) { Error.NoMessage => "no matching message",