mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 02:36:32 +01:00
Cleanups and bug fixes. Fixed the @unlink command and also made it overally more stable. Resolves issue 161. Added more string conversion routines to handle non-ascii variables being stored in an Attribute. Resolves issue 160.
This commit is contained in:
parent
14db4bea4d
commit
7d30b337d9
27 changed files with 873 additions and 1048 deletions
|
|
@ -10,7 +10,7 @@ sessions etc.
|
|||
from twisted.conch.telnet import StatefulTelnetProtocol
|
||||
from django.conf import settings
|
||||
from src.server import session
|
||||
from src.utils import ansi, utils
|
||||
from src.utils import ansi, utils, logger
|
||||
|
||||
ENCODINGS = settings.ENCODINGS
|
||||
|
||||
|
|
@ -107,47 +107,21 @@ class TelnetProtocol(StatefulTelnetProtocol, session.Session):
|
|||
"""
|
||||
Data Evennia -> Player access hook. 'data' argument is ignored.
|
||||
"""
|
||||
if self.encoding:
|
||||
try:
|
||||
string = utils.to_str(string, encoding=self.encoding)
|
||||
self.lineSend(ansi.parse_ansi(string, strip_ansi=not self.telnet_markup))
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
# malformed/wrong encoding defined on player - try some defaults
|
||||
for encoding in ENCODINGS:
|
||||
try:
|
||||
string = utils.to_str(string, encoding=encoding)
|
||||
err = None
|
||||
break
|
||||
except Exception, e:
|
||||
err = str(e)
|
||||
continue
|
||||
if err:
|
||||
self.lineSend(err)
|
||||
else:
|
||||
self.lineSend(ansi.parse_ansi(string, strip_ansi=not self.telnet_markup))
|
||||
try:
|
||||
string = utils.to_str(string, encoding=self.encoding)
|
||||
except Exception, e:
|
||||
self.lineSend(str(e))
|
||||
return
|
||||
self.lineSend(ansi.parse_ansi(string, strip_ansi=not self.telnet_markup))
|
||||
|
||||
def at_data_in(self, string, data=None):
|
||||
"""
|
||||
Line from Player -> Evennia. 'data' argument is not used.
|
||||
|
||||
"""
|
||||
if self.encoding:
|
||||
try:
|
||||
string = utils.to_unicode(string, encoding=self.encoding)
|
||||
self.execute_cmd(string)
|
||||
return
|
||||
except Exception, e:
|
||||
err = str(e)
|
||||
print err
|
||||
# malformed/wrong encoding defined on player - try some defaults
|
||||
for encoding in ENCODINGS:
|
||||
try:
|
||||
string = utils.to_unicode(string, encoding=encoding)
|
||||
err = None
|
||||
break
|
||||
except Exception, e:
|
||||
err = str(e)
|
||||
continue
|
||||
self.execute_cmd(string)
|
||||
try:
|
||||
string = utils.to_unicode(string, encoding=self.encoding)
|
||||
self.execute_cmd(string)
|
||||
return
|
||||
except Exception, e:
|
||||
logger.log_errmsg(str(e))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue