diff --git a/bootstrap.py b/bootstrap.py index 5650dfe..30bb75c 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,6 +5,7 @@ import config from houdini.houdini import Houdini from houdini import ConflictResolution +from houdini import Language if __name__ == '__main__': logger = logging.getLogger('houdini') @@ -21,6 +22,8 @@ if __name__ == '__main__': help='Cache expiry (seconds)', type=int) parser.add_argument('-P', '--plugins', action='store', nargs='*', help='Plugins to load') + parser.add_argument('-l', '--language', action='store', help='Houdini language', + choices=['En', 'Fr', 'Pt', 'Es', 'De', 'Ru']) boot_modes = parser.add_mutually_exclusive_group() boot_modes.add_argument('-W', '--world', action='store_true', help='Run server in world mode') @@ -115,11 +118,12 @@ if __name__ == '__main__': if server['World']: server.update({ 'Id': args.id or config.servers[args.server]['Id'], + 'Language': getattr(Language, args.language) if args.language else config.servers[args.server]['Language'], 'Capacity': args.capacity or config.servers[args.server]['Capacity'], 'CacheExpiry': args.cache_expiry or config.servers[args.server]['CacheExpiry'] }) - server['logging'] = logging + server['Logging'] = logging factory_instance = Houdini(args.server, database=database, diff --git a/config.py.sample b/config.py.sample index d16bb5a..775864a 100644 --- a/config.py.sample +++ b/config.py.sample @@ -1,4 +1,5 @@ from houdini import ConflictResolution +from houdini import Language database = { 'Address': 'localhost', @@ -39,6 +40,7 @@ servers = { 'Id': '100', 'Address': '0.0.0.0', 'Port': 9875, + 'Language': Language.En, 'World': True, 'Capacity': 200, 'CacheExpiry': 3600, diff --git a/houdini/__init__.py b/houdini/__init__.py index b6bd7fd..c3a7fac 100644 --- a/houdini/__init__.py +++ b/houdini/__init__.py @@ -15,7 +15,7 @@ class ConflictResolution(enum.Enum): Exception = 2 -class Language(enum.Enum): +class Language(enum.IntEnum): En = 1 Pt = 2 Fr = 4 diff --git a/houdini/data/penguin.py b/houdini/data/penguin.py index ac13b21..0f2efd0 100644 --- a/houdini/data/penguin.py +++ b/houdini/data/penguin.py @@ -66,6 +66,9 @@ class Penguin(db.Model): rejection_de = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) rejection_ru = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) + def safe_nickname(self, language_bitmask): + return self.nickname if self.approval & language_bitmask else "P" + str(self.id) + @property def approval(self): return int('{}{}0{}{}{}{}'.format(self.approval_ru * 1, self.approval_de * 1, self.approval_es * 1, diff --git a/houdini/penguin.py b/houdini/penguin.py index 4c4a7af..b7057c9 100644 --- a/houdini/penguin.py +++ b/houdini/penguin.py @@ -45,7 +45,7 @@ class Penguin(Spheniscidae): @property def nickname(self): - return self.data.nickname if self.data.approval else "P" + self.data.id + return self.data.safe_nickname(self.server.server_config['Language']) async def load(self): if self.data: