Disabling chat?

Legoracer
New member
 
Posts: 3
Joined: Tue Oct 08, 2019 21:59
GitHub: Legoracer
In-game: Legoracer

Disabling chat?

by Legoracer » Tue Oct 08, 2019 22:15

(I'm new to these forums, so I apologize if I posted in wrong category)

Hello,
I've been looking at the documentation for the past hour and can't seem to find anything that could be used to disable or edit the chat/command/console ("/" key).

Is this possible or is it currently past the possibilities of the engine?
Thanks!
 

User avatar
Krock
Developer
 
Posts: 4393
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Disabling chat?

by Krock » Wed Oct 09, 2019 17:41

Restrict all server commands to server admins only:
Code: Select all
local priv_required = "server

for cmd, def in pairs(minetest.registered_chatcommands) do
   def.privs[priv_required] = true
end


Disable chatting ("/me" inclusive) entirely -> same as /revoke <player> shout
Code: Select all
minetest.register_on_joinplayer(function(player)
   local auth = minetest.get_auth_handler()
   local player_name = player:get_player_name()
   local player_auth = auth.get_auth(player_name)

   player_auth.privileges.shout = nil

   auth.set_privileges(player_name, player_auth.privileges)
end)


Untested code.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

micheal65536
Member
 
Posts: 140
Joined: Mon May 22, 2017 20:27

Re: Disabling chat?

by micheal65536 » Wed Oct 09, 2019 18:27

Krock wrote:Restrict all server commands to server admins only:
Code: Select all
local priv_required = "server

for cmd, def in pairs(minetest.registered_chatcommands) do
   def.privs[priv_required] = true
end

You're missing a quote at the end of the first line so this will fail with a syntax error. Also you'd need to make sure that this code runs after all the commands have been registered, so ideally after all other mods have loaded (minetest really still needs a way to do this elegantly...). Not to mention that you should probably be using minetest.override_chatcommand.

The other snippets looks good to me though (although I'm not familiar with the authentication API so I might be missing something).
 

User avatar
Linuxdirk
Member
 
Posts: 2200
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk
 


Return to Feature Discussion



Who is online

Users browsing this forum: No registered users and 7 guests