Info and Info Reactor
Info
- class mcdreforged.info_reactor.info.Info(source: InfoSource, raw_content: str)[source]
An
Info
instance contains the parsed result from the server or from the console- raw_content: str
Very raw unparsed content from the server stdout.
It’s also the content to be echoed to the stdout
- content: str | 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
- source: InfoSource
A int (actually
InfoSource
, a subclass of int) representing the the type of the infoFor info from the server, its value is
0
For info from the console, its value is
1
See
InfoSource
for all possible values
- property player: str | None
The name of the player
If it’s not sent by a player the value will be None
- 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:
ConsoleCommandSource
if this info is from consolePlayerCommandSource
if this info is from a player in the server
- 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 aIllegalCallError
if it can’t extract a command source- Raises:
IllegalCallError – if a command source cannot be extracted from this object
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]
- abstract filter_server_info(info: Info) bool [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
Info
object is parsed from server output- Parameters:
info – The info object, which is parsed from server output, to check
- Returns:
True: do nothing; False: discard the info object