diff --git a/asyncoperations.lua b/asyncoperations.lua index bd0c652..a3536f0 100644 --- a/asyncoperations.lua +++ b/asyncoperations.lua @@ -1,12 +1,16 @@ local table = table local assert = assert +local select = select module "irc" local meta = _META -function meta:send(fmt, ...) - local bytes, err = self.socket:send(fmt:format(...) .. "\r\n") +function meta:send(msg, ...) + if select("#", ...) > 0 then + msg = msg:format(...) + end + local bytes, err = self.socket:send(msg .. "\r\n") if not bytes and err ~= "timeout" and err ~= "wantwrite" then self:invoke("OnDisconnect", err, true) diff --git a/doc/irc.luadoc b/doc/irc.luadoc index ff5bbee..70b4206 100644 --- a/doc/irc.luadoc +++ b/doc/irc.luadoc @@ -71,9 +71,9 @@ function irc:whois(nick) function irc:topic(channel) --- Send a raw line of IRC to the server. --- @param fmt Line to be sent, excluding newline characters. --- @param ... Format parameters for fmt, with string.format semantics. -function irc:send(fmt, ...) +-- @param msg Line to be sent, excluding newline characters. +-- @param ... Format parameters for msg, with string.format semantics. [optional] +function irc:send(msg, ...) --- Send a message to a channel or user. -- @param target Nick or channel to send to. diff --git a/init.lua b/init.lua index 6571740..4f0f0da 100644 --- a/init.lua +++ b/init.lua @@ -26,7 +26,7 @@ function meta_preconnect.__index(o, k) local v = rawget(meta_preconnect, k) if not v and meta[k] then - error("field '"..k.."' is not accessible before connecting", 2) + error(("field '%s' is not accessible before connecting"):format(k), 2) end return v end