diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2017-09-17 02:29:19 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2017-09-17 02:38:57 +0200 |
commit | 499f2c758d1fc11cacaf6db7203b64154a2547a1 (patch) | |
tree | 4a96839c25931d49a4c803356abaad5402c6180e | |
parent | b6be0949f63a8221ad32ac972b1a0288ed56c12d (diff) | |
download | wee-slack-499f2c758d1fc11cacaf6db7203b64154a2547a1.tar.gz |
Ensure that EMOJI is always defined
After the last commit, the EMOJI variable is accessed in the
initialization of SlackTeam. This made some tests fail since they don't
run the main code, so it would not be defined. By setting EMOJI to an
empty list in the top, we ensure that this is not a problem.
-rw-r--r-- | wee_slack.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/wee_slack.py b/wee_slack.py index 620e16b..5eee13d 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -104,6 +104,8 @@ if hasattr(ssl, "get_default_verify_paths") and callable(ssl.get_default_verify_ if ssl_defaults.cafile is not None: sslopt_ca_certs = {'ca_certs': ssl_defaults.cafile} +EMOJI = [] + ###### Unicode handling @@ -953,12 +955,10 @@ class SlackTeam(object): return False def load_emoji_completions(self): - if EMOJI: - self.emoji_completions = list(EMOJI["emoji"]) + self.emoji_completions = list(EMOJI) + if self.emoji_completions: s = SlackRequest(self.token, "emoji.list", {}, team_hash=self.team_hash) self.eventrouter.receive(s) - else: - self.emoji_completions = [] def add_channel(self, channel): self.channels[channel["id"]] = channel @@ -3248,9 +3248,10 @@ def load_emoji(): try: DIR = w.info_get("weechat_dir", "") with open('{}/weemoji.json'.format(DIR), 'r') as ef: - return json.loads(ef.read()) + return json.loads(ef.read())["emoji"] except Exception as e: dbg("Couldn't load emoji list: {}".format(e), 5) + return [] def setup_hooks(): @@ -3578,8 +3579,7 @@ if __name__ == "__main__": w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_changed_cb", "") - global EMOJI - EMOJI = load_emoji() + EMOJI.extend(load_emoji()) setup_hooks() # attach to the weechat hooks we need |