Skip to content

Commit

Permalink
Add --max-chat-message-length server option to allow custom chat mess…
Browse files Browse the repository at this point in the history
…age limits
  • Loading branch information
Et0h committed Jan 21, 2018
1 parent 87d9498 commit 406e9a4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion syncplay/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = '1.5.2'
milestone = 'Yoitsu'
release_number = '55'
release_number = '56'
projectURL = 'http://syncplay.pl/'
1 change: 1 addition & 0 deletions syncplay/messages_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}.",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_ru.py
Original file line number Diff line number Diff line change
Expand Up @@ -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-сообщение слишком длинное: максимальная длина - {} символ(ов), текущая длина - {} символ(ов).",

Expand Down
6 changes: 4 additions & 2 deletions syncplay/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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))
2 changes: 1 addition & 1 deletion syncplayServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 406e9a4

Please sign in to comment.