-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat.lua
36 lines (32 loc) · 1.28 KB
/
chat.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
verbana.chat = {}
local data = verbana.data
local privs = verbana.privs
function verbana.chat.tell_mods(message, ...)
message = message:format(...)
local irc_message = '[verbana] ' .. minetest.strip_colors(message)
if minetest.global_exists('irc') then irc.say(irc_message) end
if minetest.global_exists('irc2') then irc2.say(irc_message) end
for _, player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if privs.is_privileged(name) then
minetest.chat_send_player(name, message)
end
end
end
-- make this the first chat message handler by inserting it at the start.
-- this has the effect of
-- (1) preempting irc (and irc2)
-- (2) disabling all server-side commands
table.insert(minetest.registered_on_chat_messages, 1,
function(name, message)
local player_id = data.get_player_id(name)
local player_status = data.get_player_status(player_id)
local is_unverified = player_status.id == data.player_status.unverified.id
if is_unverified then
local cmsg = ('[unverified] <%s> %s'):format(name, message)
verbana.chat.tell_mods(cmsg)
minetest.chat_send_player(name, cmsg)
return true
end
return false
end)