Fix formatting issues and fgame

This commit is contained in:
skizzerz 2015-11-11 13:08:50 -06:00
parent b7bce3fbc0
commit e6c36830c4
2 changed files with 8 additions and 8 deletions

View File

@ -1,12 +1,15 @@
import json import json
import os import os
import src.settings as var import src.settings as var
MESSAGES_DIR = os.path.join(os.path.dirname(__file__), "..", "messages")
ROOT_DIR = os.path.join(os.path.dirname(__file__), "..")
class Messages: class Messages:
def __init__ (self): def __init__ (self):
self.lang = var.LANGUAGE self.lang = var.LANGUAGE
self._load_messages() self._load_messages()
# some stuff
def get(self, key): def get(self, key):
if not self.messages[key.lower()]: if not self.messages[key.lower()]:
@ -16,14 +19,12 @@ class Messages:
__getitem__ = get __getitem__ = get
def _load_messages(self): def _load_messages(self):
MESSAGES_DIR = os.path.join(os.path.dirname(__file__), '..', 'messages') with open(os.path.join(MESSAGES_DIR, self.lang + ".json")) as f:
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
with open(os.path.join(MESSAGES_DIR, self.lang + '.json')) as f:
self.messages = json.load(f) self.messages = json.load(f)
if not os.path.isfile(os.path.join(ROOT_DIR, 'messages.json')): if not os.path.isfile(os.path.join(ROOT_DIR, "messages.json")):
return return
with open(os.path.join(ROOT_DIR, 'messages.json')) as f: with open(os.path.join(ROOT_DIR, "messages.json")) as f:
custom_msgs = json.load(f) custom_msgs = json.load(f)
if not custom_msgs: if not custom_msgs:
@ -33,7 +34,6 @@ class Messages:
if key in self.messages: if key in self.messages:
if not isinstance(message, type(self.messages[key.lower()])): if not isinstance(message, type(self.messages[key.lower()])):
raise TypeError("messages.json: Key {0!r} must be of type {1!r}".format(key, type(self.messages[key.lower()]).__name__)) raise TypeError("messages.json: Key {0!r} must be of type {1!r}".format(key, type(self.messages[key.lower()]).__name__))
self.messages[key.lower()] = message self.messages[key.lower()] = message
messages = Messages() messages = Messages()

View File

@ -8975,7 +8975,7 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
parts[0] = gamemode parts[0] = gamemode
if cgamemode(cli, "=".join(parts)): if cgamemode(cli, "=".join(parts)):
cli.msg(chan, ('fgame_success').format(nick)) cli.msg(chan, messages["fgame_success"].format(nick))
var.FGAMED = True var.FGAMED = True
else: else:
cli.notice(nick, fgame.__doc__()) cli.notice(nick, fgame.__doc__())