an experimental irc client

config: don't require user or realname

rockorager.dev 8596cc7b 87060414

verified
+31 -13
+2 -2
docs/comlink.3.scd
··· 39 configuration. The table has the following required fields: 40 41 - *server*: string, the server URL 42 - - *user*: string, username used in SASL 43 - *nick*: string, nickname to identify as 44 - *password*: string, password to use in SASL 45 - - *real_name*: string, user's real name 46 47 The following optional fields are available: 48 49 - *port*: uint16 (default=6697 (tls) or 6667), port to use for 50 connection 51 - *tls*: boolean (default=true), when true, use an encrypted connection 52 53 *comlink.log* 54 Accepts a string and inserts a log statement into the comlink
··· 39 configuration. The table has the following required fields: 40 41 - *server*: string, the server URL 42 - *nick*: string, nickname to identify as 43 - *password*: string, password to use in SASL 44 45 The following optional fields are available: 46 47 - *port*: uint16 (default=6697 (tls) or 6667), port to use for 48 connection 49 + - *real_name*: string, user's real name 50 - *tls*: boolean (default=true), when true, use an encrypted connection 51 + - *user*: string, username used in SASL 52 53 *comlink.log* 54 Accepts a string and inserts a log statement into the comlink
+2 -2
docs/comlink.lua
··· 18 ---@class ConnectionConfiguration 19 --- 20 ---@field server string The server to connect to, eg "chat.sr.ht" 21 - ---@field user string Username for server connection 22 ---@field nick string Nick to use when connecting via SASL to IRC 23 ---@field password string Password for server 24 - ---@field real_name string Real name of user 25 ---@field tls? boolean Whether to encrypt connections 26 ---@field port? number Optional port to use for server connection. Defaults to 6697 for TLS connections and 6667 for plaintext connections 27
··· 18 ---@class ConnectionConfiguration 19 --- 20 ---@field server string The server to connect to, eg "chat.sr.ht" 21 + ---@field user? string Username for server connection 22 ---@field nick string Nick to use when connecting via SASL to IRC 23 ---@field password string Password for server 24 + ---@field real_name? string Real name of user 25 ---@field tls? boolean Whether to encrypt connections 26 ---@field port? number Optional port to use for server connection. Defaults to 6697 for TLS connections and 6667 for plaintext connections 27
+27 -9
src/lua.zig
··· 315 lua.argCheck(lua.isTable(1), 1, "expected a table"); 316 317 // [table] 318 - var lua_type = lua.getField(1, "user"); // [table,string] 319 - lua.argCheck(lua_type == .string, 1, "expected a string for field 'user'"); 320 - const user = lua.toString(-1) catch unreachable; 321 - lua.pop(1); // [table] 322 - 323 - lua_type = lua.getField(1, "nick"); // [table,string] 324 lua.argCheck(lua_type == .string, 1, "expected a string for field 'nick'"); 325 const nick = lua.toString(-1) catch unreachable; 326 lua.pop(1); // [table] 327 328 lua_type = lua.getField(1, "password"); // [table, string] 329 lua.argCheck(lua_type == .string, 1, "expected a string for field 'password'"); 330 const password = lua.toString(-1) catch unreachable; 331 lua.pop(1); // [table] 332 333 lua_type = lua.getField(1, "real_name"); // [table, string] 334 - lua.argCheck(lua_type == .string, 1, "expected a string for field 'real_name'"); 335 - const real_name = lua.toString(-1) catch unreachable; 336 - lua.pop(1); // [table] 337 338 lua_type = lua.getField(1, "server"); // [table, string] 339 lua.argCheck(lua_type == .string, 1, "expected a string for field 'server'");
··· 315 lua.argCheck(lua.isTable(1), 1, "expected a table"); 316 317 // [table] 318 + var lua_type = lua.getField(1, "nick"); // [table,string] 319 lua.argCheck(lua_type == .string, 1, "expected a string for field 'nick'"); 320 const nick = lua.toString(-1) catch unreachable; 321 lua.pop(1); // [table] 322 323 + lua_type = lua.getField(1, "user"); // [table,string] 324 + const user: []const u8 = switch (lua_type) { 325 + .nil => blk: { 326 + lua.pop(1); // [table] 327 + break :blk nick; 328 + }, 329 + .string => blk: { 330 + const val = lua.toString(-1) catch ""; 331 + lua.pop(1); // [table] 332 + break :blk val; 333 + }, 334 + else => lua.raiseErrorStr("expected a string for field 'user'", .{}), 335 + }; 336 + 337 lua_type = lua.getField(1, "password"); // [table, string] 338 lua.argCheck(lua_type == .string, 1, "expected a string for field 'password'"); 339 const password = lua.toString(-1) catch unreachable; 340 lua.pop(1); // [table] 341 342 lua_type = lua.getField(1, "real_name"); // [table, string] 343 + const real_name: []const u8 = switch (lua_type) { 344 + .nil => blk: { 345 + lua.pop(1); // [table] 346 + break :blk nick; 347 + }, 348 + .string => blk: { 349 + const val = lua.toString(-1) catch ""; 350 + lua.pop(1); // [table] 351 + break :blk val; 352 + }, 353 + else => lua.raiseErrorStr("expected a string for field 'real_name'", .{}), 354 + }; 355 356 lua_type = lua.getField(1, "server"); // [table, string] 357 lua.argCheck(lua_type == .string, 1, "expected a string for field 'server'");