@@ 21,6 21,7 @@ export fn main() void = {
nick = "harebot",
user = "harebot",
realname = "Hare IRC bot",
+ logfn = &logmsg,
...
};
@@ 46,6 47,20 @@ export fn main() void = {
for (!(irc::dispatch(conn)! is io::EOF)) void;
};
+fn logmsg(state: nullable *void, party: irc::party, msg: *irc::message) void = {
+ switch (party) {
+ case irc::party::SERVER =>
+ fmt::print("<= ")!;
+ case irc::party::CLIENT =>
+ fmt::print("-> ")!;
+ };
+ if (msg.command == "PASS") {
+ fmt::println("PASS <redacted>")!;
+ } else {
+ irc::serialize(os::stdout, msg)!;
+ };
+};
+
fn handle_privmsg(
user: nullable *void,
msg: const *irc::message,