customizing ingame messages
This commit is contained in:
parent
f57bdba5e9
commit
8ac7aa1c4b
27
hooks.lua
27
hooks.lua
@ -9,7 +9,6 @@ local b64e = ie.require("mime").b64
|
||||
irc.hooks = {}
|
||||
irc.registered_hooks = {}
|
||||
|
||||
|
||||
local stripped_chars = "[\2\31]"
|
||||
|
||||
local function normalize(text)
|
||||
@ -86,7 +85,7 @@ function irc.hooks.ctcp(msg)
|
||||
|
||||
if command == "ACTION" and msg.args[1] == irc.config.channel then
|
||||
local action = text:sub(8, -1)
|
||||
irc.sendLocal(("* %s@IRC %s"):format(msg.user.nick, action))
|
||||
irc.sendLocal(("* %s"..core.colorize("#A3B5CB","@IRC ").."%s"):format(msg.user.nick, action))
|
||||
elseif command == "VERSION" then
|
||||
reply(("Minetest version %s, IRC mod version %s.")
|
||||
:format(get_core_version(), irc.version))
|
||||
@ -126,19 +125,19 @@ function irc.hooks.channelChat(msg)
|
||||
if text:sub(1, 5) == "[off]" then
|
||||
return
|
||||
elseif foundchat then
|
||||
irc.sendLocal(("<%s@%s> %s")
|
||||
irc.sendLocal(("<%s"..core.colorize("#A3B5CB","@%s").."> %s")
|
||||
:format(chatnick, msg.user.nick, chatmessage))
|
||||
elseif foundjoin then
|
||||
irc.sendLocal(("*** %s joined %s")
|
||||
irc.sendLocal((core.colorize("#4ec44e", "➡ ")..core.colorize("#a74ec4", " %s")..core.colorize("#c44eb5"," just joined %s!"))
|
||||
:format(joinnick, msg.user.nick))
|
||||
elseif foundleave then
|
||||
irc.sendLocal(("*** %s left %s")
|
||||
irc.sendLocal((core.colorize("#c44e4e", "⬅ ")..core.colorize("#a74ec4", " %s")..core.colorize("#c44eb5"," just left %s... ."))
|
||||
:format(leavenick, msg.user.nick))
|
||||
elseif foundaction then
|
||||
irc.sendLocal(("* %s@%s %s")
|
||||
irc.sendLocal(("* %s"..core.colorize("#A3B5CB","@%s").." %s")
|
||||
:format(actionnick, msg.user.nick, actionmessage))
|
||||
else
|
||||
irc.sendLocal(("<%s@IRC> %s"):format(msg.user.nick, text))
|
||||
irc.sendLocal(("<%s"..core.colorize("#A3B5CB","@IRC").."> %s"):format(msg.user.nick, text))
|
||||
end
|
||||
end
|
||||
|
||||
@ -182,32 +181,32 @@ function irc.hooks.mode(user, target, modes, ...)
|
||||
options = " "
|
||||
end
|
||||
options = options .. table.concat({...}, " ")
|
||||
minetest.chat_send_all(("-!- mode/%s [%s%s]%s")
|
||||
minetest.chat_send_all((core.colorize("#c44eb5", "-!-").." mode/%s [%s%s]%s")
|
||||
:format(target, modes, options, by))
|
||||
end
|
||||
|
||||
|
||||
function irc.hooks.nick(user, newNick)
|
||||
irc.sendLocal(("-!- %s is now known as %s")
|
||||
irc.sendLocal((core.colorize("#c44eb5", "-!-")..core.colorize("#a74ec4", " %s")..core.colorize("#c44eb5"," is now known as")..core.colorize("#a74ec4", " %s"))
|
||||
:format(user.nick, newNick))
|
||||
end
|
||||
|
||||
|
||||
function irc.hooks.join(user, channel)
|
||||
irc.sendLocal(("-!- %s joined %s")
|
||||
irc.sendLocal((core.colorize("#4ec44e", "-!-")..core.colorize("#a74ec4", " %s")..core.colorize("#c44eb5"," joined %s"))
|
||||
:format(user.nick, channel))
|
||||
end
|
||||
|
||||
|
||||
function irc.hooks.part(user, channel, reason)
|
||||
reason = reason or ""
|
||||
irc.sendLocal(("-!- %s has left %s [%s]")
|
||||
irc.sendLocal((core.colorize("#c44e4e", "-!-")..core.colorize("#a74ec4", " %s")..core.colorize("#c44eb5"," has left %s [%s]"))
|
||||
:format(user.nick, channel, reason))
|
||||
end
|
||||
|
||||
|
||||
function irc.hooks.quit(user, reason)
|
||||
irc.sendLocal(("-!- %s has quit [%s]")
|
||||
irc.sendLocal((core.colorize("#c44e4e", "-!-")..core.colorize("#a74ec4", " %s")..core.colorize("#c44eb5"," has quit [%s]"))
|
||||
:format(user.nick, reason))
|
||||
end
|
||||
|
||||
@ -216,11 +215,11 @@ function irc.hooks.disconnect(_, isError)
|
||||
irc.connected = false
|
||||
if isError then
|
||||
minetest.log("error", "IRC: Error: Disconnected, reconnecting in one minute.")
|
||||
minetest.chat_send_all("IRC: Error: Disconnected, reconnecting in one minute.")
|
||||
minetest.chat_send_all(core.colorize("#c44e4e", "IRC: Error: Disconnected, reconnecting in one minute."))
|
||||
minetest.after(60, irc.connect, irc)
|
||||
else
|
||||
minetest.log("action", "IRC: Disconnected.")
|
||||
minetest.chat_send_all("IRC: Disconnected.")
|
||||
minetest.chat_send_all(core.colorize("#c44e4e", "IRC: Disconnected."))
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user