Merge branch 'evennia:main' into hex_colors

This commit is contained in:
Michael Faith 2024-04-07 00:18:17 -07:00 committed by GitHub
commit 716807aea3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
207 changed files with 2521 additions and 1108 deletions

View file

@ -4,6 +4,7 @@ communication to the AMP clients connecting to it (by default
these are the Evennia Server and the evennia launcher).
"""
import os
import sys
from subprocess import STDOUT, Popen
@ -36,7 +37,6 @@ def getenv():
class AMPServerFactory(protocol.ServerFactory):
"""
This factory creates AMP Server connection. This acts as the 'Portal'-side communication to the
'Server' process.
@ -197,8 +197,6 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
if process and not _is_windows():
# avoid zombie-process on Unix/BSD
process.wait()
# unset the reset-mode flag on the portal
self.factory.portal.server_restart_mode = None
return
def wait_for_disconnect(self, callback, *args, **kwargs):
@ -232,11 +230,18 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
"""
if mode == "reload":
self.send_AdminPortal2Server(amp.DUMMYSESSION, operation=amp.SRELOAD)
self.send_AdminPortal2Server(
amp.DUMMYSESSION, operation=amp.SRELOAD, server_restart_mode=mode
)
elif mode == "reset":
self.send_AdminPortal2Server(amp.DUMMYSESSION, operation=amp.SRESET)
self.send_AdminPortal2Server(
amp.DUMMYSESSION, operation=amp.SRESET, server_restart_mode=mode
)
elif mode == "shutdown":
self.send_AdminPortal2Server(amp.DUMMYSESSION, operation=amp.SSHUTD)
self.send_AdminPortal2Server(
amp.DUMMYSESSION, operation=amp.SSHUTD, server_restart_mode=mode
)
# store the mode for use once server comes back up again
self.factory.portal.server_restart_mode = mode
# sending amp data
@ -326,7 +331,6 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
_, server_connected, _, _, _, _ = self.get_status()
# logger.log_msg("Evennia Launcher->Portal operation %s:%s received" % (ord(operation), arguments))
# logger.log_msg("operation == amp.SSTART: {}: {}".format(operation == amp.SSTART, amp.loads(arguments)))
if operation == amp.SSTART: # portal start #15
@ -405,11 +409,11 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
sessid, kwargs = self.data_in(packed_data)
# logger.log_msg("Evennia Server->Portal admin data %s:%s received" % (sessid, kwargs))
operation = kwargs.pop("operation")
portal_sessionhandler = evennia.PORTAL_SESSION_HANDLER
# logger.log_msg(f"Evennia Server->Portal admin data operation {ord(operation)}")
if operation == amp.SLOGIN: # server_session_login
# a session has authenticated; sync it.
session = portal_sessionhandler.get(sessid)
@ -427,22 +431,28 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
portal_sessionhandler.server_disconnect_all(reason=kwargs.get("reason"))
elif operation == amp.SRELOAD: # server reload
# set up callback to restart server once it has disconnected
self.factory.server_connection.wait_for_disconnect(
self.start_server, self.factory.portal.server_twistd_cmd
)
# tell server to reload
self.stop_server(mode="reload")
elif operation == amp.SRESET: # server reset
# set up callback to restart server once it has disconnected
self.factory.server_connection.wait_for_disconnect(
self.start_server, self.factory.portal.server_twistd_cmd
)
# tell server to reset
self.stop_server(mode="reset")
elif operation == amp.SSHUTD: # server-only shutdown
self.stop_server(mode="shutdown")
elif operation == amp.PSHUTD: # full server+server shutdown
# set up callback to shut down portal once server has disconnected
self.factory.server_connection.wait_for_disconnect(self.factory.portal.shutdown)
# tell server to shut down
self.stop_server(mode="shutdown")
elif operation == amp.PSYNC: # portal sync
@ -451,6 +461,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
self.factory.portal.server_process_id = kwargs.get("spid", None)
# this defaults to 'shutdown' or whatever value set in server_stop
server_restart_mode = self.factory.portal.server_restart_mode
# print("Server has connected. Sending session data to Server ... mode: {}".format(server_restart_mode))
sessdata = evennia.PORTAL_SESSION_HANDLER.get_all_sync_data()
self.send_AdminPortal2Server(
@ -461,6 +472,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
portal_start_time=self.factory.portal.start_time,
)
evennia.PORTAL_SESSION_HANDLER.at_server_connection()
self.factory.portal.server_restart_mode = None
if self.factory.server_connection:
# this is an indication the server has successfully connected, so
@ -480,7 +492,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
)
# set a flag in case we are about to shut down soon
self.factory.server_restart_mode = True
self.factory.server_restart_mode = "shutdown"
elif operation == amp.SCONN: # server_force_connection (for irc/etc)
portal_sessionhandler.server_connect(**kwargs)

View file

@ -8,6 +8,7 @@ discord bot set up via https://discord.com/developers/applications
with the MESSAGE CONTENT toggle switched on, and your bot token
added to `server/conf/secret_settings.py` as your DISCORD_BOT_TOKEN
"""
import json
import os
from io import BytesIO

View file

@ -14,6 +14,7 @@ terribly slow connection.
This protocol is implemented by the telnet protocol importing
mccp_compress and calling it from its write methods.
"""
import zlib
# negotiations for v1 and v2 of the protocol

View file

@ -10,6 +10,7 @@ active players and so on.
"""
from django.conf import settings
from evennia.utils import utils

View file

@ -13,6 +13,7 @@ http://www.mushclient.com/mushclient/mxp.htm
http://www.gammon.com.au/mushclient/addingservermxp.htm
"""
import re
from django.conf import settings

View file

@ -9,6 +9,7 @@ NAWS allows telnet clients to report their current window size to the
client and update it when the size changes
"""
from codecs import encode as codecs_encode
from django.conf import settings

View file

@ -7,6 +7,7 @@ sets up all the networking features. (this is done automatically
by game/evennia.py).
"""
import os
import sys

View file

@ -3,7 +3,6 @@ Sessionhandler for portal sessions.
"""
import time
from collections import deque, namedtuple

View file

@ -5,6 +5,7 @@ This connects an RSS feed to an in-game Evennia channel, sending messages
to the channel whenever the feed updates.
"""
from django.conf import settings
from twisted.internet import task, threads

View file

@ -34,9 +34,6 @@ except ImportError:
raise ImportError(_SSH_IMPORT_ERROR)
from django.conf import settings
from evennia.accounts.models import AccountDB
from evennia.utils import ansi
from evennia.utils.utils import class_from_module, to_str
from twisted.conch import interfaces as iconch
from twisted.conch.insults import insults
from twisted.conch.manhole import Manhole, recvline
@ -46,6 +43,10 @@ from twisted.conch.ssh.userauth import SSHUserAuthServer
from twisted.internet import defer, protocol
from twisted.python import components
from evennia.accounts.models import AccountDB
from evennia.utils import ansi
from evennia.utils.utils import class_from_module, to_str
_RE_N = re.compile(r"\|n$")
_RE_SCREENREADER_REGEX = re.compile(
r"%s" % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE

View file

@ -3,6 +3,7 @@ This is a simple context factory for auto-creating
SSL keys and certificates.
"""
import os
import sys

View file

@ -39,9 +39,9 @@ class SuppressGA:
self.protocol = protocol
self.protocol.protocol_flags["NOGOAHEAD"] = True
self.protocol.protocol_flags[
"NOPROMPTGOAHEAD"
] = True # Used to send a GA after a prompt line only, set in TTYPE (per client)
self.protocol.protocol_flags["NOPROMPTGOAHEAD"] = (
True # Used to send a GA after a prompt line only, set in TTYPE (per client)
)
# tell the client that we prefer to suppress GA ...
self.protocol.will(SUPPRESS_GA).addCallbacks(self.will_suppress_ga, self.wont_suppress_ga)

View file

@ -23,6 +23,7 @@ This implements the following telnet OOB communication protocols:
----
"""
import json
import re

View file

@ -7,6 +7,7 @@ when starting and will warn if this was not possible. These will appear as files
ssl.cert in mygame/server/.
"""
import os
try:

View file

@ -14,6 +14,7 @@ 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"], {}]`
"""
import html
import json
import re

View file

@ -17,6 +17,7 @@ http://localhost:4001/webclient.)
to sessions connected over the webclient.
"""
import html
import json
import re