diff --git a/game/gamesrc/commands/default/cmdset_default.py b/game/gamesrc/commands/default/cmdset_default.py index 1f10f98f57..b5eb2b1a56 100644 --- a/game/gamesrc/commands/default/cmdset_default.py +++ b/game/gamesrc/commands/default/cmdset_default.py @@ -29,6 +29,7 @@ class DefaultCmdSet(CmdSet): self.add(general.CmdWho()) self.add(general.CmdSay()) self.add(general.CmdGroup()) + self.add(general.CmdEncoding()) # The help system self.add(help.CmdHelp()) diff --git a/game/gamesrc/commands/default/general.py b/game/gamesrc/commands/default/general.py index e71f378d4d..7e273ccc7f 100644 --- a/game/gamesrc/commands/default/general.py +++ b/game/gamesrc/commands/default/general.py @@ -3,6 +3,7 @@ Generic command module. Pretty much every command should go here for now. """ import time +from django.conf import settings from src.server import sessionhandler from src.permissions.models import PermissionGroup from src.permissions.permissions import has_perm, has_perm_string @@ -650,6 +651,61 @@ class CmdPose(MuxCommand): ## GLOBAL_CMD_TABLE.add_command("@fpose", cmd_fpose) +class CmdEncoding(MuxCommand): + """ + encoding - set a custom text encoding + + Usage: + @encoding/switches [] + + 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" + + def func(self): + """ + Sets the encoding. + """ + caller = self.caller + if 'clear' in self.switches: + # remove customization + old_encoding = caller.player.db.encoding + if old_encoding: + string = "Your custom text encoding ('%s') was cleared." % old_encoding + else: + string = "No custom encoding was set." + del caller.player.db.encoding + elif not self.args: + # just list the encodings supported + encodings = [] + encoding = caller.player.db.encoding + string = "Supported encodings " + if encoding: + encodings.append(encoding) + string += "(the first one you can change with {w@encoding {n)" + encodings.extend(settings.ENCODINGS) + string += ":\n " + ", ".join(encodings) + else: + # change encoding + old_encoding = caller.player.db.encoding + encoding = self.args + caller.player.db.encoding = encoding + string = "Your custom text encoding was changed from '%s' to '%s'." % (old_encoding, encoding) + caller.msg(string) + class CmdGroup(MuxCommand): """ group - show your groups diff --git a/game/gamesrc/commands/default/tests.py b/game/gamesrc/commands/default/tests.py index 2391ee1788..4c895827f2 100644 --- a/game/gamesrc/commands/default/tests.py +++ b/game/gamesrc/commands/default/tests.py @@ -29,7 +29,7 @@ class CmdTest(MuxCommand): key = "@test" aliases = ["@te", "@test all"] - #permissions = "cmd:Immortals Wizards" + permissions = "cmd:Immortals Wizards" # the muxcommand class itself handles the display # so we just defer to it by not adding any function.