From 406e9a4af50f30f2291b2887ec52988a3f89bee5 Mon Sep 17 00:00:00 2001 From: Etoh Date: Sun, 21 Jan 2018 13:25:07 +0000 Subject: [PATCH] Add --max-chat-message-length server option to allow custom chat message limits --- syncplay/__init__.py | 2 +- syncplay/messages_de.py | 1 + syncplay/messages_en.py | 1 + syncplay/messages_ru.py | 1 + syncplay/server.py | 6 ++++-- syncplayServer.py | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/syncplay/__init__.py b/syncplay/__init__.py index d487e0f80..e03947816 100644 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,4 +1,4 @@ version = '1.5.2' milestone = 'Yoitsu' -release_number = '55' +release_number = '56' projectURL = 'http://syncplay.pl/' diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 5f729b9df..768118bf7 100644 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -431,6 +431,7 @@ "server-disable-ready-argument" : u"Bereitschaftsfeature deaktivieren", "server-motd-argument": u"Pfad zur Datei, von der die Nachricht des Tages geladen wird", "server-chat-argument" : "Should chat be disabled?", # TODO: Translate + "server-chat-maxchars-argument": u"Maximum number of characters in a chat message (default is {})", # TODO: Translate "server-messed-up-motd-unescaped-placeholders": u"Die Nachricht des Tages hat unmaskierte Platzhalter. Alle $-Zeichen sollten verdoppelt werden ($$).", "server-messed-up-motd-too-long": u"Die Nachricht des Tages ist zu lang - Maximal {} Zeichen, aktuell {}.", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index f1926b4a5..e0f79256a 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -435,6 +435,7 @@ "server-disable-ready-argument" : u"disable readiness feature", "server-motd-argument": "path to file from which motd will be fetched", "server-chat-argument" : "Should chat be disabled?", + "server-chat-maxchars-argument" : u"Maximum number of characters in a chat message (default is {})", # Default number of characters "server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).", "server-messed-up-motd-too-long": u"Message of the Day is too long - maximum of {} chars, {} given.", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 0311f3c8a..9bed6701f 100644 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -437,6 +437,7 @@ "server-disable-ready-argument" : u"отключить статусы готов/не готов", "server-motd-argument" : u"путь к файлу, из которого будет извлекаться MOTD-сообщение", "server-chat-argument" : "Should chat be disabled?", # TODO: Translate + "server-chat-maxchars-argument": u"Maximum number of characters in a chat message (default is {})", # TODO: Translate "server-messed-up-motd-unescaped-placeholders" : u"MOTD-сообщение содержит неэкранированные спец.символы. Все знаки $ должны быть продублированы ($$).", "server-messed-up-motd-too-long" : u"MOTD-сообщение слишком длинное: максимальная длина - {} символ(ов), текущая длина - {} символ(ов).", diff --git a/syncplay/server.py b/syncplay/server.py index 4eb5ee88e..96904eef9 100644 --- a/syncplay/server.py +++ b/syncplay/server.py @@ -14,7 +14,7 @@ from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomStringGenerator, meetsMinVersion, playlistIsValid, truncateText class SyncFactory(Factory): - def __init__(self, password='', motdFilePath=None, isolateRooms=False, salt=None, disableReady=False,disableChat=False): + def __init__(self, password='', motdFilePath=None, isolateRooms=False, salt=None, disableReady=False,disableChat=False, maxChatMessageLength=constants.MAX_CHAT_MESSAGE_LENGTH): self.isolateRooms = isolateRooms print getMessage("welcome-server-notification").format(syncplay.version) if password: @@ -27,6 +27,7 @@ def __init__(self, password='', motdFilePath=None, isolateRooms=False, salt=None self._motdFilePath = motdFilePath self.disableReady = disableReady self.disableChat = disableChat + self.maxChatMessageLength = maxChatMessageLength if not isolateRooms: self._roomManager = RoomManager() else: @@ -48,7 +49,7 @@ def getFeatures(self): features["readiness"] = not self.disableReady features["managedRooms"] = True features["chat"] = not self.disableChat - features["maxChatMessageLength"] = constants.MAX_CHAT_MESSAGE_LENGTH + features["maxChatMessageLength"] = self.maxChatMessageLength features["maxUsernameLength"] = constants.MAX_USERNAME_LENGTH features["maxRoomNameLength"] = constants.MAX_ROOM_NAME_LENGTH features["maxFilenameLength"] = constants.MAX_FILENAME_LENGTH @@ -547,3 +548,4 @@ def _prepareArgParser(self): self._argparser.add_argument('--disable-chat', action='store_true', help=getMessage("server-chat-argument")) self._argparser.add_argument('--salt', metavar='salt', type=str, nargs='?', help=getMessage("server-salt-argument")) self._argparser.add_argument('--motd-file', metavar='file', type=str, nargs='?', help=getMessage("server-motd-argument")) + self._argparser.add_argument('--max-chat-message-length', metavar='maxChatMessageLength', type=int, nargs='?',help=getMessage("server-chat-maxchars-argument").format(constants.MAX_CHAT_MESSAGE_LENGTH)) diff --git a/syncplayServer.py b/syncplayServer.py index 347b1713a..f1cac7e04 100755 --- a/syncplayServer.py +++ b/syncplayServer.py @@ -19,5 +19,5 @@ if __name__ == '__main__': argsGetter = ConfigurationGetter() args = argsGetter.getConfiguration() - reactor.listenTCP(int(args.port), SyncFactory(args.password, args.motd_file, args.isolate_rooms, args.salt, args.disable_ready,args.disable_chat)) + reactor.listenTCP(int(args.port), SyncFactory(args.password, args.motd_file, args.isolate_rooms, args.salt, args.disable_ready,args.disable_chat, args.max_chat_message_length)) reactor.run()