Info and Info Reactor
Info
- class mcdreforged.info_reactor.info.Info(source: InfoSource, raw_content: str, id: int = <factory>, hour: int | None = None, min: int | None = None, sec: int | None = None, content: str | None = None, player: str | None = None, logging_level: str | None = None, action_flag: InfoActionFlag = <InfoActionFlag.send_to_server|echo_to_console|process: 7>, _Info__control_data: _InfoControlData | None = None)[source]
An
Infoinstance contains the parsed result from the server or from the console- source: InfoSource
A int (actually
InfoSource, a subclass of int) representing the the type of the infoFor info from the server, its value is
0For info from the console, its value is
1See
InfoSourcefor all possible values
- raw_content: str
Very raw unparsed content from the server stdout / stderr
It’s also the content to be echoed to the console stdout
- content: str | None = None
The parsed message text
If the text is sent by a player it will be what the player said. Otherwise it will be the content that removes stuffs like timestamp or thread name
- player: str | None = None
The name of the player
If it’s not sent by a player the value will be None
- logging_level: str | None = None
The logging level of the server’s output, such as
"INFO"or"WARN"
- action_flag: InfoActionFlag = 7
A flag variable controlling what actions MCDR will do next with this Info object
See also
class
InfoActionFlag
- property is_from_console: bool
If the source of the info is
InfoSource.CONSOLE(1), i.e. from the console
- property is_from_server: bool
If the source of the info is
InfoSource.SERVER(0), i.e. from the server
- property is_user: bool
If the source is from a user, i.e. if the source is from the console or from a player in the server
- get_server() ServerInterface[source]
Return the server interface instance
- get_command_source() InfoCommandSource | None[source]
Extract a command source object from this object:
ConsoleCommandSourceif this info is from consolePlayerCommandSourceif this info is from a player in the serverOtherwise: return None
- Returns:
The command source instance, or None if it can’t extract a command source
- to_command_source() InfoCommandSource[source]
The same to method
get_command_source(), but it raises aIllegalCallErrorif it can’t extract a command source- Raises:
IllegalCallError – if a command source cannot be extracted from this object
- class mcdreforged.info_reactor.info.InfoActionFlag(*values)[source]
Bases:
FlagA flag variable controlling what actions MCDR will do next with this Info object
- send_to_server = 1
Send the content from console stdin to server stdin
- echo_to_console = 2
Print the server output to the console stdout
- process = 4
Allow subsequent info reactor processing, such as plugin event dispatching
- classmethod default() InfoActionFlag[source]
The default flag set that allows all actions to be performed
Do not echo the server output to the console, perform the subsequent actions silently
- classmethod discarded() InfoActionFlag[source]
Discard the info object right now, no more future processing
Info Reactor
- class mcdreforged.info_reactor.abstract_info_reactor.AbstractInfoReactor(mcdr_server: MCDReforgedServer)[source]
The abstract base class for info reactors
- mcdr_server: MCDReforgedServer
The MCDR server object
Info Filter
- class mcdreforged.info_reactor.info_filter.InfoFilter[source]
- abstractmethod filter_server_info(info: Info) bool | None[source]
Filter an info object from the server output, check if it should be discarded
If the server info object is discarded, it will not be echoed to the console output, and will not be processed by any of the remaining MCDR logic
Do not affect innocent info objects; that is, do not discard those info that contains important messages (e.g. server start / stop), or MCDR might not work correctly
This function is invoked right after an
Infoobject is parsed from server outputTo precisely control what actions MCDR should take next for the info object, you can edit its
~in this function. ReturningFalseis actually equivalent to:info.action_flag = InfoActionFlag.discarded()
See also
class
InfoActionFlag- Parameters:
info – The info object, which is parsed from server output, to check
- Returns:
False: discard the info object; other: do nothing