evennia.server.portal package¶
Submodules¶
evennia.server.portal.amp module¶
The AMP (Asynchronous Message Protocol)-communication commands and constants used by Evennia.
This module acts as a central place for AMP-servers and -clients to get commands to use.
-
class
evennia.server.portal.amp.AMPMultiConnectionProtocol(*args, **kwargs)[source]¶ Bases:
twisted.protocols.amp.AMPAMP protocol that safely handle multiple connections to the same server without dropping old ones - new clients will receive all server returns (broadcast). Will also correctly handle erroneous HTTP requests on the port and return a HTTP error response.
-
__init__(*args, **kwargs)[source]¶ Initialize protocol with some things that need to be in place already before connecting both on portal and server.
-
_commandDispatch= {b'FunctionCall': (<class 'evennia.server.portal.amp.FunctionCall'>, <function catch_traceback>), b'StartTLS': (<class 'twisted.protocols.amp.StartTLS'>, <function BinaryBoxProtocol._defaultStartTLSResponder>)}¶
-
broadcast(command, sessid, **kwargs)[source]¶ Send data across the wire to all connections.
- Parameters
command (AMP Command) – A protocol send command.
sessid (int) – A unique Session id.
- Returns
A deferred with an errback.
- Return type
deferred (deferred or None)
Notes
Data will be sent across the wire pickled as a tuple (sessid, kwargs).
-
connectionLost(reason)[source]¶ We swallow connection errors here. The reason is that during a normal reload/shutdown there will almost always be cases where either the portal or server shuts down before a message has returned its (empty) return, triggering a connectionLost error that is irrelevant. If a true connection error happens, the portal will continuously try to reconnect, showing the problem that way.
-
connectionMade()[source]¶ This is called when an AMP connection is (re-)established. AMP calls it on both sides.
-
data_in(packed_data)[source]¶ Process incoming packed data.
- Parameters
packed_data (bytes) – Pickled data.
- Returns
Unpickled package
- Return type
unpaced_data (any)
-
errback(e, info)[source]¶ Error callback. Handles errors to avoid dropping connections on server tracebacks.
- Parameters
e (Failure) – Deferred error instance.
info (str) – Error string.
-
makeConnection(transport)[source]¶ Swallow connection log message here. Copied from original in the amp protocol.
-
send_FunctionCall(modulepath, functionname, *args, **kwargs)[source]¶ Access method called by either process. This will call an arbitrary function on the other process (On Portal if calling from Server and vice versa).
- Inputs:
modulepath (str) - python path to module holding function to call functionname (str) - name of function in given module *args, **kwargs will be used as arguments/keyword args for the
remote function call
- Returns
A deferred that fires with the return value of the remote function call
-
-
class
evennia.server.portal.amp.AdminPortal2Server(**kw)[source]¶ Bases:
twisted.protocols.amp.CommandAdministration Portal -> Server
Sent when the portal needs to perform admin operations on the server, such as when a new session connects or resyncs
-
allErrors= {<class 'Exception'>: b'EXCEPTION'}¶
-
arguments= [(b'packed_data', <evennia.server.portal.amp.Compressed object>)]¶
-
commandName= b'AdminPortal2Server'¶
-
errors= {<class 'Exception'>: b'EXCEPTION'}¶
-
key= 'AdminPortal2Server'¶
-
response= []¶
-
reverseErrors= {b'EXCEPTION': <class 'Exception'>}¶
-
-
class
evennia.server.portal.amp.AdminServer2Portal(**kw)[source]¶ Bases:
twisted.protocols.amp.CommandAdministration Server -> Portal
Sent when the server needs to perform admin operations on the portal.
-
allErrors= {<class 'Exception'>: b'EXCEPTION'}¶
-
arguments= [(b'packed_data', <evennia.server.portal.amp.Compressed object>)]¶
-
commandName= b'AdminServer2Portal'¶
-
errors= {<class 'Exception'>: b'EXCEPTION'}¶
-
key= 'AdminServer2Portal'¶
-
response= []¶
-
reverseErrors= {b'EXCEPTION': <class 'Exception'>}¶
-
-
class
evennia.server.portal.amp.Compressed(optional=False)[source]¶ Bases:
twisted.protocols.amp.StringThis is a custom AMP command Argument that both handles too-long sends as well as uses zlib for compression across the wire. The batch-grouping of too-long sends is borrowed from the “mediumbox” recipy at twisted-hacks’s ~glyph/+junk/amphacks/mediumbox.
-
fromBox(name, strings, objects, proto)[source]¶ Converts from box string representation to python. We read back too-long batched data and put it back together here.
-
fromString(inString)[source]¶ Convert (decompress) from the string-representation on the wire to Python.
-
-
class
evennia.server.portal.amp.FunctionCall(**kw)[source]¶ Bases:
twisted.protocols.amp.CommandBidirectional Server <-> Portal
Sent when either process needs to call an arbitrary function in the other. This does not use the batch-send functionality.
-
allErrors= {<class 'Exception'>: b'EXCEPTION'}¶
-
arguments= [(b'module', <twisted.protocols.amp.String object>), (b'function', <twisted.protocols.amp.String object>), (b'args', <twisted.protocols.amp.String object>), (b'kwargs', <twisted.protocols.amp.String object>)]¶
-
commandName= b'FunctionCall'¶
-
errors= {<class 'Exception'>: b'EXCEPTION'}¶
-
key= 'FunctionCall'¶
-
response= [(b'result', <twisted.protocols.amp.String object>)]¶
-
reverseErrors= {b'EXCEPTION': <class 'Exception'>}¶
-
-
class
evennia.server.portal.amp.MsgLauncher2Portal(**kw)[source]¶ Bases:
twisted.protocols.amp.CommandMessage Launcher -> Portal
-
allErrors= {<class 'Exception'>: b'EXCEPTION'}¶
-
arguments= [(b'operation', <twisted.protocols.amp.String object>), (b'arguments', <twisted.protocols.amp.String object>)]¶
-
commandName= b'MsgLauncher2Portal'¶
-
errors= {<class 'Exception'>: b'EXCEPTION'}¶
-
key= 'MsgLauncher2Portal'¶
-
response= []¶
-
reverseErrors= {b'EXCEPTION': <class 'Exception'>}¶
-
-
class
evennia.server.portal.amp.MsgPortal2Server(**kw)[source]¶ Bases:
twisted.protocols.amp.CommandMessage Portal -> Server
-
allErrors= {<class 'Exception'>: b'EXCEPTION'}¶
-
arguments= [(b'packed_data', <evennia.server.portal.amp.Compressed object>)]¶
-
commandName= b'MsgPortal2Server'¶
-
errors= {<class 'Exception'>: b'EXCEPTION'}¶
-
key= b'MsgPortal2Server'¶
-
response= []¶
-
reverseErrors= {b'EXCEPTION': <class 'Exception'>}¶
-
-
class
evennia.server.portal.amp.MsgServer2Portal(**kw)[source]¶ Bases:
twisted.protocols.amp.CommandMessage Server -> Portal
-
allErrors= {<class 'Exception'>: b'EXCEPTION'}¶
-
arguments= [(b'packed_data', <evennia.server.portal.amp.Compressed object>)]¶
-
commandName= b'MsgServer2Portal'¶
-
errors= {<class 'Exception'>: b'EXCEPTION'}¶
-
key= 'MsgServer2Portal'¶
-
response= []¶
-
reverseErrors= {b'EXCEPTION': <class 'Exception'>}¶
-
-
class
evennia.server.portal.amp.MsgStatus(**kw)[source]¶ Bases:
twisted.protocols.amp.CommandCheck Status between AMP services
-
allErrors= {<class 'Exception'>: b'EXCEPTION'}¶
-
arguments= [(b'status', <twisted.protocols.amp.String object>)]¶
-
commandName= b'MsgStatus'¶
-
errors= {<class 'Exception'>: b'EXCEPTION'}¶
-
key= 'MsgStatus'¶
-
response= [(b'status', <twisted.protocols.amp.String object>)]¶
-
reverseErrors= {b'EXCEPTION': <class 'Exception'>}¶
-
evennia.server.portal.amp_server module¶
The Evennia Portal service acts as an AMP-server, handling AMP communication to the AMP clients connecting to it (by default these are the Evennia Server and the evennia launcher).
-
class
evennia.server.portal.amp_server.AMPServerFactory(portal)[source]¶ Bases:
twisted.internet.protocol.ServerFactoryThis factory creates AMP Server connection. This acts as the ‘Portal’-side communication to the ‘Server’ process.
-
__init__(portal)[source]¶ Initialize the factory. This is called as the Portal service starts.
- Parameters
portal (Portal) – The Evennia Portal service instance.
protocol (Protocol) – The protocol the factory creates instances of.
-
buildProtocol(addr)[source]¶ Start a new connection, and store it on the service object.
- Parameters
addr (str) – Connection address. Not used.
- Returns
The created protocol.
- Return type
protocol (Protocol)
-
noisy= False¶
-
-
class
evennia.server.portal.amp_server.AMPServerProtocol(*args, **kwargs)[source]¶ Bases:
evennia.server.portal.amp.AMPMultiConnectionProtocolProtocol subclass for the AMP-server run by the Portal.
-
_commandDispatch= {b'AdminServer2Portal': (<class 'evennia.server.portal.amp.AdminServer2Portal'>, <function catch_traceback>), b'FunctionCall': (<class 'evennia.server.portal.amp.FunctionCall'>, <function catch_traceback>), b'MsgLauncher2Portal': (<class 'evennia.server.portal.amp.MsgLauncher2Portal'>, <function catch_traceback>), b'MsgServer2Portal': (<class 'evennia.server.portal.amp.MsgServer2Portal'>, <function catch_traceback>), b'MsgStatus': (<class 'evennia.server.portal.amp.MsgStatus'>, <function catch_traceback>), b'StartTLS': (<class 'twisted.protocols.amp.StartTLS'>, <function BinaryBoxProtocol._defaultStartTLSResponder>)}¶
-
connectionLost(reason)[source]¶ Set up a simple callback mechanism to let the amp-server wait for a connection to close.
-
data_to_server(command, sessid, **kwargs)[source]¶ Send data across the wire to the Server.
- Parameters
command (AMP Command) – A protocol send command.
sessid (int) – A unique Session id.
kwargs (any) – Data to send. This will be pickled.
- Returns
A deferred with an errback.
- Return type
deferred (deferred or None)
Notes
Data will be sent across the wire pickled as a tuple (sessid, kwargs).
-
get_status()[source]¶ Return status for the Evennia infrastructure.
- Returns
- The portal/server status and pids
(portal_live, server_live, portal_PID, server_PID).
- Return type
status (tuple)
-
portal_receive_adminserver2portal()¶ Helper decorator
-
portal_receive_launcher2portal()¶ Helper decorator
-
portal_receive_server2portal()¶ Helper decorator
-
portal_receive_status()¶ Helper decorator
-
send_AdminPortal2Server(session, operation='', **kwargs)[source]¶ Send Admin instructions from the Portal to the Server. Executed on the Portal.
- Parameters
session (Session) – Session.
operation (char, optional) – Identifier for the server operation, as defined by the global variables in evennia/server/amp.py.
data (str or dict, optional) – Data used in the administrative operation.
-
send_MsgPortal2Server(session, **kwargs)[source]¶ Access method called by the Portal and executed on the Portal.
- Parameters
session (session) – Session
kwargs (any, optional) – Optional data.
- Returns
Asynchronous return.
- Return type
deferred (Deferred)
-
start_server(server_twistd_cmd)[source]¶ (Re-)Launch the Evennia server.
- Parameters
server_twisted_cmd (list) – The server start instruction to pass to POpen to start the server.
-
stop_server(mode='shutdown')[source]¶ Shut down server in one or more modes.
- Parameters
mode (str) – One of ‘shutdown’, ‘reload’ or ‘reset’.
-
evennia.server.portal.grapevine module¶
Grapevine network connection
This is an implementation of the Grapevine Websocket protocol v 1.0.0 as outlined here: https://grapevine.haus/docs
This will allow the linked game to transfer status as well as connects the grapevine client to in-game channels.
-
class
evennia.server.portal.grapevine.GrapevineClient[source]¶ Bases:
autobahn.twisted.websocket.WebSocketClientProtocol,evennia.server.session.SessionImplements the grapevine client
-
data_in(data, **kwargs)[source]¶ Send data grapevine -> Evennia
- Kwargs:
data (dict): Converted json data.
-
disconnect(reason=None)[source]¶ Generic hook for the engine to call in order to disconnect this protocol.
- Parameters
reason (str or None) – Motivation for the disconnection.
-
onClose(wasClean, code=None, reason=None)[source]¶ This is executed when the connection is lost for whatever reason. it can also be called directly, from the disconnect method.
- Parameters
wasClean (bool) –
Trueif the WebSocket was closed cleanly.code (int or None) – Close status as sent by the WebSocket peer.
reason (str or None) – Close reason as sent by the WebSocket peer.
-
onMessage(payload, isBinary)[source]¶ Callback fired when a complete WebSocket message was received.
- Parameters
payload (bytes) – The WebSocket message received.
isBinary (bool) – Flag indicating whether payload is binary or UTF-8 encoded text.
-
send_authenticate(*args, **kwargs)[source]¶ Send grapevine authentication. This should be send immediately upon connection.
-
send_channel(text, channel, sender, *args, **kwargs)[source]¶ Send text type Evennia -> grapevine
This is the channels/send message type
Use with session.msg(channel=(message, channel, sender))
-
-
class
evennia.server.portal.grapevine.RestartingWebsocketServerFactory(sessionhandler, *args, **kwargs)[source]¶ Bases:
autobahn.twisted.websocket.WebSocketClientFactory,twisted.internet.protocol.ReconnectingClientFactoryA variant of the websocket-factory that auto-reconnects.
-
__init__(sessionhandler, *args, **kwargs)[source]¶ In addition to all arguments to the constructor of
autobahn.websocket.interfaces.IWebSocketClientChannelFactory(), you can supply areactorkeyword argument to specify the Twisted reactor to be used.
-
buildProtocol(addr)[source]¶ Build new instance of protocol
- Parameters
addr (str) – Not used, using factory/settings data
-
clientConnectionFailed(connector, reason)[source]¶ Called when Client failed to connect.
- Parameters
connector (Connection) – Represents the connection.
reason (str) – The reason for the failure.
-
clientConnectionLost(connector, reason)[source]¶ Called when Client loses connection.
- Parameters
connector (Connection) – Represents the connection.
reason (str) – The reason for the failure.
-
factor= 1.5¶
-
initialDelay= 1¶
-
maxDelay= 60¶
-
evennia.server.portal.irc module¶
This connects to an IRC network/channel and launches an ‘bot’ onto it. The bot then pipes what is being said between the IRC channel and one or more Evennia channels.
-
class
evennia.server.portal.irc.IRCBot[source]¶ Bases:
twisted.words.protocols.irc.IRCClient,evennia.server.session.SessionAn IRC bot that tracks activity in a channel as well as sends text to it when prompted
-
action(user, channel, msg)[source]¶ Called when an action is detected in channel.
- Parameters
user (str) – User name sending the message.
channel (str) – Channel name seeing the message.
msg (str) – The message arriving from channel.
-
channel= None¶
-
data_in(text=None, **kwargs)[source]¶ Data IRC -> Server.
- Kwargs:
text (str): Ingoing text. kwargs (any): Other data from protocol.
-
disconnect(reason='')[source]¶ Called by sessionhandler to disconnect this protocol.
- Parameters
reason (str) – Motivation for the disconnect.
-
factory= None¶
-
get_nicklist()[source]¶ Retrieve name list from the channel. The return is handled by the catch methods below.
-
lineRate= 1¶
-
logger= None¶
-
nickname= None¶
-
pong(user, time)[source]¶ Called with the return timing from a PING.
- Parameters
user (str) – Name of user
time (float) – Ping time in secs.
-
privmsg(user, channel, msg)[source]¶ Called when the connected channel receives a message.
- Parameters
user (str) – User name sending the message.
channel (str) – Channel name seeing the message.
msg (str) – The message arriving from channel.
-
send_channel(*args, **kwargs)[source]¶ Send channel text to IRC channel (visible to all). Note that we don’t handle the “text” send (it’s rerouted to send_default which does nothing) - this is because the IRC bot is a normal session and would otherwise report anything that happens to it to the IRC channel (such as it seeing server reload messages).
- Parameters
text (str) – Outgoing text
-
send_ping(*args, **kwargs)[source]¶ Send a ping. The return (handled by self.pong) will be sent back as a message of type ‘ping’.
-
send_privmsg(*args, **kwargs)[source]¶ Send message only to specific user.
- Parameters
text (str) – Outgoing text.
- Kwargs:
- user (str): the nick to send
privately to.
-
send_reconnect(*args, **kwargs)[source]¶ The server instructs us to rebuild the connection by force, probably because the client silently lost connection.
-
send_request_nicklist(*args, **kwargs)[source]¶ Send a request for the channel nicklist. The return (handled by self.irc_RPL_ENDOFNAMES) will be sent back as a message with type `nicklist’.
-
signedOn()[source]¶ This is called when we successfully connect to the network. We make sure to now register with the game as a full session.
-
sourceURL= 'http://code.evennia.com'¶
-
-
class
evennia.server.portal.irc.IRCBotFactory(sessionhandler, uid=None, botname=None, channel=None, network=None, port=None, ssl=None)[source]¶ Bases:
twisted.internet.protocol.ReconnectingClientFactoryCreates instances of IRCBot, connecting with a staggered increase in delay
-
__init__(sessionhandler, uid=None, botname=None, channel=None, network=None, port=None, ssl=None)[source]¶ Storing some important protocol properties.
- Parameters
sessionhandler (SessionHandler) – Reference to the main Sessionhandler.
- Kwargs:
uid (int): Bot user id. botname (str): Bot name (seen in IRC channel). channel (str): IRC channel to connect to. network (str): Network address to connect to. port (str): Port of the network. ssl (bool): Indicates SSL connection.
-
buildProtocol(addr)[source]¶ Build the protocol and assign it some properties.
- Parameters
addr (str) – Not used; using factory data.
-
clientConnectionFailed(connector, reason)[source]¶ Called when Client failed to connect.
- Parameters
connector (Connection) – Represents the connection.
reason (str) – The reason for the failure.
-
clientConnectionLost(connector, reason)[source]¶ Called when Client loses connection.
- Parameters
connector (Connection) – Represents the connection.
reason (str) – The reason for the failure.
-
factor= 1.5¶
-
initialDelay= 1¶
-
maxDelay= 60¶
-
evennia.server.portal.mccp module¶
MCCP - Mud Client Compression Protocol
This implements the MCCP v2 telnet protocol as per http://tintin.sourceforge.net/mccp/. MCCP allows for the server to compress data when sending to supporting clients, reducing bandwidth by 70-90%.. The compression is done using Python’s builtin zlib library. If the client doesn’t support MCCP, server sends uncompressed as normal. Note: On modern hardware you are not likely to notice the effect of MCCP unless you have extremely heavy traffic or sits on a terribly slow connection.
This protocol is implemented by the telnet protocol importing mccp_compress and calling it from its write methods.
-
class
evennia.server.portal.mccp.Mccp(protocol)[source]¶ Bases:
objectImplements the MCCP protocol. Add this to a variable on the telnet protocol to set it up.
-
__init__(protocol)[source]¶ initialize MCCP by storing protocol on ourselves and calling the client to see if it supports MCCP. Sets callbacks to start zlib compression in that case.
- Parameters
protocol (Protocol) – The active protocol instance.
-
evennia.server.portal.mssp module¶
MSSP - Mud Server Status Protocol
This implements the MSSP telnet protocol as per http://tintin.sourceforge.net/mssp/. MSSP allows web portals and listings to have their crawlers find the mud and automatically extract relevant information about it, such as genre, how many active players and so on.
-
class
evennia.server.portal.mssp.Mssp(protocol)[source]¶ Bases:
objectImplements the MSSP protocol. Add this to a variable on the telnet protocol to set it up.
-
__init__(protocol)[source]¶ initialize MSSP by storing protocol on ourselves and calling the client to see if it supports MSSP.
- Parameters
protocol (Protocol) – The active protocol instance.
-
get_player_count()[source]¶ Get number of logged-in players.
- Returns
The number of players in the MUD.
- Return type
count (int)
-
evennia.server.portal.mxp module¶
MXP - Mud eXtension Protocol.
Partial implementation of the MXP protocol. The MXP protocol allows more advanced formatting options for telnet clients that supports it (mudlet, zmud, mushclient are a few)
This only implements the SEND tag.
More information can be found on the following links: http://www.zuggsoft.com/zmud/mxp.htm http://www.mushclient.com/mushclient/mxp.htm http://www.gammon.com.au/mushclient/addingservermxp.htm
-
class
evennia.server.portal.mxp.Mxp(protocol)[source]¶ Bases:
objectImplements the MXP protocol.
-
__init__(protocol)[source]¶ Initializes the protocol by checking if the client supports it.
- Parameters
protocol (Protocol) – The active protocol instance.
-
evennia.server.portal.naws module¶
NAWS - Negotiate About Window Size
This implements the NAWS telnet option as per https://www.ietf.org/rfc/rfc1073.txt
NAWS allows telnet clients to report their current window size to the client and update it when the size changes
-
class
evennia.server.portal.naws.Naws(protocol)[source]¶ Bases:
objectImplements the NAWS protocol. Add this to a variable on the telnet protocol to set it up.
-
__init__(protocol)[source]¶ initialize NAWS by storing protocol on ourselves and calling the client to see if it supports NAWS.
- Parameters
protocol (Protocol) – The active protocol instance.
-
do_naws(option)[source]¶ Client wants to negotiate all the NAWS information.
- Parameters
option (Option) – Not used.
-
evennia.server.portal.portal module¶
This module implements the main Evennia server process, the core of the game engine.
This module should be started with the ‘twistd’ executable since it sets up all the networking features. (this is done automatically by game/evennia.py).
-
class
evennia.server.portal.portal.Portal(application)[source]¶ Bases:
objectThe main Portal server handler. This object sets up the database and tracks and interlinks all the twisted network services that make up Portal.
-
__init__(application)[source]¶ Setup the server.
- Parameters
application (Application) – An instantiated Twisted application
-
_get_backup_server_twistd_cmd()[source]¶ For interactive Portal mode there is no way to get the server cmdline from the launcher, so we need to guess it here (it’s very likely to not change)
- Returns
An instruction for starting the server, to pass to Popen.
- Return type
server_twistd_cmd (list)
-
shutdown(_reactor_stopping=False, _stop_server=False)[source]¶ Shuts down the server from inside it.
- Parameters
_reactor_stopping (bool, optional) – This is set if server is already in the process of shutting down; in this case we don’t need to stop it again.
_stop_server (bool, optional) – Only used in portal-interactive mode; makes sure to stop the Server cleanly.
Note that restarting (regardless of the setting) will not work if the Portal is currently running in daemon mode. In that case it always needs to be restarted manually.
-
evennia.server.portal.portalsessionhandler module¶
Sessionhandler for portal sessions
-
class
evennia.server.portal.portalsessionhandler.PortalSessionHandler(*args, **kwargs)[source]¶ Bases:
evennia.server.sessionhandler.SessionHandlerThis object holds the sessions connected to the portal at any time. It is synced with the server’s equivalent SessionHandler over the AMP connection.
Sessions register with the handler using the connect() method. This will assign a new unique sessionid to the session and send that sessid to the server using the AMP connection.
-
announce_all(message)[source]¶ Send message to all connected sessions.
- Parameters
message (str) – Message to relay.
Notes
This will create an on-the fly text-type send command.
-
at_server_connection()[source]¶ Called when the Portal establishes connection with the Server. At this point, the AMP connection is already established.
-
connect(session)[source]¶ Called by protocol at first connect. This adds a not-yet authenticated session using an ever-increasing counter for sessid.
- Parameters
session (PortalSession) – The Session connecting.
Notes
We implement a throttling mechanism here to limit the speed at which new connections are accepted - this is both a stop against DoS attacks as well as helps using the Dummyrunner tester with a large number of connector dummies.
-
count_loggedin(include_unloggedin=False)[source]¶ Count loggedin connections, alternatively count all connections.
- Parameters
include_unloggedin (bool) – Also count sessions that have
yet authenticated. (not) –
- Returns
Number of sessions.
- Return type
count (int)
-
data_in(session, **kwargs)[source]¶ Called by portal sessions for relaying data coming in from the protocol to the server.
- Parameters
session (PortalSession) – Session receiving data.
- Kwargs:
kwargs (any): Other data from protocol.
Notes
Data is serialized before passed on.
-
data_out(session, **kwargs)[source]¶ Called by server for having the portal relay messages and data to the correct session protocol.
- Parameters
session (Session) – Session sending data.
- Kwargs:
kwargs (any): Each key is a command instruction to the protocol on the form key = [[args],{kwargs}]. This will call a method send_<key> on the protocol. If no such method exixts, it sends the data to a method send_default.
-
disconnect(session)[source]¶ Called from portal when the connection is closed from the portal side.
- Parameters
session (PortalSession) – Session to disconnect.
delete (bool, optional) – Delete the session from the handler. Only time to not do this is when this is called from a loop, such as from self.disconnect_all().
-
generate_sessid()[source]¶ Simply generates a sessid that’s guaranteed to be unique for this Portal run.
- Returns
sessid
-
server_connect(protocol_path='', config={})[source]¶ Called by server to force the initialization of a new protocol instance. Server wants this instance to get a unique sessid and to be connected back as normal. This is used to initiate irc/rss etc connections.
- Parameters
protocol_path (st) – Full python path to the class factory for the protocol used, eg ‘evennia.server.portal.irc.IRCClientFactory’
config (dict) – Dictionary of configuration options, fed as **kwarg to protocol class’ __init__ method.
- Raises
RuntimeError – If The correct factory class is not found.
Notes
The called protocol class must have a method start() that calls the portalsession.connect() as a normal protocol.
-
server_disconnect(session, reason='')[source]¶ Called by server to force a disconnect by sessid.
- Parameters
session (portalsession) – Session to disconnect.
reason (str, optional) – Motivation for disconnect.
-
server_disconnect_all(reason='')[source]¶ Called by server when forcing a clean disconnect for everyone.
- Parameters
reason (str, optional) – Motivation for disconnect.
-
server_logged_in(session, data)[source]¶ The server tells us that the session has been authenticated. Update it. Called by the Server.
- Parameters
session (Session) – Session logging in.
data (dict) – The session sync data.
-
server_session_sync(serversessions, clean=True)[source]¶ Server wants to save data to the portal, maybe because it’s about to shut down. We don’t overwrite any sessions here, just update them in-place.
- Parameters
serversessions (dict) –
This is a dictionary
{sessid:{property:value},…} describing the properties to sync on all sessions.
clean (bool) – If True, remove any Portal sessions that are not included in serversessions.
-
-
evennia.server.portal.portalsessionhandler._PORTAL_SESSION_HANDLER_CLASS¶ alias of
evennia.server.portal.portalsessionhandler.PortalSessionHandler
evennia.server.portal.rss module¶
RSS parser for Evennia
This connects an RSS feed to an in-game Evennia channel, sending messages to the channel whenever the feed updates.
-
class
evennia.server.portal.rss.RSSBotFactory(sessionhandler, uid=None, url=None, rate=None)[source]¶ Bases:
objectInitializes new bots.
-
__init__(sessionhandler, uid=None, url=None, rate=None)[source]¶ Initialize the bot.
- Parameters
sessionhandler (PortalSessionHandler) – The main sessionhandler object.
uid (int) – User id for the bot.
url (str) – The RSS URL.
rate (int) – How often for the RSS to request the latest RSS entries.
-
-
class
evennia.server.portal.rss.RSSReader(factory, url, rate)[source]¶ Bases:
evennia.server.session.SessionA simple RSS reader using the feedparser module.
-
__init__(factory, url, rate)[source]¶ Initialize the reader.
- Parameters
factory (RSSFactory) – The protocol factory.
url (str) – The RSS url.
rate (int) – The seconds between RSS lookups.
-
_callback(new_entries, init)[source]¶ Called when RSS returns.
- Parameters
new_entries (list) – List of new RSS entries since last.
init (bool) – If this is a startup operation (at which point all entries are considered new).
-
data_in(text=None, **kwargs)[source]¶ Data RSS -> Evennia.
- Kwargs:
text (str): Incoming text kwargs (any): Options from protocol.
-
evennia.server.portal.ssh module¶
This module implements the ssh (Secure SHell) protocol for encrypted connections.
This depends on a generic session module that implements the actual login procedure of the game, tracks sessions etc.
Using standard ssh client,
-
class
evennia.server.portal.ssh.AccountDBPasswordChecker(factory)[source]¶ Bases:
objectChecks the django db for the correct credentials for username/password otherwise it returns the account or None which is useful for the Realm.
-
__init__(factory)[source]¶ Initialize the factory.
- Parameters
factory (SSHFactory) – Checker factory.
-
credentialInterfaces= (<InterfaceClass twisted.cred.credentials.IUsernamePassword>,)¶
-
noisy= False¶
-
-
class
evennia.server.portal.ssh.ExtraInfoAuthServer[source]¶ Bases:
twisted.conch.ssh.userauth.SSHUserAuthServer-
auth_password(packet)[source]¶ Password authentication.
Used mostly for setting up the transport so we can query username and password later.
- Parameters
packet (Packet) – Auth packet.
-
noisy= False¶
-
-
class
evennia.server.portal.ssh.PassAvatarIdTerminalRealm(transportFactory=None)[source]¶ Bases:
twisted.conch.manhole_ssh.TerminalRealmReturns an avatar that passes the avatarId through to the protocol. This is probably not the best way to do it.
-
noisy= False¶
-
-
class
evennia.server.portal.ssh.SSHServerFactory[source]¶ Bases:
twisted.internet.protocol.ServerFactoryThis is only to name this better in logs
-
noisy= False¶
-
-
class
evennia.server.portal.ssh.SshProtocol(starttuple)[source]¶ Bases:
twisted.conch.manhole.Manhole,evennia.server.session.SessionEach account connecting over ssh gets this protocol assigned to them. All communication between game and account goes through here.
-
__init__(starttuple)[source]¶ For setting up the account. If account is not None then we’ll login automatically.
- Parameters
starttuple (tuple) – A (account, factory) tuple.
-
connectionLost(reason=None)[source]¶ This is executed when the connection is lost for whatever reason. It can also be called directly, from the disconnect method.
- Parameters
reason (str) – Motivation for loosing connection.
-
disconnect(reason='Connection closed. Goodbye for now.')[source]¶ Disconnect from server.
- Parameters
reason (str) – Motivation for disconnect.
-
getClientAddress()[source]¶ Get client address.
- Returns
- The client’s address and port in
a tuple. For example (‘127.0.0.1’, 41917).
- Return type
address_and_port (tuple)
-
handle_INT()[source]¶ Handle ^C as an interrupt keystroke by resetting the current input variables to their initial state.
-
lineReceived(string)[source]¶ Communication User -> Evennia. Any line return indicates a command for the purpose of the MUD. So we take the user input and pass it on to the game engine.
- Parameters
string (str) – Input text.
-
noisy= False¶
-
sendLine(string)[source]¶ Communication Evennia -> User. Any string sent should already have been properly formatted and processed before reaching this point.
- Parameters
string (str) – Output text.
-
send_text(*args, **kwargs)[source]¶ Send text data. This is an in-band telnet operation.
- Parameters
text (str) – The first argument is always the text string to send. No other arguments are considered.
- Kwargs:
- options (dict): Send-option flags
mxp: Enforce MXP link support.
ansi: Enforce no ANSI colors.
xterm256: Enforce xterm256 colors, regardless of TTYPE setting.
nocolor: Strip all colors.
- raw: Pass string through without any ansi processing
(i.e. include Evennia ansi markers but do not convert them into ansi tokens)
- echo: Turn on/off line echo on the client. Turn
off line echo for client, for example for password. Note that it must be actively turned back on again!
-
-
class
evennia.server.portal.ssh.TerminalSessionTransport_getPeer(proto, chainedProtocol, avatar, width, height)[source]¶ Bases:
objectTaken from twisted’s TerminalSessionTransport which doesn’t provide getPeer to the transport. This one does.
-
__init__(proto, chainedProtocol, avatar, width, height)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
noisy= False¶
-
evennia.server.portal.ssl module¶
This is a simple context factory for auto-creating SSL keys and certificates.
-
class
evennia.server.portal.ssl.SSLProtocol(*args, **kwargs)[source]¶ Bases:
evennia.server.portal.telnet.TelnetProtocolCommunication is the same as telnet, except data transfer is done with encryption.
evennia.server.portal.suppress_ga module¶
SUPPRESS-GO-AHEAD
This supports suppressing or activating Evennia the GO-AHEAD telnet operation after every server reply. If the client sends no explicit DONT SUPRESS GO-AHEAD, Evennia will default to supressing it since many clients will fail to use it and has no knowledge of this standard.
It is set as the NOGOAHEAD protocol_flag option.
http://www.faqs.org/rfcs/rfc858.html
-
class
evennia.server.portal.suppress_ga.SuppressGA(protocol)[source]¶ Bases:
objectImplements the SUPRESS-GO-AHEAD protocol. Add this to a variable on the telnet protocol to set it up.
evennia.server.portal.telnet module¶
This module implements the telnet protocol.
This depends on a generic session module that implements the actual login procedure of the game, tracks sessions etc.
-
class
evennia.server.portal.telnet.TelnetProtocol(*args, **kwargs)[source]¶ Bases:
twisted.conch.telnet.Telnet,twisted.conch.telnet.StatefulTelnetProtocol,evennia.server.session.SessionEach player connecting over telnet (ie using most traditional mud clients) gets a telnet protocol instance assigned to them. All communication between game and player goes through here.
-
_wont_linemode(*args)[source]¶ Client refuses do(linemode). This is common for MUD-specific clients, but we must ask for the sake of raw telnet. We ignore this error.
-
applicationDataReceived(data)[source]¶ Telnet method called when non-telnet-command data is coming in over the telnet connection. We pass it on to the game engine directly.
- Parameters
data (str) – Incoming data.
-
connectionLost(reason)[source]¶ this is executed when the connection is lost for whatever reason. it can also be called directly, from the disconnect method
- Parameters
reason (str) – Motivation for losing connection.
-
dataReceived(data)[source]¶ Unused by default, but a good place to put debug printouts of incoming data.
-
disableLocal(option)[source]¶ Disable a given option locally.
- Parameters
option (char) – The telnet option to disable locally.
-
disableRemote(option)[source]¶ Signal a programming error by raising an exception.
L{enableRemote} must return true for the given value of C{option} in order for this method to be called. If a subclass of L{Telnet} overrides enableRemote to allow certain options to be enabled, it must also override disableRemote tto disable those options.
@raise NotImplementedError: Always raised.
-
disconnect(reason='')[source]¶ generic hook for the engine to call in order to disconnect this protocol.
- Parameters
reason (str, optional) – Reason for disconnecting.
-
enableLocal(option)[source]¶ Call to allow the activation of options for this protocol
- Parameters
option (char) – The telnet option to enable locally.
- Returns
If this option should be enabled.
- Return type
enable (bool)
-
enableRemote(option)[source]¶ This sets up the remote-activated options we allow for this protocol.
- Parameters
option (char) – The telnet option to enable.
- Returns
If this option should be enabled.
- Return type
enable (bool)
-
handshake_done(timeout=False)[source]¶ This is called by all telnet extensions once they are finished. When all have reported, a sync with the server is performed. The system will force-call this sync after a small time to handle clients that don’t reply to handshakes at all.
-
sendLine(line)[source]¶ Hook overloading the one used by linereceiver.
- Parameters
line (str) – Line to send.
-
send_prompt(*args, **kwargs)[source]¶ Send a prompt - a text without a line end. See send_text for argument options.
-
send_text(*args, **kwargs)[source]¶ Send text data. This is an in-band telnet operation.
- Parameters
text (str) – The first argument is always the text string to send. No other arguments are considered.
- Kwargs:
- options (dict): Send-option flags
mxp: Enforce MXP link support.
ansi: Enforce no ANSI colors.
xterm256: Enforce xterm256 colors, regardless of TTYPE.
noxterm256: Enforce no xterm256 color support, regardless of TTYPE.
nocolor: Strip all Color, regardless of ansi/xterm256 setting.
- raw: Pass string through without any ansi processing
(i.e. include Evennia ansi markers but do not convert them into ansi tokens)
- echo: Turn on/off line echo on the client. Turn
off line echo for client, for example for password. Note that it must be actively turned back on again!
-
evennia.server.portal.telnet_oob module¶
Telnet OOB (Out of band communication)
OOB protocols allow for asynchronous communication between Evennia and compliant telnet clients. The “text” type of send command will always be sent “in-band”, appearing in the client’s main text output. OOB commands, by contrast, can have many forms and it is up to the client how and if they are handled. Examples of OOB instructions could be to instruct the client to play sounds or to update a graphical health bar.
> Note that in Evennia’s Web client, all send commands are “OOB commands”, (including the “text” one), there is no equivalence to MSDP/GMCP for the webclient since it doesn’t need it.
This implements the following telnet OOB communication protocols: - MSDP (Mud Server Data Protocol), as per
- GMCP (Generic Mud Communication Protocol) as per
Following the lead of KaVir’s protocol snippet, we first check if client supports MSDP and if not, we fallback to GMCP with a MSDP header where applicable.
-
class
evennia.server.portal.telnet_oob.TelnetOOB(protocol)[source]¶ Bases:
objectImplements the MSDP and GMCP protocols.
-
__init__(protocol)[source]¶ Initiates by storing the protocol on itself and trying to determine if the client supports MSDP.
- Parameters
protocol (Protocol) – The active protocol.
-
data_out(cmdname, *args, **kwargs)[source]¶ Return a MSDP- or GMCP-valid subnegotiation across the protocol.
- Parameters
cmdname (str) – OOB-command name.
kwargs (args,) – Arguments to OOB command.
-
decode_gmcp(data)[source]¶ Decodes incoming GMCP data on the form ‘varname <structure>’.
- Parameters
data (str or list) – GMCP data.
Notes
Clients send data on the form “Module.Submodule.Cmdname <structure>”. We assume the structure is valid JSON.
The following is parsed into Evennia’s formal structure:
Core.Name -> [name, [], {}] Core.Name string -> [name, [string], {}] Core.Name [arg, arg,…] -> [name, [args], {}] Core.Name {key:arg, key:arg, …} -> [name, [], {kwargs}] Core.Name [[args], {kwargs}] -> [name, [args], {kwargs}]
-
decode_msdp(data)[source]¶ Decodes incoming MSDP data.
- Parameters
data (str or list) – MSDP data.
Notes
Clients should always send MSDP data on one of the following forms:
cmdname ‘’ -> [cmdname, [], {}] cmdname val -> [cmdname, [val], {}] cmdname array -> [cmdname, [array], {}] cmdname table -> [cmdname, [], {table}] cmdname array cmdname table -> [cmdname, [array], {table}]
Observe that all MSDP_VARS are used to identify cmdnames, so if there are multiple arrays with the same cmdname given, they will be merged into one argument array, same for tables. Different MSDP_VARS (outside tables) will be identified as separate cmdnames.
-
do_gmcp(option)[source]¶ Called when client confirms that it can do MSDP or GMCP.
- Parameters
option (Option) – Not used.
-
do_msdp(option)[source]¶ Client reports that it supports msdp.
- Parameters
option (Option) – Not used.
-
encode_gmcp(cmdname, *args, **kwargs)[source]¶ Encode into GMCP messages.
- Parameters
cmdname (str) – GMCP OOB command name.
kwargs (args,) – Arguments to OOB command.
Notes
GMCP messages will be outgoing on the following form (the non-JSON cmdname at the start is what IRE games use, supposedly, and what clients appear to have adopted). A cmdname without Package will end up in the Core package, while Core package names will be stripped on the Evennia side.
[cmd.name, [], {}] -> Cmd.Name [cmd.name, [arg], {}] -> Cmd.Name arg [cmd.name, [args],{}] -> Cmd.Name [args] [cmd.name, [], {kwargs}] -> Cmd.Name {kwargs} [cmdname, [args, {kwargs}] -> Core.Cmdname [[args],{kwargs}]
Notes
There are also a few default mappings between evennia outputcmds and GMCP:
client_options -> Core.Supports.Get get_inputfuncs -> Core.Commands.Get get_value -> Char.Value.Get repeat -> Char.Repeat.Update monitor -> Char.Monitor.Update
-
encode_msdp(cmdname, *args, **kwargs)[source]¶ Encode into a valid MSDP command.
- Parameters
cmdname (str) – Name of send instruction.
kwargs (args,) – Arguments to OOB command.
Notes
The output of this encoding will be MSDP structures on these forms:
[cmdname, [], {}] -> VAR cmdname VAL “” [cmdname, [arg], {}] -> VAR cmdname VAL arg [cmdname, [args],{}] -> VAR cmdname VAL ARRAYOPEN VAL arg VAL arg … ARRAYCLOSE [cmdname, [], {kwargs}] -> VAR cmdname VAL TABLEOPEN VAR key VAL val … TABLECLOSE [cmdname, [args], {kwargs}] -> VAR cmdname VAL ARRAYOPEN VAL arg VAL arg … ARRAYCLOSE
VAR cmdname VAL TABLEOPEN VAR key VAL val … TABLECLOSE
Further nesting is not supported, so if an array argument consists of an array (for example), that array will be json-converted to a string.
-
evennia.server.portal.telnet_ssl module¶
This allows for running the telnet communication over an encrypted SSL tunnel. To use it, requires a client supporting Telnet SSL.
The protocol will try to automatically create the private key and certificate on the server side when starting and will warn if this was not possible. These will appear as files ssl.key and ssl.cert in mygame/server/.
-
class
evennia.server.portal.telnet_ssl.SSLProtocol(*args, **kwargs)[source]¶ Bases:
evennia.server.portal.telnet.TelnetProtocolCommunication is the same as telnet, except data transfer is done with encryption set up by the portal at start time.
evennia.server.portal.tests module¶
-
class
evennia.server.portal.tests.TestAMPServer(methodName='runTest')[source]¶ Bases:
twisted.trial._asynctest.TestCaseTest AMP communication
-
class
evennia.server.portal.tests.TestIRC(methodName='runTest')[source]¶ Bases:
django.test.testcases.TestCase
-
class
evennia.server.portal.tests.TestTelnet(methodName='runTest')[source]¶ Bases:
twisted.trial._asynctest.TestCase
evennia.server.portal.ttype module¶
TTYPE (MTTS) - Mud Terminal Type Standard
This module implements the TTYPE telnet protocol as per http://tintin.sourceforge.net/mtts/. It allows the server to ask the client about its capabilities. If the client also supports TTYPE, it will return with information such as its name, if it supports colour etc. If the client does not support TTYPE, this will be ignored.
All data will be stored on the protocol’s protocol_flags dictionary, under the ‘TTYPE’ key.
-
class
evennia.server.portal.ttype.Ttype(protocol)[source]¶ Bases:
objectHandles ttype negotiations. Called and initiated by the telnet protocol.
-
__init__(protocol)[source]¶ Initialize ttype by storing protocol on ourselves and calling the client to see if it supporst ttype.
- Parameters
protocol (Protocol) – The protocol instance.
Notes
The self.ttype_step indicates how far in the data retrieval we’ve gotten.
-
will_ttype(option)[source]¶ Handles negotiation of the ttype protocol once the client has confirmed that it will respond with the ttype protocol.
- Parameters
option (Option) – Not used.
Notes
The negotiation proceeds in several steps, each returning a certain piece of information about the client. All data is stored on protocol.protocol_flags under the TTYPE key.
-
evennia.server.portal.webclient module¶
Webclient based on websockets.
This implements a webclient with WebSockets (http://en.wikipedia.org/wiki/WebSocket) by use of the autobahn-python package’s implementation (https://github.com/crossbario/autobahn-python). It is used together with evennia/web/media/javascript/evennia_websocket_webclient.js.
All data coming into the webclient is in the form of valid JSON on the form
[“inputfunc_name”, [args], {kwarg}]
which represents an “inputfunc” to be called on the Evennia side with *args, **kwargs. The most common inputfunc is “text”, which takes just the text input from the command line and interprets it as an Evennia Command: [“text”, [“look”], {}]
-
class
evennia.server.portal.webclient.WebSocketClient(*args, **kwargs)[source]¶ Bases:
autobahn.twisted.websocket.WebSocketServerProtocol,evennia.server.session.SessionImplements the server-side of the Websocket connection.
-
data_in(**kwargs)[source]¶ Data User > Evennia.
- Parameters
text (str) – Incoming text.
kwargs (any) – Options from protocol.
Notes
At initilization, the client will send the special ‘csessid’ command to identify its browser session hash with the Evennia side.
The websocket client will also pass ‘websocket_close’ command to report that the client has been closed and that the session should be disconnected.
Both those commands are parsed and extracted already at this point.
-
disconnect(reason=None)[source]¶ Generic hook for the engine to call in order to disconnect this protocol.
- Parameters
reason (str or None) – Motivation for the disconnection.
-
get_client_session()[source]¶ Get the Client browser session (used for auto-login based on browser session)
- Returns
- This is a django-specific internal representation
of the browser session.
- Return type
csession (ClientSession)
-
nonce= None¶
-
onClose(wasClean, code=None, reason=None)[source]¶ This is executed when the connection is lost for whatever reason. it can also be called directly, from the disconnect method.
- Parameters
wasClean (bool) –
Trueif the WebSocket was closed cleanly.code (int or None) – Close status as sent by the WebSocket peer.
reason (str or None) – Close reason as sent by the WebSocket peer.
-
onMessage(payload, isBinary)[source]¶ Callback fired when a complete WebSocket message was received.
- Parameters
payload (bytes) – The WebSocket message received.
isBinary (bool) – Flag indicating whether payload is binary or UTF-8 encoded text.
-
send_default(cmdname, *args, **kwargs)[source]¶ Data Evennia -> User.
- Parameters
cmdname (str) – The first argument will always be the oob cmd name.
*args (any) – Remaining args will be arguments for cmd.
- Kwargs:
- options (dict): These are ignored for oob commands. Use command
arguments (which can hold dicts) to send instructions to the client instead.
-
send_text(*args, **kwargs)[source]¶ Send text data. This will pre-process the text for color-replacement, conversion to html etc.
- Parameters
text (str) – Text to send.
- Kwargs:
- options (dict): Options-dict with the following keys understood:
raw (bool): No parsing at all (leave ansi-to-html markers unparsed).
nocolor (bool): Clean out all color.
screenreader (bool): Use Screenreader mode.
send_prompt (bool): Send a prompt with parsed html
-
evennia.server.portal.webclient_ajax module¶
AJAX/COMET fallback webclient
The AJAX/COMET web client consists of two components running on twisted and django. They are both a part of the Evennia website url tree (so the testing website might be located on http://localhost:4001/, whereas the webclient can be found on http://localhost:4001/webclient.)
- /webclient - this url is handled through django’s template
system and serves the html page for the client itself along with its javascript chat program.
- /webclientdata - this url is called by the ajax chat using
POST requests (long-polling when necessary) The WebClient resource in this module will handle these requests and act as a gateway to sessions connected over the webclient.
-
class
evennia.server.portal.webclient_ajax.AjaxWebClient[source]¶ Bases:
twisted.web.resource.ResourceAn ajax/comet long-polling transport
-
allowedMethods= ('POST',)¶
-
client_disconnect(csessid)[source]¶ Disconnect session with given csessid.
- Parameters
csessid (int) – Session id.
-
get_client_sessid(request)[source]¶ Helper to get the client session id out of the request.
- Parameters
request (Request) – Incoming request object.
- Returns
The client-session id.
- Return type
csessid (int)
-
isLeaf= True¶
-
lineSend(csessid, data)[source]¶ This adds the data to the buffer and/or sends it to the client as soon as possible.
- Parameters
csessid (int) – Session id.
data (list) – A send structure [cmdname, [args], {kwargs}].
-
mode_close(request)[source]¶ This is called by render_POST when the client is signalling that it is about to be closed.
- Parameters
request (Request) – Incoming request.
-
mode_init(request)[source]¶ This is called by render_POST when the client requests an init mode operation (at startup)
- Parameters
request (Request) – Incoming request.
-
mode_input(request)[source]¶ This is called by render_POST when the client is sending data to the server.
- Parameters
request (Request) – Incoming request.
-
mode_keepalive(request)[source]¶ This is called by render_POST when the client is replying to the keepalive.
-
mode_receive(request)[source]¶ This is called by render_POST when the client is telling us that it is ready to receive data as soon as it is available. This is the basis of a long-polling (comet) mechanism: the server will wait to reply until data is available.
- Parameters
request (Request) – Incoming request.
-
render_POST(request)[source]¶ This function is what Twisted calls with POST requests coming in from the ajax client. The requests should be tagged with different modes depending on what needs to be done, such as initializing or sending/receving data through the request. It uses a long-polling mechanism to avoid sending data unless there is actual data available.
- Parameters
request (Request) – Incoming request.
-
-
class
evennia.server.portal.webclient_ajax.AjaxWebClientSession(*args, **kwargs)[source]¶ Bases:
evennia.server.session.SessionThis represents a session running in an AjaxWebclient.
-
disconnect(reason='Server disconnected.')[source]¶ Disconnect from server.
- Parameters
reason (str) – Motivation for the disconnect.
-
get_client_session()[source]¶ Get the Client browser session (used for auto-login based on browser session)
- Returns
- This is a django-specific internal representation
of the browser session.
- Return type
csession (ClientSession)
-
send_default(cmdname, *args, **kwargs)[source]¶ Data Evennia -> User.
- Parameters
cmdname (str) – The first argument will always be the oob cmd name.
*args (any) – Remaining args will be arguments for cmd.
- Kwargs:
- options (dict): These are ignored for oob commands. Use command
arguments (which can hold dicts) to send instructions to the client instead.
-
send_text(*args, **kwargs)[source]¶ Send text data. This will pre-process the text for color-replacement, conversion to html etc.
- Parameters
text (str) – Text to send.
- Kwargs:
- options (dict): Options-dict with the following keys understood:
raw (bool): No parsing at all (leave ansi-to-html markers unparsed).
nocolor (bool): Remove all color.
screenreader (bool): Use Screenreader mode.
send_prompt (bool): Send a prompt with parsed html
-
-
class
evennia.server.portal.webclient_ajax.LazyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶ Bases:
json.encoder.JSONEncoder-
default(obj)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-