an experimental irc client
1---@meta
2
3--- The primary comlink module
4---
5---@class comlink
6local comlink = {}
7
8---@class ConnectionConfiguration
9---
10---@field server string The server to connect to, eg "chat.sr.ht"
11---@field user string Username for server connection
12---@field nick string Nick to use when connecting via SASL to IRC
13---@field password string Password for server
14---@field real_name string Real name of user
15---@field tls? boolean Whether to encrypt connections
16
17---A connection to a server
18---
19---@class Connection
20---
21---@field on_connect fun(conn: Connection) Called after successful connection to the server
22---@field on_message fun(channel: string, sender: string, msg: string) Called after receiving a PRIVMSG
23local conn = {}
24
25---Returns the name of the connection
26---
27---@return string name Name of the connection
28function conn.name() end
29
30---Joins a channel
31---
32---@param channel string Name of the channel to join
33function conn.join(channel) end
34
35---Set connection configuration
36---
37---@param cfg ConnectionConfiguration
38---@return Connection
39function comlink.connect(cfg) end
40
41---Log a msg to the comlink logs
42---
43---@param msg string The message to log
44function comlink.log(msg) end
45
46--- A command for comlink to execute
47---
48---@enum action
49local Action = {
50 quote = "quote",
51 me = "me",
52 msg = "msg",
53 next_channel = "next-channel",
54 prev_channel = "prev-channel",
55 quit = "quit",
56 redraw = "redraw",
57 who = "who",
58}
59
60---Bind a key
61---
62---@param key string The key to bind, eg "alt+n", "shift+left"
63---@param action action|function The action to perform, eg "quit"
64function comlink.bind(key, action) end
65
66---Send a system notification
67---
68---@param title string Title of the notification
69---@param body string Body of the notification
70function comlink.notify(title, body) end
71
72---Add a custom command to comlink
73---
74---@param name string Name of the command
75---@param fn fun(cmdline: string) Callback for the command. Receives the commandline as enterred, with the name removed, then any leading or trailing whitespace removed
76function comlink.add_command(name, fn) end
77
78---Get the currently selected buffer
79---
80---@return Channel|nil
81function comlink.selected_channel() end
82
83---A channel.
84---
85---@class Channel
86local channel = {}
87
88---Send a message to the channel. If the message begins with a '/', it will be processed as a command. This allows for sending of "/me <msg>" style messages from lua
89---
90---@param chan Channel this channel
91---@param msg string message to send
92function channel.send_msg(chan, msg) end
93
94---Get the name of the channel
95---
96---@param chan Channel // this channel
97---@return string name name of the channel
98function channel.name(chan) end
99
100return comlink