Chat

Provides methods to interact with the server chat.

class miney.Chat(luanti: Luanti)[source]

Chat functions.

command(name: str, parameter: str = '', description: str = '', privileges: Dict | None = None) Callable[source]

Decorator to register a chat command.

This is the recommended way to register chat commands.

from miney.events import ChatCommandEvent

@lt.chat.command("hello", description="Greets the player")
def hello_command(event: ChatCommandEvent):
    lt.chat.send_to_player(event.issuer, f"Hello, {event.issuer}!")
Parameters:
  • name – The name of the command.

  • parameter – The command’s parameter string (for /help).

  • description – The command’s description (for /help).

  • privileges – Privileges required to execute the command.

Returns:

The decorator function.

on(event: str = 'chat_message', filters: Dict[str, Any] | None = None) Callable[source]

Decorator to subscribe to chat-related events.

The default and most common event is ‘chat_message’. The callback receives the full event dictionary as produced by the Miney mod.

from miney.events import ChatMessageEvent

@lt.chat.on()  # Defaults to "chat_message"
def on_chat(event: ChatMessageEvent):
    print(f"{event.sender_name}: {event.message}")
Parameters:
  • event – The name of the event to subscribe to. Defaults to ‘chat_message’.

  • filters – Optional filters for the event subscription.

Returns:

The decorator function.

on_unregister(callback: Callable[[dict], None], event: str = 'chat_message') None[source]

Unregister a previously registered event callback.

Parameters:
  • callback – The callback function to unregister.

  • event – The name of the event. Defaults to ‘chat_message’.

register_command(name: str, callback_function: callable, parameter: str = '', description: str = '', privileges: Dict | None = None)[source]

Register a chat command handled by the Python client.

This is a non-decorator way to register commands. For a more modern and readable approach, consider using the command() decorator instead.

Parameters:
  • name – The name of the command.

  • callback_function – The function to call when the command is executed.

  • parameter – The command’s parameter string (for /help).

  • description – The command’s description (for /help).

  • privileges – Privileges required to execute the command.

Returns:

The command name.

send_to_all(message: str) None[source]

Send a chat message to all connected players.

send_to_player(player: str | Player, message: str) None[source]

Send a message to a player.

unregister_command(name: str)[source]

Unregister a chat command previously registered.