piqueserver package¶
Module contents¶
Subpackages¶
- piqueserver.core_commands package
- Submodules
- piqueserver.core_commands.game module
- piqueserver.core_commands.info module
- piqueserver.core_commands.map module
- piqueserver.core_commands.moderation module
- piqueserver.core_commands.movement module
- piqueserver.core_commands.player module
- piqueserver.core_commands.server module
- piqueserver.core_commands.social module
- Module contents
- piqueserver.web package
Submodules¶
piqueserver.banpublish module¶
-
class
piqueserver.banpublish.
PublishResource
(factory)[source]¶ Bases:
twisted.web.resource.Resource
-
getChild
(name, request)[source]¶ Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
-
piqueserver.bansubscribe module¶
piqueserver.commands module¶
-
class
piqueserver.commands.
CommandHelp
(description, usage, info)¶ Bases:
tuple
-
description
¶ Alias for field number 0
-
info
¶ Alias for field number 2
-
usage
¶ Alias for field number 1
-
-
piqueserver.commands.
add
(func: Callable) → None[source]¶ Function to add a command from scripts. Deprecated
-
piqueserver.commands.
add_rights
(user_type: str, command_name: str) → None[source]¶ Give the user type a new right
>>> add_rights("knights", "say_ni")
-
piqueserver.commands.
admin
(func: Callable) → Callable[source]¶ Shorthand for @restrict(“admin”). Mainly exists for backwards compatibility with pyspades scripts.
>>> @admin ... @command() ... def some_command(x): ... pass
-
piqueserver.commands.
command
(name=None, *aliases, admin_only=False) → Callable[[Callable], Callable][source]¶ Register a new command.
The command will be accessible as
/function_name
unless a name or alias is specified.>>> @command() ... def some_command(x): ... pass
Optional names and aliases:
>>> @command("name", "alias1", "alias2") ... def some_command(x): ... pass
-
piqueserver.commands.
format_command_error
(command_func: Callable, message: str, exception: Exception = None) → str[source]¶ format a help message for a given command
-
piqueserver.commands.
get_command_help
(command_func: Callable) → piqueserver.commands.CommandHelp[source]¶
-
piqueserver.commands.
get_player
(protocol, value: str, spectators=True)[source]¶ Get a player connection object by name or ID.
IDs are formatted as: “#12”
If no player with the specified name is found, it will try to find a player who’s name contains the string
-
piqueserver.commands.
get_rights
(user_type: str) → List[str][source]¶ Get a list of rights a specific user type has.
>>> add_rights("knights", "say_ni") >>> get_rights("knights") ["say_ni"] >>> get_rights("arthur") []
-
piqueserver.commands.
handle_command
(connection, command, parameters)[source]¶ Public facing function to run a command, given the connection, a command name, and a list of parameters.
Will log the command.
-
piqueserver.commands.
player_only
(func: Callable)[source]¶ This recorator restricts a command to only be runnable by players connected to the server, not via other places such as, say, the console.
>>> @command() ... @player_only ... def some_command(x): ... pass
-
piqueserver.commands.
restrict
(*user_types) → Callable[source]¶ restrict the command to only be used by a specific type of user
>>> @restrict("admin", "guard") ... @command() ... def some_command(x): ... pass
-
piqueserver.commands.
target_player
(func: Callable)[source]¶ - This decorator converts first argument of a command to a
piqueserver.FeatureConnection
. - It’s intended for commands which accept single argument for target player eg. /fly [player]. It implicitly uses invoker as target if no arguments are provided. It uses first argument are player name or id for targetting. It forces non-player invokers to provide player argument.
>>> @command() ... @target_player ... def fly(connection, target): ... target.fly = True ... pass
- This decorator converts first argument of a command to a
piqueserver.config module¶
-
class
piqueserver.config.
ConfigStore
[source]¶ Bases:
object
Configuration store that manages global configuration.
Usage example:
>>> config = ConfigStore() >>> config.load_from_dict({'key1': 'value1'})
>>> option1 = config.option('key1', default='nothing', ... validate=lambda x: len(x) > 0) >>> section1 = config.section('section1') >>> nested_option = section1.option('key1', default=0)
>>> print(nested_option.get()) >>> option1.set('hello')
>>> # underlying dictionary structure will look like >>> # { >>> # 'key1': 'hello', >>> # 'section1': { >>> # 'key1': 0 >>> # } >>> # }
-
check_unused
()[source]¶ Return the subset of the underlying dictionary that doesn’t have any corresponding registered options.
-
dump_to_file
(fobj, format_='TOML')[source]¶ Writes the current configuration to a file-like objection, with the format specified by
format_
.
-
load_from_file
(fobj, format_='TOML')[source]¶ Clear the current configuration and load new configuration from a file-like object in a supported format.
-
piqueserver.console module¶
-
class
piqueserver.console.
ConsoleInput
(protocol)[source]¶ Bases:
twisted.protocols.basic.LineReceiver
-
admin
= True¶
-
delimiter
= b'\n'¶
-
lineReceived
(line)[source]¶ Override this for when each line is received.
@param line: The line which was received with the delimiter removed. @type line: C{bytes}
-
name
= 'Console'¶
-
piqueserver.irc module¶
-
class
piqueserver.irc.
IRCBot
[source]¶ Bases:
twisted.words.protocols.irc.IRCClient
-
admin
¶
-
colors
¶
-
joined
(irc_channel)[source]¶ Called when I finish joining a channel.
channel has the starting character (C{‘#’}, C{’&’}, C{‘!’}, or C{‘+’}) intact.
-
left
(irc_channel)[source]¶ Called when I have left a channel.
channel has the starting character (C{‘#’}, C{’&’}, C{‘!’}, or C{‘+’}) intact.
-
name
= None¶
-
nickname
¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
-
ops
= None¶
-
rights
¶
-
unaliased_name
= None¶
-
userKicked
(kickee, irc_channel, kicker, message)[source]¶ Called when I observe someone else being kicked from a channel.
-
user_types
¶
-
voices
= None¶
-
-
class
piqueserver.irc.
IRCClientFactory
(server, config)[source]¶ Bases:
twisted.internet.protocol.ClientFactory
-
admin
= None¶
-
aliases
= None¶
-
bot
= None¶
-
buildProtocol
(address)[source]¶ Create an instance of a subclass of Protocol.
The returned instance will handle input on an incoming server connection, and an attribute “factory” pointing to the creating factory.
Alternatively, L{None} may be returned to immediately close the new connection.
Override this method to alter how Protocol instances get created.
@param addr: an object implementing L{IAddress}
-
clientConnectionFailed
(connector, reason)[source]¶ Called when a connection has failed to connect.
It may be useful to call connector.connect() - this will reconnect.
@type reason: L{twisted.python.failure.Failure}
-
clientConnectionLost
(connector, reason)[source]¶ Called when an established connection is lost.
It may be useful to call connector.connect() - this will reconnect.
@type reason: L{twisted.python.failure.Failure}
-
colors
= True¶
-
failed_reconnect_delay
= 60¶
-
lost_reconnect_delay
= 20¶
-
rights
= None¶
-
startedConnecting
(connector)[source]¶ Called when a connection has been started.
You can call connector.stopConnecting() to stop the connection attempt.
@param connector: a Connector object.
-
user_types
= None¶
-
piqueserver.map module¶
-
class
piqueserver.map.
Map
(rot_info: piqueserver.map.RotationInfo, load_dir: str)[source]¶ Bases:
object
-
piqueserver.map.
check_rotation
(maps: List[Union[str, RotationInfo]], load_dir: Optional[str] = None) → List[piqueserver.map.RotationInfo][source]¶ Checks if provided maps exist in maps dir. and returns an array of RotationInfo objects for those maps. Raises MapNotFound exception if maps are not found.
piqueserver.player module¶
-
class
piqueserver.player.
FeatureConnection
(*args, **kwargs)[source]¶ Bases:
pyspades.player.ServerConnection
-
on_animation_update
(jump: bool, crouch: bool, sneak: bool, sprint: bool) → Tuple[bool, bool, bool, bool][source]¶
-
on_chat
(value: str, global_message: bool) → Union[str, bool][source]¶ notifies when the server receives a chat message
return False to block sending the message
-
on_hit
(hit_amount: float, player: piqueserver.player.FeatureConnection, _type: int, grenade: pyspades.world.Grenade) → Optional[bool][source]¶
-
send_lines
(lines: List[str], key: str = 'unknown') → None[source]¶ Send a list of lines to the player.
‘key’ is a unique identifier for the lines being sent - for example, a message saying ‘3 medkits are ready!’ could use the key ‘medkits.ready’. The key is used to avoid sending two messages of the same variety at once, to protect the server against a vulnerability which exploits this function.
The key should always be specified when calling this function. The default value of ‘unknown’ exists simply for backwards compatibility.
-
piqueserver.run module¶
piqueserver.scheduler module¶
piqueserver.server module¶
pyspades - default/featured server
-
class
piqueserver.server.
FeatureProtocol
(interface: bytes, config_dict: Dict[str, Any])[source]¶ Bases:
pyspades.server.ServerProtocol
-
add_ban
(ip, reason, duration, name=None)[source]¶ Ban an ip with an optional reason and duration in seconds. If duration is None, ban is permanent.
-
advance_call
= None¶
-
advance_rotation
(message: Optional[str] = None) → twisted.internet.defer.Deferred[source]¶ Advances to the next map in the rotation. If message is provided it will send it to the chat, waits for 10 seconds and then advances.
Returns: Deferred that fires when the map has been loaded
-
balanced_teams
= None¶
-
ban_manager
= None¶
-
ban_publish
= None¶
-
bans
= None¶
-
broadcast_chat
(value, global_message=True, sender=None, team=None, irc=False)[source]¶ Send a chat message to many users
-
building
= True¶
-
connection_class
¶ alias of
piqueserver.player.FeatureConnection
-
default_fog
= (128, 232, 255)¶
-
everyone_is_admin
= False¶
-
game_mode
= None¶
-
global_chat
= True¶
-
god_blocks
= None¶
-
identifier
= None¶
-
interface
= None¶
-
ip
= None¶
-
irc_relay
= None¶
-
killing
= True¶
-
last_time
= None¶
-
make_map
(rot_info: piqueserver.map.RotationInfo) → twisted.internet.defer.Deferred[source]¶ Creates and returns a Map object from rotation info in a new thread
Returns: Deferred that resolves to a Map
object.
-
map_info
= None¶
-
master
= False¶
-
master_reconnect_call
= None¶
-
planned_map
= None¶
-
player_memory
= None¶
-
receive_callback
(address: enet.Address, data: bytes) → int[source]¶ This hook receives the raw UDP data before it is processed by enet
-
remote_console
= None¶
-
set_map_rotation
(maps: List[str]) → None[source]¶ Over-writes the current map rotation with provided one.
FeatureProtocol.advance_rotation
still needs to be called to actually change the map,
-
spawns
= None¶
-
team_class
¶ alias of
FeatureTeam
-
time_announce_schedule
= None¶
-
timestamps
= None¶
-
user_blocks
= None¶
-
-
class
piqueserver.server.
FeatureTeam
(team_id: int, name: str, color: Tuple[int, int, int], spectator: bool, protocol: pyspades.protocol.BaseProtocol)[source]¶ Bases:
pyspades.team.Team
-
locked
= False¶
-
piqueserver.ssh module¶
piqueserver.statistics module¶
-
class
piqueserver.statistics.
StatsClient
[source]¶ Bases:
piqueserver.statistics.StatsProtocol
-
connectionMade
()[source]¶ Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
-
login_defers
= None¶
-
server
= None¶
-
-
class
piqueserver.statistics.
StatsClientFactory
(name, password, callback)[source]¶ Bases:
twisted.internet.protocol.ReconnectingClientFactory
-
maxDelay
= 20¶
-
protocol
¶ alias of
StatsClient
-
-
class
piqueserver.statistics.
StatsFactory
(password)[source]¶ Bases:
twisted.internet.protocol.ServerFactory
-
protocol
¶ alias of
StatsServer
-
-
class
piqueserver.statistics.
StatsProtocol
[source]¶ Bases:
twisted.protocols.basic.Int16StringReceiver
-
class
piqueserver.statistics.
StatsServer
[source]¶ Bases:
piqueserver.statistics.StatsProtocol
-
connectionLost
(reason)[source]¶ Called when the connection is shut down.
Clear any circular references here, and any external references to this Protocol. The connection has been closed.
@type reason: L{twisted.python.failure.Failure}
-
connectionMade
()[source]¶ Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
-
piqueserver.statusserver module¶
-
class
piqueserver.statusserver.
AccessLogger
(logger: logging.Logger, log_format: str)[source]¶ Bases:
aiohttp.abc.AbstractAccessLogger