-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add /remote_mute and /remote_unmute commands (#65)
* Create remote_mute.lua * Maybe fix luacheck and indentation? * Load remote_mute.lua * Fix name for remote_mute checks
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
local remote_muted = {} | ||
|
||
minetest.register_chatcommand("remote_mute", { | ||
params = "<Player Name> [<Player Name> ...]", | ||
description = ("Mute remote users. Requires %s privilege."):format(beerchat.jail.priv), | ||
privs = { [beerchat.jail.priv] = true }, | ||
func = function(_, param) | ||
if not param or param == "" then | ||
return false, "ERROR: Invalid number of arguments. Please supply the player name(s)." | ||
end | ||
local names = string.gmatch(param, "[^%s,]+") | ||
for remote_name in names do | ||
remote_muted[remote_name] = true | ||
end | ||
return true | ||
end | ||
}) | ||
|
||
minetest.register_chatcommand("remote_unmute", { | ||
params = "[<Player Name> <Player Name> ...]", | ||
description = ("Unmute remote users or list muted remote users. Requires %s privilege."):format(beerchat.jail.priv), | ||
privs = { [beerchat.jail.priv] = true }, | ||
func = function(name, param) | ||
if not param or param == "" then | ||
local names = {} | ||
for remote_name,_ in pairs(remote_muted) do | ||
table.insert(names, remote_name) | ||
end | ||
if #names > 0 then | ||
minetest.chat_send_player(name, "Muted remote users: " .. table.concat(names, ", ")) | ||
else | ||
minetest.chat_send_player(name, "No muted remote users.") | ||
end | ||
else | ||
local names = string.gmatch(param, "[^%s,]+") | ||
for remote_name in names do | ||
remote_muted[remote_name] = nil | ||
end | ||
end | ||
return true | ||
end | ||
}) | ||
|
||
beerchat.register_callback('on_http_receive', function(msg_data) | ||
if remote_muted[msg_data.username .. "@" .. msg_data.name] then | ||
return false | ||
end | ||
end) |