mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 18:47:16 +01:00
This fixes issue #569
This commit is contained in:
parent
46781d3ee1
commit
dbbacb4bb3
6 changed files with 82 additions and 13 deletions
|
|
@ -21,3 +21,4 @@ class UnloggedinCmdSet(CmdSet):
|
||||||
self.add(unloggedin.CmdUnconnectedQuit())
|
self.add(unloggedin.CmdUnconnectedQuit())
|
||||||
self.add(unloggedin.CmdUnconnectedLook())
|
self.add(unloggedin.CmdUnconnectedLook())
|
||||||
self.add(unloggedin.CmdUnconnectedHelp())
|
self.add(unloggedin.CmdUnconnectedHelp())
|
||||||
|
self.add(unloggedin.CmdUnconnectedEncoding())
|
||||||
|
|
|
||||||
|
|
@ -457,19 +457,21 @@ class CmdEncoding(MuxPlayerCommand):
|
||||||
"""
|
"""
|
||||||
Sets the encoding.
|
Sets the encoding.
|
||||||
"""
|
"""
|
||||||
player = self.player
|
|
||||||
|
if self.session is None:
|
||||||
|
return
|
||||||
|
|
||||||
if 'clear' in self.switches:
|
if 'clear' in self.switches:
|
||||||
# remove customization
|
# remove customization
|
||||||
old_encoding = player.db.encoding
|
old_encoding = self.session.encoding
|
||||||
if old_encoding:
|
if old_encoding:
|
||||||
string = "Your custom text encoding ('%s') was cleared." % old_encoding
|
string = "Your custom text encoding ('%s') was cleared." % old_encoding
|
||||||
else:
|
else:
|
||||||
string = "No custom encoding was set."
|
string = "No custom encoding was set."
|
||||||
del player.db.encoding
|
self.session.encoding = "utf-8"
|
||||||
elif not self.args:
|
elif not self.args:
|
||||||
# just list the encodings supported
|
# just list the encodings supported
|
||||||
pencoding = player.db.encoding
|
pencoding = self.session.encoding
|
||||||
string = ""
|
string = ""
|
||||||
if pencoding:
|
if pencoding:
|
||||||
string += "Default encoding: {g%s{n (change with {w@encoding <encoding>{n)" % pencoding
|
string += "Default encoding: {g%s{n (change with {w@encoding <encoding>{n)" % pencoding
|
||||||
|
|
@ -480,9 +482,9 @@ class CmdEncoding(MuxPlayerCommand):
|
||||||
string = "No encodings found."
|
string = "No encodings found."
|
||||||
else:
|
else:
|
||||||
# change encoding
|
# change encoding
|
||||||
old_encoding = player.db.encoding
|
old_encoding = self.session.encoding
|
||||||
encoding = self.args
|
encoding = self.args
|
||||||
player.db.encoding = encoding
|
self.session.encoding = encoding
|
||||||
string = "Your custom text encoding was changed from '%s' to '%s'." % (old_encoding, encoding)
|
string = "Your custom text encoding was changed from '%s' to '%s'." % (old_encoding, encoding)
|
||||||
self.msg(string.strip())
|
self.msg(string.strip())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,69 @@ You can use the {wlook{n command if you want to see the connect screen again.
|
||||||
self.caller.msg(string)
|
self.caller.msg(string)
|
||||||
|
|
||||||
|
|
||||||
|
class CmdUnconnectedEncoding(MuxCommand):
|
||||||
|
"""
|
||||||
|
set which text encoding to use in unconnected-in state
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
@encoding/switches [<encoding>]
|
||||||
|
|
||||||
|
Switches:
|
||||||
|
clear - clear your custom encoding
|
||||||
|
|
||||||
|
|
||||||
|
This sets the text encoding for communicating with Evennia. This is mostly
|
||||||
|
an issue only if you want to use non-ASCII characters (i.e. letters/symbols
|
||||||
|
not found in English). If you see that your characters look strange (or you
|
||||||
|
get encoding errors), you should use this command to set the server
|
||||||
|
encoding to be the same used in your client program.
|
||||||
|
|
||||||
|
Common encodings are utf-8 (default), latin-1, ISO-8859-1 etc.
|
||||||
|
|
||||||
|
If you don't submit an encoding, the current encoding will be displayed
|
||||||
|
instead.
|
||||||
|
"""
|
||||||
|
|
||||||
|
key = "@encoding"
|
||||||
|
aliases = "@encode"
|
||||||
|
locks = "cmd:all()"
|
||||||
|
|
||||||
|
def func(self):
|
||||||
|
"""
|
||||||
|
Sets the encoding.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self.session is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if 'clear' in self.switches:
|
||||||
|
# remove customization
|
||||||
|
old_encoding = self.session.encoding
|
||||||
|
if old_encoding:
|
||||||
|
string = "Your custom text encoding ('%s') was cleared." % old_encoding
|
||||||
|
else:
|
||||||
|
string = "No custom encoding was set."
|
||||||
|
self.session.encoding = "utf-8"
|
||||||
|
elif not self.args:
|
||||||
|
# just list the encodings supported
|
||||||
|
pencoding = self.session.encoding
|
||||||
|
string = ""
|
||||||
|
if pencoding:
|
||||||
|
string += "Default encoding: {g%s{n (change with {w@encoding <encoding>{n)" % pencoding
|
||||||
|
encodings = settings.ENCODINGS
|
||||||
|
if encodings:
|
||||||
|
string += "\nServer's alternative encodings (tested in this order):\n {g%s{n" % ", ".join(encodings)
|
||||||
|
if not string:
|
||||||
|
string = "No encodings found."
|
||||||
|
else:
|
||||||
|
# change encoding
|
||||||
|
old_encoding = self.session.encoding
|
||||||
|
encoding = self.args
|
||||||
|
self.session.encoding = encoding
|
||||||
|
string = "Your custom text encoding was changed from '%s' to '%s'." % (old_encoding, encoding)
|
||||||
|
self.caller.msg(string.strip())
|
||||||
|
|
||||||
|
|
||||||
def _create_player(session, playername, password,
|
def _create_player(session, playername, password,
|
||||||
default_home, permissions, typeclass=None):
|
default_home, permissions, typeclass=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -268,9 +268,6 @@ class Player(TypeClass):
|
||||||
changing this method.
|
changing this method.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# the text encoding to use.
|
|
||||||
self.db.encoding = "utf-8"
|
|
||||||
|
|
||||||
# A basic security setup
|
# A basic security setup
|
||||||
lockstring = "examine:perm(Wizards);edit:perm(Wizards);delete:perm(Wizards);boot:perm(Wizards);msg:all()"
|
lockstring = "examine:perm(Wizards);edit:perm(Wizards);delete:perm(Wizards);boot:perm(Wizards);msg:all()"
|
||||||
self.locks.add(lockstring)
|
self.locks.add(lockstring)
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,7 @@ class AMPProtocol(amp.AMP):
|
||||||
"""
|
"""
|
||||||
#print "msg portal->server (portal side):", sessid, msg, data
|
#print "msg portal->server (portal side):", sessid, msg, data
|
||||||
return self.safe_send(MsgPortal2Server, sessid,
|
return self.safe_send(MsgPortal2Server, sessid,
|
||||||
msg=to_str(msg) if msg is not None else "",
|
msg=msg if msg is not None else "",
|
||||||
data=dumps(data))
|
data=dumps(data))
|
||||||
|
|
||||||
# Server -> Portal message
|
# Server -> Portal message
|
||||||
|
|
@ -389,7 +389,7 @@ class AMPProtocol(amp.AMP):
|
||||||
"""
|
"""
|
||||||
#print "msg server->portal (server side):", sessid, msg, data
|
#print "msg server->portal (server side):", sessid, msg, data
|
||||||
return self.safe_send(MsgServer2Portal, sessid,
|
return self.safe_send(MsgServer2Portal, sessid,
|
||||||
msg=to_str(msg) if msg is not None else "",
|
msg=msg if msg is not None else "",
|
||||||
data=dumps(data))
|
data=dumps(data))
|
||||||
|
|
||||||
# Server administration from the Portal side
|
# Server administration from the Portal side
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ from django.conf import settings
|
||||||
#from src.scripts.models import ScriptDB
|
#from src.scripts.models import ScriptDB
|
||||||
from src.comms.models import ChannelDB
|
from src.comms.models import ChannelDB
|
||||||
from src.utils import logger, utils
|
from src.utils import logger, utils
|
||||||
from src.utils.utils import make_iter, to_unicode, escape_control_sequences
|
from src.utils.utils import make_iter, to_unicode, to_str, escape_control_sequences
|
||||||
from src.commands.cmdhandler import cmdhandler
|
from src.commands.cmdhandler import cmdhandler
|
||||||
from src.commands.cmdsethandler import CmdSetHandler
|
from src.commands.cmdsethandler import CmdSetHandler
|
||||||
from src.server.session import Session
|
from src.server.session import Session
|
||||||
|
|
@ -198,7 +198,7 @@ class ServerSession(Session):
|
||||||
"""
|
"""
|
||||||
if text:
|
if text:
|
||||||
# this is treated as a command input
|
# this is treated as a command input
|
||||||
text = to_unicode(escape_control_sequences(text))
|
text = to_unicode(escape_control_sequences(text), encoding=self.encoding)
|
||||||
# handle the 'idle' command
|
# handle the 'idle' command
|
||||||
if text.strip() == IDLE_COMMAND:
|
if text.strip() == IDLE_COMMAND:
|
||||||
self.update_session_counters(idle=True)
|
self.update_session_counters(idle=True)
|
||||||
|
|
@ -231,6 +231,12 @@ class ServerSession(Session):
|
||||||
"""
|
"""
|
||||||
Send Evennia -> User
|
Send Evennia -> User
|
||||||
"""
|
"""
|
||||||
|
if text is None:
|
||||||
|
text = ""
|
||||||
|
else:
|
||||||
|
text = to_unicode(text)
|
||||||
|
text = to_str(text, self.encoding)
|
||||||
|
|
||||||
self.sessionhandler.data_out(self, text=text, **kwargs)
|
self.sessionhandler.data_out(self, text=text, **kwargs)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue