aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2017-02-06 14:31:15 -0800
committerRyan Huber <rhuber@gmail.com>2017-02-06 14:31:15 -0800
commit92688afb3b3d5213dc7b4413867bbdee2b96fd43 (patch)
treeabbd35d1ff52023221d36f200de39d2c04cc995a /wee_slack.py
parent91fcccd081f1f64528aedbec64afe54cc4f863fa (diff)
downloadwee-slack-92688afb3b3d5213dc7b4413867bbdee2b96fd43.tar.gz
add weemoji
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 9938d86..7ad39bd 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -644,6 +644,22 @@ def nick_completion_cb(data, completion_item, current_buffer, completion):
w.hook_completion_list_add(completion, "@" + u.slack_name, 1, w.WEECHAT_LIST_POS_SORT)
return w.WEECHAT_RC_OK
+def emoji_completion_cb(data, completion_item, current_buffer, completion):
+ """
+ Adds all :-prefixed emoji to completion list
+ """
+
+ current_buffer = w.current_buffer()
+ current_channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer, None)
+
+ if current_channel is None:
+ return w.WEECHAT_RC_OK
+
+ for e in EMOJI['emoji']:
+ w.hook_completion_list_add(completion, ":" + e + ":", 0, w.WEECHAT_LIST_POS_SORT)
+
+ return w.WEECHAT_RC_OK
+
def complete_next_cb(data, current_buffer, command):
"""Extract current word, if it is equal to a nick, prefix it with @ and
@@ -2457,6 +2473,20 @@ def create_slack_debug_buffer():
slack_debug = w.buffer_new("slack-debug", "", "", "closed_slack_debug_buffer_cb", "")
w.buffer_set(slack_debug, "notify", "0")
+def load_emoji():
+ try:
+ global EMOJI
+ DIR = w.info_get("weechat_dir", "")
+ #no idea why this does't work w/o checking the type?!
+ dbg(type(DIR), 0)
+ ef = open('{}/weemoji.json'.format(DIR), 'r')
+ EMOJI = json.loads(ef.read())
+ ef.close()
+ except:
+ dbg("Unexpected error: {}".format(sys.exc_info()), 5)
+ return w.WEECHAT_RC_OK
+
+
def setup_hooks():
cmds = {k[8:]: v for k, v in globals().items() if k.startswith("command_")}
@@ -2503,6 +2533,7 @@ def setup_hooks():
w.hook_command_run('/away', 'away_command_cb', '')
w.hook_completion("nicks", "complete @-nicks for slack", "nick_completion_cb", "")
+ w.hook_completion("emoji", "complete :emoji: for slack", "emoji_completion_cb", "")
# Hooks to fix/implement
#w.hook_timer(1000 * 60 * 29, 0, 0, "slack_never_away_cb", "")
@@ -2702,6 +2733,7 @@ if __name__ == "__main__":
w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_changed_cb", "")
+ load_emoji()
setup_hooks()
# attach to the weechat hooks we need