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.
|
||||
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
|
||||
|
||||
- `.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)
|
||||
msg = msg:sub(s + 1)
|
||||
else
|
||||
if cmdprefix == '@' or channels[msg:sub(2)] or msg == main_channel
|
||||
if cmdprefix ~= '#' or channels[msg:sub(2)] or msg == main_channel
|
||||
then
|
||||
channel = msg
|
||||
if channel == main_channel then
|
||||
|
@ -110,6 +110,9 @@ minetest.register_on_sending_chat_messages(function(msg)
|
|||
if c == '@' then
|
||||
minetest.display_chat_message('-!- <' .. localplayer .. '> ' .. msg)
|
||||
return true
|
||||
elseif c == '@[off]' then
|
||||
minetest.send_chat_message('[off] ' .. msg)
|
||||
return true
|
||||
end
|
||||
local players = get_channel_users(c)
|
||||
if not players then return end
|
||||
|
@ -146,7 +149,15 @@ minetest.register_on_receiving_chat_messages(function(msg)
|
|||
hijack = true
|
||||
end
|
||||
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
|
||||
end
|
||||
elseif m:match('^PM from [^\\- ]*: -[^ ]*- ') then
|
||||
|
@ -278,7 +289,7 @@ minetest.register_chatcommand('toggle_' .. main_channel:sub(2), {
|
|||
show_main_channel = true
|
||||
return true, "You will now start to receive messages from "
|
||||
.. main_channel .. "."
|
||||
elseif channel == main_channel then
|
||||
elseif channel == main_channel or channel == '@[off]' then
|
||||
return false, "You are currently in " .. main_channel
|
||||
.. "! Please change channels first."
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue