mirror of
https://github.com/ShadowNinja/LuaIRC.git
synced 2025-01-24 17:00:21 +01:00
Interpret format codes passed to meta:send() literally if there are no format arguments
This commit is contained in:
parent
1d0480adba
commit
ddb788883e
@ -1,12 +1,16 @@
|
|||||||
local table = table
|
local table = table
|
||||||
local assert = assert
|
local assert = assert
|
||||||
|
local select = select
|
||||||
|
|
||||||
module "irc"
|
module "irc"
|
||||||
|
|
||||||
local meta = _META
|
local meta = _META
|
||||||
|
|
||||||
function meta:send(fmt, ...)
|
function meta:send(msg, ...)
|
||||||
local bytes, err = self.socket:send(fmt:format(...) .. "\r\n")
|
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
|
if not bytes and err ~= "timeout" and err ~= "wantwrite" then
|
||||||
self:invoke("OnDisconnect", err, true)
|
self:invoke("OnDisconnect", err, true)
|
||||||
|
@ -71,9 +71,9 @@ function irc:whois(nick)
|
|||||||
function irc:topic(channel)
|
function irc:topic(channel)
|
||||||
|
|
||||||
--- Send a raw line of IRC to the server.
|
--- Send a raw line of IRC to the server.
|
||||||
-- @param fmt Line to be sent, excluding newline characters.
|
-- @param msg Line to be sent, excluding newline characters.
|
||||||
-- @param ... Format parameters for <code>fmt</code>, with <code>string.format</code> semantics.
|
-- @param ... Format parameters for <code>msg</code>, with <code>string.format</code> semantics. [optional]
|
||||||
function irc:send(fmt, ...)
|
function irc:send(msg, ...)
|
||||||
|
|
||||||
--- Send a message to a channel or user.
|
--- Send a message to a channel or user.
|
||||||
-- @param target Nick or channel to send to.
|
-- @param target Nick or channel to send to.
|
||||||
|
2
init.lua
2
init.lua
@ -26,7 +26,7 @@ function meta_preconnect.__index(o, k)
|
|||||||
local v = rawget(meta_preconnect, k)
|
local v = rawget(meta_preconnect, k)
|
||||||
|
|
||||||
if not v and meta[k] then
|
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
|
end
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user