mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 00:06:30 +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
|
|
@ -174,6 +174,9 @@ class Evennia(object):
|
|||
#
|
||||
#------------------------------------------------------------
|
||||
|
||||
# Tell the system the server is starting up; some things are not available yet
|
||||
ServerConfig.objects.conf("server_starting_mode", True)
|
||||
|
||||
# twistd requires us to define the variable 'application' so it knows
|
||||
# what to execute from.
|
||||
application = service.Application('Evennia')
|
||||
|
|
@ -225,24 +228,19 @@ if WEBSERVER_ENABLED:
|
|||
webserver.setName('EvenniaWebServer%s' % port)
|
||||
EVENNIA.services.addService(webserver)
|
||||
|
||||
|
||||
if IMC2_ENABLED:
|
||||
|
||||
# IMC2 channel connections
|
||||
|
||||
from src.imc2.connection import IMC2ClientFactory
|
||||
from src.imc2 import events as imc2_events
|
||||
imc2_factory = IMC2ClientFactory()
|
||||
svc = internet.TCPClient(settings.IMC2_SERVER_ADDRESS,
|
||||
settings.IMC2_SERVER_PORT,
|
||||
imc2_factory)
|
||||
svc.setName('IMC2')
|
||||
EVENNIA.services.addService(svc)
|
||||
imc2_events.add_events()
|
||||
|
||||
if IRC_ENABLED:
|
||||
|
||||
# IRC channel connections
|
||||
|
||||
from src.comms import irc
|
||||
irc.connect_all()
|
||||
|
||||
if IMC2_ENABLED:
|
||||
|
||||
# IMC2 channel connections
|
||||
|
||||
from src.comms import imc2
|
||||
imc2.connect_all()
|
||||
|
||||
# clear server startup mode
|
||||
ServerConfig.objects.conf("server_starting_mode", delete=True)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ from django.utils import simplejson
|
|||
from django.utils.functional import Promise
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.conf import settings
|
||||
from src.utils import utils
|
||||
from src.utils import utils, logger
|
||||
from src.utils.text2html import parse_html
|
||||
from src.server import session
|
||||
from src.server.sessionhandler import SESSIONS
|
||||
|
|
@ -258,27 +258,13 @@ class WebClientSession(session.Session):
|
|||
pass
|
||||
|
||||
# string handling is similar to telnet
|
||||
if self.encoding:
|
||||
try:
|
||||
string = utils.to_str(string, encoding=self.encoding)
|
||||
self.client.lineSend(self.suid, parse_html(string))
|
||||
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.client.lineSend(self.suid, err)
|
||||
else:
|
||||
#self.client.lineSend(self.suid, ansi.parse_ansi(string, strip_ansi=True))
|
||||
try:
|
||||
string = utils.to_str(string, encoding=self.encoding)
|
||||
self.client.lineSend(self.suid, parse_html(string))
|
||||
return
|
||||
except Exception, e:
|
||||
logger.log_trace()
|
||||
|
||||
def at_data_in(self, string, data=None):
|
||||
"""
|
||||
Input from Player -> Evennia (called by client protocol).
|
||||
|
|
@ -290,22 +276,9 @@ class WebClientSession(session.Session):
|
|||
pass
|
||||
|
||||
# the string part is identical to telnet
|
||||
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_trace()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue