How to use the node-emoji.find function in node-emoji

To help you get started, we’ve selected a few node-emoji examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matrix-org / matrix-appservice-slack / lib / BridgedRoom.js View on Github external
BridgedRoom.prototype.onMatrixReaction = async function(message) {
    if (!this._slack_bot_token) return;

    const relates_to = message.content['m.relates_to'];
    const eventStore = this._main.getEventStore();
    const event = await eventStore.getEntryByMatrixId(message.room_id, relates_to.event_id);

    // If we don't get an event then exit
    if (event === null) {
        log.debug("Could not find event to react to.");
        return;
    }

    // Convert the unicode emoji into a slack emote name
    let emoji_key_name = emoji.find(relates_to.key);
    if (emoji_key_name !== undefined) {
        emoji_key_name = emoji_key_name['key'];
    } else {
        emoji_key_name = relates_to.key;
        // Strip the colons
        if (emoji_key_name.startsWith(":") && emoji_key_name.endsWith(":")) {
            emoji_key_name = emoji_key_name.substring(1, emoji_key_name.length - 1);
        }
    }

    // TODO: This only works once from matrix as we are sending the event as the
    // bot user.
    const body = {channel: this._slack_channel_id,
                  timestamp: event.remoteEventId,
                  name: emoji_key_name,
                  as_user: false};
github Snooful / Snooful / src / commands / emoji / emojiinfo.js View on Github external
handler: args => {
		const key = getEmojiKey(args.emoji);
		const emoji = emojiAPI.find(key);

		if (emoji && emoji.emoji && emoji.key) {
			args.send(args.localize("emoji_info", emoji.emoji, emoji.key.replace(/_/g, " ")));
		} else {
			// Search for names
			const search = emojiAPI.search(key);

			if (search[0] && search[0].emoji && search[0].key) {
				args.send(args.localize("emoji_info_closest", search[0].emoji, search[0].key.replace(/_/g, " ")));
			} else {
				args.send(args.localize("emoji_not_found"));
			}
		}
	},
	name: "emojiinfo",
github matrix-org / matrix-appservice-slack / src / BridgedRoom.ts View on Github external
public async onMatrixReaction(message: any) {
        if (!this.botClient) { return; }

        const relatesTo = message.content["m.relates_to"];
        const eventStore = this.main.datastore;
        const event = await eventStore.getEventByMatrixId(message.room_id, relatesTo.event_id);

        // If we don't get an event then exit
        if (event === null) {
            log.debug("Could not find event to react to.");
            return;
        }

        // Convert the unicode emoji into a slack emote name
        let emojiKeyName: string;
        const emojiItem = emoji.find(relatesTo.key);
        if (emojiItem !== undefined) {
            emojiKeyName = emojiItem.key;
        } else {
            emojiKeyName = relatesTo.key;
            // Strip the colons
            if (emojiKeyName.startsWith(":") && emojiKeyName.endsWith(":")) {
                emojiKeyName = emojiKeyName.substring(1, emojiKeyName.length - 1);
            }
        }
        let client: WebClient = this.botClient;
        const puppet = await this.main.clientFactory.getClientForUserWithId(this.SlackTeamId!, message.sender);
        if (puppet) {
            client = puppet.client;
            // We must do this before sending to avoid racing
            // Use the unicode key for uniqueness
            this.addRecentSlackMessage(`reactadd:${relatesTo.key}:${puppet.id}:${event.slackTs}`);
github LeaPhant / flowabot / commands / emote.js View on Github external
emotes.forEach(emoteName => {
            let emote;

            if(emoteName.startsWith("<:") && emoteName.split(":").length > 1)
                emoteName = emoteName.split(":")[1];

            if(emoji.hasEmoji(emoteName))
                emote = emoji.find(emoteName).emoji;
            else if(msg.channel.type == 'text')
                emote = helper.emote(emoteName, msg.guild, client);
            else
                emote = helper.emote(emoteName, null, client);

            if(emote)
                output += emote.toString();
            else
                output += " " + emoteName;
        });
github momocow / semantic-release-gitmoji / lib / release-notes.js View on Github external
get (target, prop) {
      const emoji = findEmoji(prop)
      if (emoji) {
        return target[emoji.emoji]
      }
      return undefined
    }
  })