Add standard slack emoji to a compilation unit

v1
Tony Olagbaiye 7 years ago
parent b762aa3a8c
commit 3e0cd6e8d5
No known key found for this signature in database
GPG Key ID: 7420820577A31D11

@ -19,6 +19,7 @@ SRCS=slack.c \
slack-channel.c \ slack-channel.c \
slack-config.c \ slack-config.c \
slack-command.c \ slack-command.c \
slack-emoji.c \
slack-input.c \ slack-input.c \
slack-message.c \ slack-message.c \
slack-oauth.c \ slack-oauth.c \
@ -46,6 +47,9 @@ all: libwebsockets/lib/libwebsockets.a json-c/libjson-c.a weechat-slack
weechat-slack: $(OBJS) weechat-slack: $(OBJS)
$(CXX) $(LDFLAGS) -o slack.so $(OBJS) $(LDLIBS) $(CXX) $(LDFLAGS) -o slack.so $(OBJS) $(LDLIBS)
slack-emoji.inc: slack-emoji.py
env python3 slack-emoji.py > slack-emoji.inc
libwebsockets/lib/libwebsockets.a: libwebsockets/lib/libwebsockets.a:
cd libwebsockets && env CFLAGS= LDFLAGS= cmake -DLWS_STATIC_PIC=ON -DLWS_WITH_SHARED=OFF -DLWS_WITHOUT_TESTAPPS=ON -DLWS_WITH_LIBEV=OFF -DLWS_WITH_LIBUV=OFF -DLWS_WITH_LIBEVENT=OFF -DCMAKE_BUILD_TYPE=DEBUG . cd libwebsockets && env CFLAGS= LDFLAGS= cmake -DLWS_STATIC_PIC=ON -DLWS_WITH_SHARED=OFF -DLWS_WITHOUT_TESTAPPS=ON -DLWS_WITH_LIBEV=OFF -DLWS_WITH_LIBUV=OFF -DLWS_WITH_LIBEVENT=OFF -DCMAKE_BUILD_TYPE=DEBUG .
$(MAKE) -C libwebsockets $(MAKE) -C libwebsockets

@ -74,10 +74,15 @@
- [ ] Implement handling api message =message.message_changed= - [ ] Implement handling api message =message.message_changed=
- [ ] Implement handling api message =message.message_deleted= - [ ] Implement handling api message =message.message_deleted=
- [ ] Implement handling api message =message.message_replied= - [ ] Implement handling api message =message.message_replied=
- [ ] Implement sending websocket =typing= message
** TODO [#B] Implement completion engine (milestone v0.3) ** TODO [#B] Implement completion engine (milestone v0.3)
- [ ] Tab completion for slack emoji (see [[http://github.com/bqv/weechat-slack/issues/3][#3]]) - [ ] Tab completion for slack emoji (see [[http://github.com/bqv/weechat-slack/issues/3][#3]])
- [ ] Support Slack Emoji
- [ ] Support Custom Emoji
- [ ] Tab completion for display/user names (see [[http://github.com/bqv/weechat-slack/issues/1][#1]]) - [ ] Tab completion for display/user names (see [[http://github.com/bqv/weechat-slack/issues/1][#1]])
- [ ] Sort nick-completion by recent (see [[http://github.com/bqv/weechat-slack/issues/4][#4]]) - [ ] Sort nick-completion by recent (see [[http://github.com/bqv/weechat-slack/issues/4][#4]])
** TODO [#B] Implement websocket ping and pong (milestone v0.4)
- [ ] Add ping timer and pong handler (see [[http://github.com/bqv/weechat-slack/issues/9][#9]])
** TODO [#C] Implement remaining api endpoints and events (milestone v0.5) ** TODO [#C] Implement remaining api endpoints and events (milestone v0.5)
- [ ] Complete api endpoint set - [ ] Complete api endpoint set
- [ ] Complete api event set - [ ] Complete api event set

@ -0,0 +1,12 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, version 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <string.h>
#include "weechat-plugin.h"
#include "slack.h"
#include "slack-emoji.h"
#include "slack-emoji.inc"

@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, version 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef _SLACK_EMOJI_H_
#define _SLACK_EMOJI_H_
#endif /*SLACK_EMOJI_H*/

File diff suppressed because it is too large Load Diff

@ -0,0 +1,50 @@
#!/usr/bin/env python3
import requests
import json
import ast
emoji = requests.get("https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json").json()
print("""
#include <stdlib.h>
#define MAX_TEXTS %d
#define MAX_NAMES %d
struct t_slack_emoji_by_name {
const char *name;
const char *unicode;
const char *text_to;
const char *text_from[MAX_TEXTS];
};
struct t_slack_emoji_by_text {
const char *text;
const char *unicode;
const char *name_to;
const char *name_from[MAX_NAMES];
};
"""%(max(len(o['texts'] if o['texts'] else []) for o in emoji) + 1,
max(len(o['short_names'] if o['short_names'] else []) for o in emoji) + 1))
print("static struct t_slack_emoji_by_name slack_emoji_by_name[] =")
print("{"+"\n".join(", {{ {0}, {1}, {2}, {3} }}".format(
json.dumps(name),
json.dumps(ast.parse("\"\\u"+"\\u".join(o['unified'].split('-'))+"\"", mode='eval').body.s),
json.dumps(o['text']),
"{"+json.dumps(o['texts']+[None] if o['texts'] else [None])[1:-1]+"}")
for o,name in sorted(((o,name) for o in emoji for name in o['short_names']),
key=lambda x: x[1])
).replace("null", "NULL")[1:])
print("};")
print("")
print("static struct t_slack_emoji_by_text slack_emoji_by_text[] =")
print("{"+"\n".join(", {{ {0}, {1}, {2}, {3} }}".format(
json.dumps(text),
json.dumps(ast.parse("\"\\u"+"\\u".join(o['unified'].split('-'))+"\"", mode='eval').body.s),
json.dumps(o['short_name']),
"{"+json.dumps(o['short_names']+[None] if o['short_names'] else [None])[1:-1]+"}")
for o,text in sorted(((o,text) for o in emoji if o['texts'] for text in o['texts']),
key=lambda x:x[1])
).replace("null", "NULL")[1:])
print("};")
Loading…
Cancel
Save