From d01e9d9c32301b101c3a4ef22935892bf9883b78 Mon Sep 17 00:00:00 2001 From: vonzimr Date: Mon, 9 Oct 2017 12:31:13 -0700 Subject: [PATCH 1/7] fix spelling of variable to be more consistent with comments. --- evennia/server/portal/irc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evennia/server/portal/irc.py b/evennia/server/portal/irc.py index 75ef7fb289..2ac5994426 100644 --- a/evennia/server/portal/irc.py +++ b/evennia/server/portal/irc.py @@ -38,7 +38,7 @@ IRC_CYAN = "11" IRC_BLUE = "12" IRC_MAGENTA = "13" IRC_DGREY = "14" -IRC_GRAY = "15" +IRC_GREY = "15" # obsolete test: @@ -76,7 +76,7 @@ IRC_COLOR_MAP = dict(( (r'|B', IRC_COLOR + IRC_DBLUE), (r'|M', IRC_COLOR + IRC_DMAGENTA), (r'|C', IRC_COLOR + IRC_DCYAN), - (r'|W', IRC_COLOR + IRC_GRAY), # light grey + (r'|W', IRC_COLOR + IRC_GREY), # light grey (r'|X', IRC_COLOR + IRC_BLACK), # pure black (r'|[r', IRC_COLOR + IRC_NORMAL + "," + IRC_DRED), @@ -85,7 +85,7 @@ IRC_COLOR_MAP = dict(( (r'|[b', IRC_COLOR + IRC_NORMAL + "," + IRC_DBLUE), (r'|[m', IRC_COLOR + IRC_NORMAL + "," + IRC_DMAGENTA), (r'|[c', IRC_COLOR + IRC_NORMAL + "," + IRC_DCYAN), - (r'|[w', IRC_COLOR + IRC_NORMAL + "," + IRC_GRAY), # light grey background + (r'|[w', IRC_COLOR + IRC_NORMAL + "," + IRC_GREY), # light grey background (r'|[x', IRC_COLOR + IRC_NORMAL + "," + IRC_BLACK) # pure black background )) # ansi->irc From 9ddd79b202706a51388a2698d1c07639b3e489f8 Mon Sep 17 00:00:00 2001 From: vonzimr Date: Mon, 9 Oct 2017 14:13:48 -0700 Subject: [PATCH 2/7] extra tests for irc parsing functions --- evennia/server/portal/tests.py | 81 ++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 evennia/server/portal/tests.py diff --git a/evennia/server/portal/tests.py b/evennia/server/portal/tests.py new file mode 100644 index 0000000000..f9f787d050 --- /dev/null +++ b/evennia/server/portal/tests.py @@ -0,0 +1,81 @@ +try: + from django.utils.unittest import TestCase +except ImportError: + from django.test import TestCase + +try: + from django.utils import unittest +except ImportError: + import unittest + +import string +from evennia.server.portal import irc + + +class TestIRC(TestCase): + + def test_plain_ansi(self): + """ + Test that printable characters do not get mangled. + """ + irc_ansi = irc.parse_ansi_to_irc(string.printable) + ansi_irc = irc.parse_irc_to_ansi(string.printable) + self.assertEqual(irc_ansi, string.printable) + self.assertEqual(ansi_irc, string.printable) + + def test_evennia_strings(self): + pass + + def test_irc_string(self): + pass + + def test_bold(self): + s_irc = "\x02thisisatest" + s_eve = r'|hthisisatest' + self.assertEqual(irc.parse_ansi_to_irc(s_eve), s_irc) + self.assertEqual(s_eve, irc.prase_irc_to_ansi(s_irc)) + + def test_italic(self): + s_irc = "\x02thisisatest" + s_eve = r'|hthisisatest' + self.assertEqual(irc.parse_ansi_to_irc(s_eve), s_irc) + + def test_colors(self): + color_map = (("\0030", r'|w'), + ("\0031", r'|X'), + ("\0032", r'|B'), + ("\0033", r'|G'), + ("\0034", r'|r'), + ("\0035", r'|R'), + ("\0036", r'|M'), + ("\0037", r'|Y'), + ("\0038", r'|y'), + ("\0039", r'|g'), + ("\00310", r'|C'), + ("\00311", r'|c'), + ("\00312", r'|b'), + ("\00313", r'|m'), + ("\00314", r'|x'), + ("\00315", r'|W')) + + + for m in color_map: + self.assertEqual(irc.parse_irc_to_ansi(m[0]), m[1]) + self.assertEqual(m[0], irc.parse_ansi_to_irc(m[1])) + + + def test_bold(self): + s_irc = "\002thisisatest" + s_eve = r'|hthisisatest' + self.assertEqual(irc.parse_ansi_to_irc(s_eve), s_irc) + self.assertEqual(s_eve, irc.parse_irc_to_ansi(s_irc)) + + def test_underlined(self): + pass + + def test_identity(self): + """ + Test that the composition of the function and + its inverse gives the correct string + """ + pass From 5d2ee7e5f493d0bdad541d5287795fa99eebe1c4 Mon Sep 17 00:00:00 2001 From: vonzimr Date: Mon, 9 Oct 2017 14:14:14 -0700 Subject: [PATCH 3/7] added IRC_INVERT code according to: https://github.com/myano/jenni/wiki/IRC-String-Formatting --- evennia/server/portal/irc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/evennia/server/portal/irc.py b/evennia/server/portal/irc.py index 2ac5994426..7a67a5ba80 100644 --- a/evennia/server/portal/irc.py +++ b/evennia/server/portal/irc.py @@ -20,6 +20,7 @@ IRC_BOLD = "\002" IRC_COLOR = "\003" IRC_RESET = "\017" IRC_ITALIC = "\026" +IRC_INVERT = "\x16" IRC_NORMAL = "99" IRC_UNDERLINE = "37" @@ -57,7 +58,7 @@ IRC_COLOR_MAP = dict(( (r'|t', " "), # tab (r'|-', " "), # fixed tab (r'|_', " "), # space - (r'|*', ""), # invert + (r'|*', IRC_INVERT), # invert (r'|^', ""), # blinking text (r'|h', IRC_BOLD), # highlight, use bold instead From 53a4fc0b667718ca2faffd8f1a2befaee7d84a16 Mon Sep 17 00:00:00 2001 From: Ryan Stein Date: Tue, 10 Oct 2017 12:51:09 -0400 Subject: [PATCH 4/7] resolve #1448, fix 'no help entry' not popping up in webclient --- evennia/commands/default/help.py | 2 +- evennia/server/inputfuncs.py | 14 ++++++++------ .../webclient/static/webclient/css/webclient.css | 2 ++ .../webclient/static/webclient/js/webclient_gui.js | 3 +++ .../webclient/templates/webclient/webclient.html | 3 +-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py index 6f09f98068..a79fc0a61b 100644 --- a/evennia/commands/default/help.py +++ b/evennia/commands/default/help.py @@ -267,7 +267,7 @@ class CmdHelp(Command): return # no exact matches found. Just give suggestions. - self.msg(self.format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions)) + self.msg((self.format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions), {"type": "help"})) def _loadhelp(caller): diff --git a/evennia/server/inputfuncs.py b/evennia/server/inputfuncs.py index 9c7098a7db..3715bb53fe 100644 --- a/evennia/server/inputfuncs.py +++ b/evennia/server/inputfuncs.py @@ -436,9 +436,12 @@ def webclient_options(session, *args, **kwargs): """ account = session.account - clientoptions = settings.WEBCLIENT_OPTIONS.copy() - storedoptions = account.db._saved_webclient_options or {} - clientoptions.update(storedoptions) + clientoptions = account.db._saved_webclient_options + if not clientoptions: + # No saved options for this account, copy and save the default. + account.db._saved_webclient_options = settings.WEBCLIENT_OPTIONS.copy() + # Get the _SaverDict created by the database. + clientoptions = account.db._saved_webclient_options # The webclient adds a cmdid to every kwargs, but we don't need it. try: @@ -448,7 +451,8 @@ def webclient_options(session, *args, **kwargs): if not kwargs: # No kwargs: we are getting the stored options - session.msg(webclient_options=clientoptions) + # Convert clientoptions to regular dict for sending. + session.msg(webclient_options=dict(clientoptions)) # Create a monitor. If a monitor already exists then it will replace # the previous one since it would use the same idstring @@ -461,5 +465,3 @@ def webclient_options(session, *args, **kwargs): # kwargs provided: persist them to the account object for key, value in kwargs.iteritems(): clientoptions[key] = value - - account.db._saved_webclient_options = clientoptions diff --git a/evennia/web/webclient/static/webclient/css/webclient.css b/evennia/web/webclient/static/webclient/css/webclient.css index fff9f29390..1c94a1f9fd 100644 --- a/evennia/web/webclient/static/webclient/css/webclient.css +++ b/evennia/web/webclient/static/webclient/css/webclient.css @@ -31,6 +31,8 @@ strong {font-weight: bold;} div {margin:0px;} +.hidden { display: none; } + /* Utility messages (green) */ .sys { color: #0f0 } diff --git a/evennia/web/webclient/static/webclient/js/webclient_gui.js b/evennia/web/webclient/static/webclient/js/webclient_gui.js index c1af719f72..ba657858d9 100644 --- a/evennia/web/webclient/static/webclient/js/webclient_gui.js +++ b/evennia/web/webclient/static/webclient/js/webclient_gui.js @@ -289,6 +289,7 @@ function onPrompt(args, kwargs) { // Called when the user logged in function onLoggedIn() { + $('#optionsbutton').removeClass('hidden'); Evennia.msg("webclient_options", [], {}); } @@ -323,6 +324,8 @@ function onSilence(cmdname, args, kwargs) {} // Handle the server connection closing function onConnectionClose(conn_name, evt) { + $('#optionsbutton').addClass('hidden'); + closePopup("#optionsdialog"); onText(["The connection was closed or lost."], {'cls': 'err'}); } diff --git a/evennia/web/webclient/templates/webclient/webclient.html b/evennia/web/webclient/templates/webclient/webclient.html index 7be315f3fa..1c641bffb0 100644 --- a/evennia/web/webclient/templates/webclient/webclient.html +++ b/evennia/web/webclient/templates/webclient/webclient.html @@ -11,7 +11,7 @@
- +
@@ -48,4 +48,3 @@
{% endblock %} - From 3d2e7a7efd38311c79add2ec9977e782670ccaf8 Mon Sep 17 00:00:00 2001 From: vonzimr Date: Wed, 11 Oct 2017 19:53:48 -0700 Subject: [PATCH 5/7] remove blank tests --- evennia/server/portal/tests.py | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/evennia/server/portal/tests.py b/evennia/server/portal/tests.py index f9f787d050..cd869996e2 100644 --- a/evennia/server/portal/tests.py +++ b/evennia/server/portal/tests.py @@ -33,49 +33,49 @@ class TestIRC(TestCase): s_irc = "\x02thisisatest" s_eve = r'|hthisisatest' self.assertEqual(irc.parse_ansi_to_irc(s_eve), s_irc) - self.assertEqual(s_eve, irc.prase_irc_to_ansi(s_irc)) - + self.assertEqual(s_eve, irc.parse_irc_to_ansi(s_irc)) + def test_italic(self): s_irc = "\x02thisisatest" s_eve = r'|hthisisatest' self.assertEqual(irc.parse_ansi_to_irc(s_eve), s_irc) def test_colors(self): - color_map = (("\0030", r'|w'), - ("\0031", r'|X'), - ("\0032", r'|B'), - ("\0033", r'|G'), - ("\0034", r'|r'), - ("\0035", r'|R'), - ("\0036", r'|M'), - ("\0037", r'|Y'), - ("\0038", r'|y'), - ("\0039", r'|g'), - ("\00310", r'|C'), - ("\00311", r'|c'), - ("\00312", r'|b'), - ("\00313", r'|m'), - ("\00314", r'|x'), - ("\00315", r'|W')) - + color_map = (("\0030", r'|w'), + ("\0031", r'|X'), + ("\0032", r'|B'), + ("\0033", r'|G'), + ("\0034", r'|r'), + ("\0035", r'|R'), + ("\0036", r'|M'), + ("\0037", r'|Y'), + ("\0038", r'|y'), + ("\0039", r'|g'), + ("\00310", r'|C'), + ("\00311", r'|c'), + ("\00312", r'|b'), + ("\00313", r'|m'), + ("\00314", r'|x'), + ("\00315", r'|W'), + ("\00399,5", r'|[r'), + ("\00399,3", r'|[g'), + ("\00399,7", r'|[y'), + ("\00399,2", r'|[b'), + ("\00399,6", r'|[m'), + ("\00399,10", r'|[c'), + ("\00399,15", r'|[w'), + ("\00399,1", r'|[x')) for m in color_map: self.assertEqual(irc.parse_irc_to_ansi(m[0]), m[1]) self.assertEqual(m[0], irc.parse_ansi_to_irc(m[1])) - - def test_bold(self): - s_irc = "\002thisisatest" - s_eve = r'|hthisisatest' - self.assertEqual(irc.parse_ansi_to_irc(s_eve), s_irc) - self.assertEqual(s_eve, irc.parse_irc_to_ansi(s_irc)) - - def test_underlined(self): - pass - def test_identity(self): """ Test that the composition of the function and - its inverse gives the correct string + its inverse gives the correct string. """ - pass + + s = r'|wthis|Xis|gis|Ma|C|complex|*string' + + self.assertEqual(irc.parse_irc_to_ansi(irc.parse_ansi_to_irc(s)), s) From 9f7fb2734cc186d56df72c7045b540cd86ec808a Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 12 Oct 2017 18:00:39 +0200 Subject: [PATCH 6/7] Make `@py` output appear for all sessions in MULTISESSION_MODE=1 Resolves #1356. --- evennia/commands/default/help.py | 2 +- evennia/commands/default/system.py | 22 ++++++++++++---------- evennia/utils/evmore.py | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py index a79fc0a61b..ebce460748 100644 --- a/evennia/commands/default/help.py +++ b/evennia/commands/default/help.py @@ -75,7 +75,7 @@ class CmdHelp(Command): pass if usemore: - evmore.msg(self.caller, text) + evmore.msg(self.caller, text, session=self.session) return self.msg((text, {"type": "help"})) diff --git a/evennia/commands/default/system.py b/evennia/commands/default/system.py index 77a0dce864..fe5efa337d 100644 --- a/evennia/commands/default/system.py +++ b/evennia/commands/default/system.py @@ -161,7 +161,7 @@ def _run_code_snippet(caller, pycode, mode="eval", measure_time=False, # Try to retrieve the session session = caller if hasattr(caller, "sessions"): - session = caller.sessions.get()[0] + sessions = caller.sessions.all() # import useful variables import evennia @@ -175,11 +175,12 @@ def _run_code_snippet(caller, pycode, mode="eval", measure_time=False, } if show_input: - try: - caller.msg(">>> %s" % pycode, session=session, - options={"raw": True}) - except TypeError: - caller.msg(">>> %s" % pycode, options={"raw": True}) + for session in sessions: + try: + caller.msg(">>> %s" % pycode, session=session, + options={"raw": True}) + except TypeError: + caller.msg(">>> %s" % pycode, options={"raw": True}) try: try: @@ -206,10 +207,11 @@ def _run_code_snippet(caller, pycode, mode="eval", measure_time=False, errlist = errlist[4:] ret = "\n".join("%s" % line for line in errlist if line) - try: - caller.msg(ret, session=session, options={"raw": True}) - except TypeError: - caller.msg(ret, options={"raw": True}) + for session in sessions: + try: + caller.msg(ret, session=session, options={"raw": True}) + except TypeError: + caller.msg(ret, options={"raw": True}) class CmdPy(COMMAND_DEFAULT_CLASS): diff --git a/evennia/utils/evmore.py b/evennia/utils/evmore.py index 4043025d6f..169091396b 100644 --- a/evennia/utils/evmore.py +++ b/evennia/utils/evmore.py @@ -192,7 +192,7 @@ class EvMore(object): if self._npages <= 1 and not always_page: # no need for paging; just pass-through. - caller.msg(text=text, **kwargs) + caller.msg(text=text, session=self._session, **kwargs) else: # go into paging mode # first pass on the msg kwargs From fbaad6c3b7eba426f3925b7f3027b4608ddac23d Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 12 Oct 2017 19:35:42 +0200 Subject: [PATCH 7/7] Further cleanup of a module --- evennia/server/portal/tests.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/evennia/server/portal/tests.py b/evennia/server/portal/tests.py index cd869996e2..be400144c6 100644 --- a/evennia/server/portal/tests.py +++ b/evennia/server/portal/tests.py @@ -23,12 +23,6 @@ class TestIRC(TestCase): self.assertEqual(irc_ansi, string.printable) self.assertEqual(ansi_irc, string.printable) - def test_evennia_strings(self): - pass - - def test_irc_string(self): - pass - def test_bold(self): s_irc = "\x02thisisatest" s_eve = r'|hthisisatest'