an experimental irc client
at main 3.3 kB view raw
1---@meta 2 3--- The primary comlink module 4--- 5---@class comlink 6local comlink = {} 7 8---@class Configuration 9--- 10---@field markread_on_focus boolean When true, the unread indicator will be reset when comlink 11---regains focus 12 13---Global configuration 14--- 15---@param cfg Configuration | {} Comlink global configuration 16function comlink.setup(cfg) end 17 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 28---A connection to a server 29--- 30---@class Connection 31--- 32---@field on_connect fun(conn: Connection) Called after successful connection to the server 33---@field on_message fun(channel: string, sender: string, msg: string) Called after receiving a PRIVMSG 34local conn = {} 35 36---Returns the name of the connection 37--- 38---@return string name Name of the connection 39function conn.name() end 40 41---Joins a channel 42--- 43---@param channel string Name of the channel to join 44function conn.join(channel) end 45 46---Set connection configuration 47--- 48---@param cfg ConnectionConfiguration 49---@return Connection 50function comlink.connect(cfg) end 51 52---Log a msg to the comlink logs 53--- 54---@param msg string The message to log 55function comlink.log(msg) end 56 57--- A command for comlink to execute 58--- 59---@enum action 60local Action = { 61 quote = "quote", 62 me = "me", 63 msg = "msg", 64 next_channel = "next-channel", 65 prev_channel = "prev-channel", 66 quit = "quit", 67 redraw = "redraw", 68 who = "who", 69} 70 71---Bind a key 72--- 73---@param key string The key to bind, eg "alt+n", "shift+left" 74---@param action action|function The action to perform, eg "quit" 75function comlink.bind(key, action) end 76 77---Send a system notification 78--- 79---@param title string Title of the notification 80---@param body string Body of the notification 81function comlink.notify(title, body) end 82 83---Add a custom command to comlink 84--- 85---@param name string Name of the command 86---@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 87function comlink.add_command(name, fn) end 88 89---Get the currently selected buffer 90--- 91---@return Channel|nil 92function comlink.selected_channel() end 93 94---A channel. 95--- 96---@class Channel 97local channel = {} 98 99---Get the name of the channel 100--- 101---@param chan Channel // this channel 102---@return string name name of the channel 103function channel.name(chan) end 104 105---Insert text at the cursor 106--- 107---@param chan Channel this channel 108---@param text string text to insert 109function channel.insert_text(chan, text) end 110 111---Mark a channel as read 112--- 113---@param chan Channel // this channel 114function channel.mark_read(chan) end 115 116---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 117--- 118---@param chan Channel this channel 119---@param msg string message to send 120function channel.send_msg(chan, msg) end 121 122return comlink