Add `@[off]`
`@[off]` prefixes messages with `[off]`, and is displayed in chat as `[off]`.
This commit is contained in:
parent
dac3ebcd3a
commit
11f338ee01
|
@ -19,6 +19,11 @@ The following channel prefixes exist:
|
||||||
same name, the message will display as a chat message in the channel.
|
same name, the message will display as a chat message in the channel.
|
||||||
Otherwise, it will display as a PM prefixed in `-#channel-`.
|
Otherwise, it will display as a PM prefixed in `-#channel-`.
|
||||||
|
|
||||||
|
The following special channels exist:
|
||||||
|
|
||||||
|
- `#main`: Normal chat without the CSM.
|
||||||
|
- `@[off]`: Prefixes messages with `[off]`, displayed in chat as `[off]`.
|
||||||
|
|
||||||
## Added commands
|
## Added commands
|
||||||
|
|
||||||
- `.add_to_channel <victim> [channel]`: Adds `<victim>` to the channel. If
|
- `.add_to_channel <victim> [channel]`: Adds `<victim>` to the channel. If
|
||||||
|
|
17
init.lua
17
init.lua
|
@ -84,7 +84,7 @@ minetest.register_on_sending_chat_messages(function(msg)
|
||||||
c = msg:sub(1, s - 1)
|
c = msg:sub(1, s - 1)
|
||||||
msg = msg:sub(s + 1)
|
msg = msg:sub(s + 1)
|
||||||
else
|
else
|
||||||
if cmdprefix == '@' or channels[msg:sub(2)] or msg == main_channel
|
if cmdprefix ~= '#' or channels[msg:sub(2)] or msg == main_channel
|
||||||
then
|
then
|
||||||
channel = msg
|
channel = msg
|
||||||
if channel == main_channel then
|
if channel == main_channel then
|
||||||
|
@ -110,6 +110,9 @@ minetest.register_on_sending_chat_messages(function(msg)
|
||||||
if c == '@' then
|
if c == '@' then
|
||||||
minetest.display_chat_message('-!- <' .. localplayer .. '> ' .. msg)
|
minetest.display_chat_message('-!- <' .. localplayer .. '> ' .. msg)
|
||||||
return true
|
return true
|
||||||
|
elseif c == '@[off]' then
|
||||||
|
minetest.send_chat_message('[off] ' .. msg)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
local players = get_channel_users(c)
|
local players = get_channel_users(c)
|
||||||
if not players then return end
|
if not players then return end
|
||||||
|
@ -146,7 +149,15 @@ minetest.register_on_receiving_chat_messages(function(msg)
|
||||||
hijack = true
|
hijack = true
|
||||||
end
|
end
|
||||||
if hijack then
|
if hijack then
|
||||||
minetest.display_chat_message('-' .. main_channel .. '- ' .. msg)
|
if m:match('^<[^>]*> %[off%]') then
|
||||||
|
local s, e = m:find('[off]')
|
||||||
|
local sender = m:sub(1, s - 2)
|
||||||
|
local text = m:sub(s + 5)
|
||||||
|
minetest.display_chat_message('-[off]- ' .. sender .. text)
|
||||||
|
else
|
||||||
|
minetest.display_chat_message('-' .. main_channel .. '- '
|
||||||
|
.. msg)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
elseif m:match('^PM from [^\\- ]*: -[^ ]*- ') then
|
elseif m:match('^PM from [^\\- ]*: -[^ ]*- ') then
|
||||||
|
@ -278,7 +289,7 @@ minetest.register_chatcommand('toggle_' .. main_channel:sub(2), {
|
||||||
show_main_channel = true
|
show_main_channel = true
|
||||||
return true, "You will now start to receive messages from "
|
return true, "You will now start to receive messages from "
|
||||||
.. main_channel .. "."
|
.. main_channel .. "."
|
||||||
elseif channel == main_channel then
|
elseif channel == main_channel or channel == '@[off]' then
|
||||||
return false, "You are currently in " .. main_channel
|
return false, "You are currently in " .. main_channel
|
||||||
.. "! Please change channels first."
|
.. "! Please change channels first."
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue