Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unemojify option to textify emojis, fixes #192 #600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ First you need to create a Discord bot user, which you can do by following the i
"sasl": true, // false by default
"username": "test", // nodeirc by default
"password": "p455w0rd" // empty by default
"unemojify": true // Textify emojis from messages send to Discord, false by default
},
"format": { // Optional custom formatting options
// Patterns, represented by {$patternName}, are replaced when sending messages
Expand Down
6 changes: 6 additions & 0 deletions lib/bot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash';
import irc from 'irc-upd';
import discord from 'discord.js';
import { unemojify } from 'node-emoji';
import logger from './logger';
import { ConfigurationError } from './errors';
import { validateChannelMapping } from './validators';
Expand Down Expand Up @@ -46,6 +47,7 @@ class Bot {
this.ircStatusNotices = options.ircStatusNotices;
this.announceSelfJoin = options.announceSelfJoin;
this.webhookOptions = options.webhooks;
this.unemojifyMessages = options.unemojifyMessages === true; // default: false

// Nicks to ignore
this.ignoreUsers = options.ignoreUsers || {};
Expand Down Expand Up @@ -361,6 +363,10 @@ class Bot {
ircChannel
};

if (this.unemojifyMessages) {
text = unemojify(text);
}

if (this.isCommandMessage(text)) {
patternMap.side = 'Discord';
logger.debug('Sending command message to IRC', ircChannel, text);
Expand Down
10 changes: 9 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-irc",
"version": "2.9.0",
"version": "2.9.1",
"description": "Connects IRC and Discord channels by sending messages back and forth.",
"keywords": [
"discord",
Expand Down Expand Up @@ -42,6 +42,7 @@
"irc-formatting": "1.0.0-rc3",
"irc-upd": "0.11.0",
"lodash": "^4.17.21",
"node-emoji": "^1.11.0",
"simple-markdown": "^0.7.3",
"strip-json-comments": "^3.1.1",
"winston": "^3.3.3"
Expand Down