Parses emoji in payload.data.text
.
- Source:
require('chat-engine-emoji')(config, propopt, eventopt, heightopt, urlopt)
- Source:
Example
const emoji = require('./src/plugin.js');
chat = new OCF.Chat('emoji-chat');
chat.plugin(emoji());
chat.on('message', (payload) => {
// payload.data.text == '<img class="emoji" title=":pizza:" alt="pizza" src="http://www.webpagefx.com/tools/emoji-cheat-sheet/graphics/emojis/pizza.png" height="16" />';
});
chat.emit('message', {
text: 'I want :pizza:'
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
config |
Object | The config object |
||
prop |
String |
<optional> |
"data.text"
|
The payload to search for. |
event |
String |
<optional> |
"message"
|
The ChatEngine event that will trigger emoji parsing. |
config.title |
function | The title of the desktop notification |
||
height |
Integer |
<optional> |
16
|
The height of the resulting emojiß images |
url |
String |
<optional> |
The web directory where emoji images are hosted. Filename (ex: /smile.png) will be added. |
Requires:
Methods
(inner) parseEmoji()
- Augments:
- Source:
Turns:smile:
into <img src="/smile.png" />
Listens to Events:
- event:message
- $history.event:message
(inner) render(string, url, height) → {String}
- Augments:
- Source:
Renders emoji given :smile:
as input.
Parameters:
Name | Type | Description |
---|---|---|
string |
String | The emoji text to turn into an icon |
url |
String | Root url to look for emoji images |
height |
Int | Height of the emoji icons |
Returns:
Returns the IMG HTML for this emoji
- Type
- String
(inner) search(query) → {Array}
- Augments:
- Source:
Finds partial string matches of emoji text by searching emoji db.
Parameters:
Name | Type | Description |
---|---|---|
query |
Strings | The partial text to search for |
Returns:
An array of matching emoji strings. Call the render function to display these.
- Type
- Array