diff options
author | jomo <github@jomo.tv> | 2014-07-27 19:42:33 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-07-27 19:42:33 +0200 |
commit | b1a3a92e49b353dfa42b52b448cdbc3b27bb33f8 (patch) | |
tree | 1b135af4f422d2ebcb96e814c08923d52b2f85c3 /chatgroups.py | |
parent | e9b0ad656b71841fa23f332ddf8eff43e5cf1986 (diff) |
apply file read/save helpers
Diffstat (limited to 'chatgroups.py')
-rw-r--r-- | chatgroups.py | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/chatgroups.py b/chatgroups.py index 3fd029e..d87426b 100644 --- a/chatgroups.py +++ b/chatgroups.py @@ -1,17 +1,11 @@ #pylint: disable = F0401 from helpers import * from java.util.UUID import fromString as juuid -import json -chatgroups_filename = "plugins/redstoner-utils.py.dir/files/chatgroups.json" -groups = {} -cg_key = ":" -cg_toggle_list = [] +groups = open_json_file("chatgroups", {}) +cg_key = ":" +cg_toggle_list = [] -try: - groups = json.loads(open(chatgroups_filename).read()) -except Exception, e: - error("Failed to load chatgroups: %s" % e) @hook.command("chatgroup") @@ -86,12 +80,7 @@ def groupchat(sender, message, ann = False): def save_groups(): - try: - chatgroups_file = open(chatgroups_filename, "w") - chatgroups_file.write(json.dumps(groups)) - chatgroups_file.close() - except Exception, e: - error("Failed to write reports: " + str(e)) + save_json_file("chatgroups", groups) @hook.event("player.AsyncPlayerChatEvent", "normal") |