Fix formatting issues and fgame
This commit is contained in:
parent
b7bce3fbc0
commit
e6c36830c4
@ -1,12 +1,15 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
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:
|
||||
def __init__ (self):
|
||||
self.lang = var.LANGUAGE
|
||||
self._load_messages()
|
||||
# some stuff
|
||||
|
||||
def get(self, key):
|
||||
if not self.messages[key.lower()]:
|
||||
@ -16,14 +19,12 @@ class Messages:
|
||||
__getitem__ = get
|
||||
|
||||
def _load_messages(self):
|
||||
MESSAGES_DIR = os.path.join(os.path.dirname(__file__), '..', 'messages')
|
||||
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
|
||||
with open(os.path.join(MESSAGES_DIR, self.lang + '.json')) as f:
|
||||
with open(os.path.join(MESSAGES_DIR, self.lang + ".json")) as 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
|
||||
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)
|
||||
|
||||
if not custom_msgs:
|
||||
@ -33,7 +34,6 @@ class Messages:
|
||||
if key in self.messages:
|
||||
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__))
|
||||
|
||||
self.messages[key.lower()] = message
|
||||
|
||||
messages = Messages()
|
||||
|
@ -8975,7 +8975,7 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
|
||||
parts[0] = gamemode
|
||||
|
||||
if cgamemode(cli, "=".join(parts)):
|
||||
cli.msg(chan, ('fgame_success').format(nick))
|
||||
cli.msg(chan, messages["fgame_success"].format(nick))
|
||||
var.FGAMED = True
|
||||
else:
|
||||
cli.notice(nick, fgame.__doc__())
|
||||
|
Loading…
x
Reference in New Issue
Block a user