u-wave-emoji
Emoji management plugin for üWave.
Last updated 3 years ago by goto-bus-stop .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install u-wave-emoji 
SYNC missed versions from official npm registry.

u-wave-emoji

Generic support for emoji sets and configurable custom emoji for üWave servers.

Install

npm install --save u-wave-emoji

Usage

First create an instance of the u-wave-emoji plugin and .use() it. To enable custom emoji, also provide a local path or a custom blob-store instance. Then add the uw.emoji middleware to the Express app.

import emoji from 'u-wave-emoji';

uw.use(emoji({
  path: './custom-emoji',
  // OR
  store: require('fs-blob-store')('./custom-emoji')
}));


app.use('/assets/emoji', uw.emoji);

API

uw.use(emoji(opts={}))

Create and use the emoji plugin.

Available options are:

  • opts.path - A file path to a directory where custom emoji should be stored.
  • opts.store - A blob-store to be used to store emoji. By default, an fs store is used that saves emoji in the directory specified by opts.path.

uw.emoji.useEmojiSet(set)

Use a predefined emoji set. Multiple emoji sets can be used. If there are duplicate shortcodes, emoji that were registered first take precedence over emoji that were registered later.

import emojione from 'u-wave-emojione'

uw.emoji.useEmojiSet(emojione)

uw.emoji.addCustomEmoji(user, shortcode, stream)

In order to use custom emoji, a Blob Store must be configured.

Define a custom emoji. Custom emoji persist across server restarts.

Parameters

  • user - The user who is adding the emoji. This user must have the emoji.add role.
  • shortcode - String representing the emoji short code. May not contain whitespace.
  • stream - A stream or Buffer containing the emoji image data.

uw.emoji.deleteCustomEmoji(user, shortcode)

Delete an emoji.

Parameters

  • user - The user who is deleting the emoj. This user must have the emoji.remove role.
  • shortcode - Shortcode of the emoji to remove.

uw.emoji.getEmoji(shortcode)

Get information about an emoji.

Parameters

  • shortcode - Shortcode of the emoji.

Returns an object {set, shortcode, name, addedBy}. set identifies the emoji set the emoji is a part of, or null if the emoji is custom. addedBy identifies the user that added the emoji, and is only present for custom emoji.

uw.emoji.list()

Retrieve all emoji. Returns a Promise for an object of the shape {shortcode: "name"}.

Message: emoji:add

Whenever a custom emoji is added, an emoji:add message is published to the uwave channel.

Data

  • shortcode - Shortcode of the new emoji.
  • name - File name of the emoji.
  • addedBy - User ID of the user who added the emoji.

Message: emoji:remove

Whenever a custom emoji is removed, an emoji:remove message is published to the uwave channel.

Data

  • shortcode - Shortcode of the emoji that has been removed.
  • user - User ID of the user who removed the emoji.

License

MIT

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

2 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |