an experimental irc client
at c43db93cce5477a2a21807a1b075dd8b35d71974 106 lines 2.9 kB view raw
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---@field port? number Optional port to use for server connection. Defaults to 6697 for TLS connections and 6667 for plaintext connections 17 18---A connection to a server 19--- 20---@class Connection 21--- 22---@field on_connect fun(conn: Connection) Called after successful connection to the server 23---@field on_message fun(channel: string, sender: string, msg: string) Called after receiving a PRIVMSG 24local conn = {} 25 26---Returns the name of the connection 27--- 28---@return string name Name of the connection 29function conn.name() end 30 31---Joins a channel 32--- 33---@param channel string Name of the channel to join 34function conn.join(channel) end 35 36---Set connection configuration 37--- 38---@param cfg ConnectionConfiguration 39---@return Connection 40function comlink.connect(cfg) end 41 42---Log a msg to the comlink logs 43--- 44---@param msg string The message to log 45function comlink.log(msg) end 46 47--- A command for comlink to execute 48--- 49---@enum action 50local Action = { 51 quote = "quote", 52 me = "me", 53 msg = "msg", 54 next_channel = "next-channel", 55 prev_channel = "prev-channel", 56 quit = "quit", 57 redraw = "redraw", 58 who = "who", 59} 60 61---Bind a key 62--- 63---@param key string The key to bind, eg "alt+n", "shift+left" 64---@param action action|function The action to perform, eg "quit" 65function comlink.bind(key, action) end 66 67---Send a system notification 68--- 69---@param title string Title of the notification 70---@param body string Body of the notification 71function comlink.notify(title, body) end 72 73---Add a custom command to comlink 74--- 75---@param name string Name of the command 76---@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 77function comlink.add_command(name, fn) end 78 79---Get the currently selected buffer 80--- 81---@return Channel|nil 82function comlink.selected_channel() end 83 84---A channel. 85--- 86---@class Channel 87local channel = {} 88 89---Get the name of the channel 90--- 91---@param chan Channel // this channel 92---@return string name name of the channel 93function channel.name(chan) end 94 95---Mark a channel as read 96--- 97---@param chan Channel // this channel 98function channel.mark_read(chan) end 99 100---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 101--- 102---@param chan Channel this channel 103---@param msg string message to send 104function channel.send_msg(chan, msg) end 105 106return comlink