Compare commits

..
456 Commits
Author SHA1 Message Date
marc e7330aa7b1 no push statement 2021-12-25 19:11:37 +01:00
marc ce71a7c7e5 docker-compose 2021-12-25 19:10:10 +01:00
marc a6a9531107 build before push 2021-12-25 19:01:11 +01:00
marc 7ce65dc804 docker-compose and makefile 2021-12-25 18:58:44 +01:00
dependabot[bot] b2e7598554 Bump ws from 7.4.5 to 7.4.6 (#593)
Publish Docker image / Publish to Docker Hub (push) Canceled after 0s
Node.js CI / test (12.x) (push) Canceled after 0s
Node.js CI / test (14.x) (push) Canceled after 0s
Node.js CI / test (15.x) (push) Canceled after 0s
Node.js CI / test (16.x) (push) Canceled after 0s
Node.js CI / finish (push) Canceled after 0s
Bumps [ws](https://github.com/websockets/ws) from 7.4.5 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.5...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-23 23:01:41 -03:00
Edward Jones b467e7d915 Upgrade deps as of 2021-04-24 (#590)
* Bump discord.js to 12.5.3

* Bump commander to ^7.2.0

* Bump simple-markdown to ^0.7.3

* Bump @babel dependencies to ^7.13

* Bump cross-env to ^7.0.3

(Nothing relevant; just went to maintenance-only mode)

* Bump lodash to ^4.17.21

* Bump eslint dependencies

* Bump test dependencies (chai, mocha, sinon, sinon-chai)

* Replace babel-eslint with @babel/eslint-parser

* Bump sub-dependencies
2021-04-24 02:23:24 -03:00
Edward Jones e21b174fe1 Add support for Node 15, 16 (#589) 2021-04-24 00:36:26 -03:00
Edward Jones f2ea354717 Drop support for Node 13 (#588)
EOL since June 2020.
2021-04-24 00:31:03 -03:00
dependabot[bot] fd27afb8f1 Bump y18n from 4.0.0 to 4.0.3 (#587)
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.3.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/compare/v4.0.0...y18n-v4.0.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-24 00:26:56 -03:00
Edward Jones feac4c792a Use node-version for coveralls flag-name key (#586)
Should fix coveralls reporting, hopefully
2021-04-24 00:24:04 -03:00
Nick McCurdy 4d31ecd4eb Remove Travis badge
We're using GitHub Actions now.
2021-01-22 19:04:52 -05:00
Nick McCurdy fa83071b5c Change default branch to main 2021-01-22 18:59:59 -05:00
Nick McCurdy 4f449954e0 Replace discordapp.com with discord.com (#567) 2020-11-09 20:33:03 -03:00
Edward Jones d646ba149f 2.9.0 2020-10-03 16:47:42 -03:00
Edward Jones 6f89730ea8 Update changelog for 2.9.0 2020-10-03 16:47:28 -03:00
Edward Jones e0f2edf2d4 Add retryLimit of 3 to the Discord client (#565)
Intended to avoid issues with 500 errors returned
from Discord, as in #461.
2020-10-03 16:35:16 -03:00
Edward Jones 3908e00d16 Upgrade discord.js to v12.3.1 (#564) 2020-10-03 16:30:42 -03:00
dependabot[bot] 328fe0b44e Bump node-fetch from 2.6.0 to 2.6.1 (#562)
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-13 11:43:58 -03:00
KWeaver87andTJ22 5b01e7639f Add customizable IRC nick colors in config (#561)
Co-authored-by: TJ22 <tacojet42@yahoo.com>
2020-09-05 12:41:00 -03:00
Mikaela Szekely 56d1c84147 Fix parsing when the same user is mentioned more than once (#541)
Before, the parser would only replace the first instance of a mention
for any given user in a message.
2020-08-14 21:35:48 -03:00
Edward Jones 5af02c16c6 Add 2.9.0-alpha to CHANGELOG 2020-08-09 02:17:32 -03:00
Edward Jones f047ce0224 Upgrade discord.js to 12.2.0 (#555)
* Upgrade discord.js to 12.2.0

* Use cache accessors in Discord client

* Replace sendMessage with send

* Use avatarURL method

* Update test stubs for discord.js 12

* Disconnect clients at end of tests

* Fix disabling webhook mentions when bot lacks permissions
2020-08-09 02:07:09 -03:00
Edward Jones ee2d70fac1 Fix winston logging to be primarily single-line (#554) 2020-08-08 23:32:21 -03:00
Edward Jones 91ad0b12d2 Update regular dependencies for 2020-08-08 (#553)
* Upgrade irc-upd to 0.11.0

* Bump lodash to ^4.17.19 in package.json

* Upgrade simple-markdown to ^0.7.2

* Upgrade strip-json-comments to ^3.1.1

* Upgrade winston to ^3.3.3

* Upgrade commander to ^5.1.0

* Upgrade commander to ^6.0.0
2020-08-08 22:18:36 -03:00
Edward Jones 8a1378f864 Inline check-env dependency (#552) 2020-08-08 21:53:04 -03:00
Edward Jones 8084ed42a7 Update devDependencies for 2020-08-08 (#551)
* Update eslint dependencies for eslint ^7.6.0

* Upgrade nyc dependencies for nyc ^15.1.0

* Upgrade sinon-chai to ^3.5.0

* Upgrade sinon to ^9.0.2

* Upgrade cross-env to ^7.0.2

* Upgrade coveralls to ^3.1.0

* Upgrade mocha to ^7.2.0

* Upgrade mocha to ^8.1.1
2020-08-08 21:47:10 -03:00
Edward Jones 6df5da619c Drop support for Node <12 (#550)
Upcoming updates to discord require us to update our
version of discord.js, which in turn requires Node >=12.
2020-08-08 21:18:52 -03:00
Edward Jones 7789bd6a24 Add testing for Node 14 (#549) 2020-08-08 21:12:42 -03:00
Edward Jones 1b7d3378aa Update babel devDependencies to recent versions (minor) (#548) 2020-08-08 21:09:24 -03:00
dependabot[bot] 8c97037930 Bump lodash from 4.17.15 to 4.17.19 (#544)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-08 20:39:19 -03:00
Edward Jones 8a02361758 Use NodeJS Action instead of TravisCI (#547)
* Create NodeJS Action

Looks like Travis is a bit broken, and I don't have admin access to the repo over there. For now, as I have admin access to this repo here, let's try out GitHub Actions to replace the old CI.

* Create save-coverage script for Coveralls

* Delete .travis.yml

* Add Docker Hub workflow

* Remove docker-deploy.sh
2020-08-08 20:35:58 -03:00
Edward Jones 41f8444d17 2.8.1 2020-03-16 22:10:55 -03:00
Edward Jones eaf8b3d470 Update changelog for 2.8.1 2020-03-16 22:10:50 -03:00
Edward Jones b3ebca5dcb Use istanbul babel plugin only in tests (#536)
Prevents coverage instrumentation code from being
in the final package.

Fixes #535.
2020-03-16 21:59:10 -03:00
dependabot[bot] 9585a70eb8 Bump acorn from 7.1.0 to 7.1.1 (#534)
Bumps [acorn](https://github.com/acornjs/acorn) from 7.1.0 to 7.1.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/7.1.0...7.1.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-03-16 21:53:04 -03:00
Edward Jones 4fe14837db Fix webhooks for users with no avatars (#530)
* Consistently use this.bot in tests

Some tests were subtly testing broken behavior,
as this.addUser was not correctly adding a user
to the given bot's guild.

* Group up webhook tests in contexts

* Fix webhooks for users with no avatars

Fixes #529.
2020-01-04 18:24:00 -03:00
Miosame 88fecf3aa1 Fix avatars not displaying via webhooks (#511)
* Fix avatars not displaying via webhooks

Avatars that were 2048x2048 would break webhooks displaying avatars, defaulting to 128x128 fixes that.

* travis-ci fix

* Fix null-checks

* Fix travis-ci tests for avatar size
2019-12-24 15:12:28 +01:00
Edward Jones 03d6ac2170 2.8.0 2019-12-14 17:42:52 -03:00
Edward Jones c5ad1a6a6a Upgrade eslint & commander (out of current ranges) (#525)
* Upgrade eslint-config-airbnb-base to ^14.0.0

* Upgrade eslint to ^6.7.2

* Upgrade commander to ^4.0.1
2019-12-14 17:21:01 -03:00
Edward Jones 33d12d7b38 Upgrade dependencies in compatible ranges (#524) 2019-12-14 16:56:02 -03:00
Edward Jones 97b0bf8669 Upgrade to Babel 7 (#523)
* Run npx babel-upgrade, removing unnecessary stage0 plugins

* Move from babel-preset-node6 to @babel/preset-env

* Update nyc to work with updated babel
2019-12-14 16:49:03 -03:00
Nick Savchenko 21985c6d97 Add ignoreUsers.discordIds option to ignore Discorders by ID (#508)
* Add option to ignore discord users by id

* Discord ids are strings. Add ignore by discord id example to README
2019-12-14 15:52:21 -03:00
Edward Jones 11a5347006 Support a basic image on Docker Hub (#498)
* Revert "Revert "Merge branch 'docker-test'""

This reverts commit 2b4bcb1136.

* Use node 12 for docker image

* More thoroughly limit deploy to master pushes

* Use discordirc/discord-irc repo for Docker

* Tag git commit image for Docker hub

* Add .dockerignore
2019-12-14 15:36:36 -03:00
Edward Jones 5d31e2d16b Upgrade simple-markdown per npm audit fix (#522) 2019-12-14 14:46:58 -03:00
Edward Jones 681cd40056 Add support for Node 13, drop automated testing for Node 6 (#521)
* Support Node 13

* Drop automated testing for Node 6
2019-12-14 14:35:26 -03:00
Edward Jones 8a6dec41c6 Rename ircPreventMention to parallelPingFix (#520) 2019-12-14 14:31:12 -03:00
dependabot[bot] 4e807ca34d Bump eslint-utils from 1.3.1 to 1.4.3 (#516)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.3.1 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.3.1...v1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-14 13:41:10 -03:00
Edward Jones 221d42a44b Upgrade sinon to ^7.4.1, sinon-chai to ^3.3.0 (#503)
* Upgrade sinon to ^5.1.1 and sinon-chai to ^3.1.0

* Upgrade sinon to ^6.3.5

* Upgrade sinon to ^7.4.1
2019-08-08 13:03:05 -03:00
Doppins c28151a30c [Doppins] Upgrade dependency discord.js to 11.5.1 (#488)
* Upgrade dependency discord.js to 11.5.0

* Upgrade dependency discord.js to 11.5.1

* Update package-lock.json
2019-08-08 12:38:19 -03:00
Edward Jones d528aedb6d Add ircPreventMention (#502)
* Add ircPreventMention

(This adds a zero-width character to nicknames to prevent IRC-side pings.)

Original commits:

- Add ircPreventMention code

- Document ircPreventMention

- Make ircNickColor wrap the displayUsername

- Fix build errors

- Default ircPreventMention to false

* Correct that ircPreventMention is off by default

* Test ircPreventMention

Only tests turning it on; extant tests ensure it's off by default.
2019-08-08 12:06:07 -03:00
George 70e88498de Add a customizable fallback URL for webhook avatars (#419)
Adds a format option for a default avatar URL to send if the user isn't found on IRC. Takes the user's nickname as an argument so it can be passed to a web service.

Fixes #383.
2019-08-08 11:35:11 -03:00
Edward Jones 4f10b60c89 2.7.2 2019-08-08 11:14:52 -03:00
Edward Jones a719185cc9 Bump lint config versions for eslint 5 (#500)
Fixes deprecation warning upon lint
2019-08-08 11:00:01 -03:00
Edward Jones c9ccd7b473 Run all test/*.test.js files (#501)
Somehow, upgrading either mocha or nyc (?) appears to make
the current test command skip test/bot-events.test.js.
I do not know why, but quoting it (so mocha globs it
instead) seems to fix this.

(This happened between 2.7.0 and 2.7.1.)
2019-08-05 20:21:26 -03:00
Edward Jones 4196726799 Fix lodash security vulnerability 2019-08-05 18:57:01 -03:00
Edward Jones fc9f62a7e7 Add support for Node 10 and 12 (#499) 2019-08-05 00:27:59 +02:00
Edward Jones 3b362d8698 Defer to discord for disabling at-everyone in webhooks (#497)
Discord already has permissions for whether the bot can ping everyone,
and the webhook send method has a `disableEveryone` option, so let's
defer to the inbuilt Discord permission for this.

When permissions can't be found (shouldn't happen), defaults to
disabling the pings.

Fixes #494
2019-08-04 23:39:27 +02:00
Edward Jones 2b4bcb1136 Revert "Merge branch 'docker-test'"
This reverts commit 28fc86826b, reversing
changes made to ef553d37e2.
2019-08-01 17:44:52 +02:00
Edward Jones 28fc86826b Merge branch 'docker-test' 2019-08-01 17:37:08 +02:00
Edward Jones 8cf95fff4f Skip whole deploy step on non-master branches
The deploy section of the deploy phase used to skip anyway,
but it still ran a worker to get to the point where it decided
to skip. This stops it earlier.
2019-08-01 17:35:33 +02:00
Edward Jones 45a898ae67 Use top-level Dockerfile to build image 2019-08-01 17:27:37 +02:00
Edward Jones 492629816e Skip coverage reporting step in deployment 2019-08-01 17:12:48 +02:00
Edward Jones 98c6286416 Skip testing in deploy phase 2019-08-01 17:03:55 +02:00
Edward Jones 977b337a53 Move docker files, remove docker-compose, amend README
The Dockerfile references the code locally, so this move fixes
its `COPY . /bot` line.

docker-compose is primarily for combining container services,
and doesn't add much here, so we're removing it for now.

The README has been updated to explain how to run discord-irc
with a specific configuration file through Docker (locally
and from Docker Hub).
2019-08-01 16:49:56 +02:00
Edward Jones aac3fa677f Use a proper deploy stage for travis pushing to docker 2019-08-01 16:21:05 +02:00
Gareth Coles 5c18507ffd Docker: Build for every commit 2019-08-01 15:12:44 +01:00
Gareth Coles 9387bca2ce Merge branch 'master' into master 2019-07-29 09:45:41 +01:00
Martin Ek ef553d37e2 2.7.1 2019-06-15 19:21:20 -07:00
Martin Ek 3e6aa324f2 Update some dependencies 2019-06-15 19:20:24 -07:00
Martin Ek df3bf91465 Update simple-markdown 2019-06-15 19:15:54 -07:00
Martin Ek 68678fb134 2.7.0 2019-04-02 22:19:46 -07:00
Martin Ek 87608f3e99 Upgrade some dependencies 2019-03-16 23:30:19 +00:00
Martin Ek 5ea6abbe86 Add tests for webhook usernames 2019-03-16 23:29:59 +00:00
Martin Ek 15f2382639 Merge pull request #454 from simnalamburt/patch-1
Update bot.js
2019-03-16 23:16:11 +00:00
Martin Ek 32b12b3096 Merge pull request #476 from Throne3d/add/460-channel-mentions
Add channel mentions, similar to user mentions
2019-03-16 23:13:40 +00:00
Edward Jones 0e21e679fd Test bot converts same-guild channel mentions 2019-03-13 15:10:22 -03:00
Edward Jones 38e7f1fe3a Fix addRole and addEmoji stubs, add addTextChannel stub 2019-03-13 15:10:00 -03:00
Edward Jones d07ac66e39 Convert channel mentions similar to user mentions 2019-03-13 15:09:22 -03:00
Martin Ek 5e3a8e201b Merge pull request #470 from rdb/patch-1
Match IRC-style mentions at beginning of message
2019-03-05 00:49:04 +00:00
rdb ba505edd32 Add unit tests for IRC-style initial mentions (#470) 2019-03-04 15:47:48 +01:00
rdb d7d3bd6f67 Match IRC-style mentions at beginning of message 2019-02-11 13:54:26 +01:00
Gareth Coles 05e7ccd1eb Docker: Less layers (Thanks @3stadt) 2018-12-25 23:08:10 +00:00
Gareth Coles cb4979b0f8 Merge branch 'master' into master 2018-12-25 23:06:43 +00:00
Hyeon Kim d10606106f Update bot.js
Username must be between 2 and 32 in length, even in the webhook.

Reference:
  https://discordapp.com/developers/docs/resources/user#usernames-and-nicknames
2018-12-11 22:40:55 +09:00
James Ward 308766163a use util.inspect for logger instead of json.stringify (#453)
JSON.stringify can't represent every value from our application
passed to logger, but util.inspect can.

this fixes #446
2018-12-09 00:25:16 +00:00
James Ward ebee361e2d use non-deprecated form of Array.find (#449)
* use non-deprecated form of `Array.find`

The older form emitted a deprecation warning in nodejs, cluttering up the log.

* refactor to make lines shorter

required by code style guidelines
2018-11-22 18:28:18 +00:00
Martin Ek 4690e69bd3 2.6.2 2018-09-19 00:27:00 +01:00
Martin Ek 4f3c4365c6 Use bools in readme 2018-09-19 00:26:14 +01:00
Mikaela Suomalainen 1a8685d26d README.md: add SSL & SASL examples (#436)
[CI SKIP]
2018-09-19 00:25:42 +01:00
Martin Ek f8ad2d2fa7 Define a custom winston logger 2018-09-19 00:24:52 +01:00
Martin Ek d7c99e49af Update package-lock.json 2018-09-19 00:10:28 +01:00
Martin Ek 9a98f6da95 Merge branch 'doppins/discord.js-equals-11.4.0' 2018-09-19 00:09:13 +01:00
Martin Ek 877212dd0c Update package-lock.json 2018-09-19 00:08:30 +01:00
Martin Ek 1fd15b9f94 Merge branch 'master' into doppins/discord.js-equals-11.4.0 2018-09-18 23:49:49 +01:00
Doppins 21eda4ef53 Upgrade dependency irc-colors to 1.4.3 (#422) 2018-09-18 23:48:47 +01:00
Doppins b8c069ed12 [Doppins] Upgrade dependency commander to 2.18.0 (#418)
* Upgrade dependency commander to 2.16.0

* Upgrade dependency commander to 2.17.0

* Upgrade dependency commander to 2.17.1

* Upgrade dependency commander to 2.18.0
2018-09-18 23:48:37 +01:00
Doppins fe1aea55b1 Upgrade dependency irc-upd to 0.10.0 (#411) 2018-09-18 23:47:46 +01:00
Doppins dec2ea9379 [Doppins] Upgrade dependency winston to 3.1.0 (#410)
* Upgrade dependency winston to 2.4.3

* Upgrade dependency winston to 3.0.0

* Upgrade dependency winston to 2.4.4

* Upgrade dependency winston to 3.0.0

* Upgrade dependency winston to 3.0.1

* Upgrade dependency winston to 3.1.0
2018-09-18 23:47:29 +01:00
Doppins 9383b1bcf4 [Doppins] Upgrade dependency nyc to ^13.0.1 (#406)
* Upgrade dependency nyc to ^12.0.1

* Upgrade dependency nyc to ^12.0.2

* Upgrade dependency nyc to ^13.0.1
2018-09-18 23:47:17 +01:00
Doppins c5e7b13866 [Doppins] Upgrade dependency simple-markdown to 0.4.2 (#401)
* Upgrade dependency simple-markdown to 0.4.1

* Upgrade dependency simple-markdown to 0.4.2
2018-09-18 23:46:59 +01:00
Doppins 02264093f8 Upgrade dependency discord.js to 11.4.2 2018-08-13 14:22:50 +00:00
Doppins c977943ff8 Upgrade dependency discord.js to 11.4.1 2018-08-12 21:15:51 +00:00
Doppins c75031c67f Upgrade dependency discord.js to 11.4.0 2018-08-09 18:03:41 +00:00
Gareth Coles 2dcd6c97fc Fix dumb copy-paste mistake in build.sh 2018-07-20 09:52:23 +01:00
Gareth Coles 3d57250883 Update build.sh env vars for Travis 2018-07-20 09:44:49 +01:00
Gareth Coles 1f9f6bda6f Add Docker container files and documentation 2018-07-20 09:42:34 +01:00
Martin Ek b252f56658 2.6.1 2018-05-11 22:37:19 +02:00
Martin Ek 6a6a1ed547 Remove node-icu warning 2018-05-11 22:36:54 +02:00
Doppins 1c6146d603 Upgrade dependency simple-markdown to 0.4.0 (#391) 2018-05-11 22:35:45 +02:00
Doppins 20e76872ad Upgrade dependency winston to 2.4.2 (#387) 2018-05-11 22:35:25 +02:00
Doppins cb7dc2b75d Upgrade dependency irc-upd to 0.9.0 (#378) 2018-05-11 22:35:12 +02:00
Edward Jones f624134814 Fix parsing of animated emoji from Discord (#388)
(Fixes #384.)

On the Discord side of things, animated emoji get a prefixed 'a' to the
identifier string, so that instead of the normal emoji string:

`<:test:330064465703862273>`

you instead get:

`<a:test:330064465703862273>`

This commit fixes parseText to also process the animated form into `:test:`.
2018-04-23 12:02:10 +02:00
Doppins 22e3bece3c [Doppins] Upgrade dependency discord.js to 11.3.2 (#371)
* Upgrade dependency discord.js to 11.3.1

* Upgrade dependency discord.js to 11.3.2
2018-03-23 01:23:36 +01:00
Doppins 883c3ecd83 [Doppins] Upgrade dependency commander to 2.15.1 (#363)
* Upgrade dependency commander to 2.14.0

* Upgrade dependency commander to 2.14.1

* Upgrade dependency commander to 2.15.0

* Upgrade dependency commander to 2.15.1
2018-03-22 18:23:14 +01:00
Martin Ek a1e645626f Merge pull request #376 from reactiflux/doppins/simple-markdown-equals-0.3.3
[Doppins] Upgrade dependency simple-markdown to 0.3.3
2018-03-22 17:59:27 +01:00
Martin Ek f0afa90170 Merge pull request #374 from reactiflux/doppins/winston-equals-2.4.1
[Doppins] Upgrade dependency winston to 2.4.1
2018-03-22 17:59:17 +01:00
Martin Ek d2a6dad79a Merge pull request #370 from reactiflux/doppins/irc-colors-equals-1.4.2
[Doppins] Upgrade dependency irc-colors to 1.4.2
2018-03-22 17:59:04 +01:00
Martin Ek 91a191ec37 2.6.0 2018-03-22 15:32:23 +01:00
Martin Ek 0d1dfd22f6 Update webhook instructions 2018-03-22 15:31:10 +01:00
Martin Ek c7263b72dd Merge pull request #230 from Fiaxhs/master
Use webhooks to reflect irc usernames + avatars
2018-03-22 15:22:30 +01:00
Doppins b4f6e50728 Upgrade dependency simple-markdown to 0.3.3 2018-03-11 01:13:56 +00:00
Doppins 85bce0caf6 Upgrade dependency winston to 2.4.1 2018-03-09 19:07:33 +00:00
Doppins 08e1b3dd68 Upgrade dependency irc-colors to 1.4.2 2018-02-26 04:14:26 +00:00
Martin Ek f660afda3b 2.5.1 2018-01-18 14:19:23 +01:00
Martin Ek b80d9f650d Upgrade and pin dependencies 2018-01-18 14:15:36 +01:00
Martin Ek 2da61b3e53 Merge pull request #340 from reactiflux/doppins/commander-equals-2.12.2
[Doppins] Upgrade dependency commander to 2.12.2
2018-01-18 04:48:05 -08:00
Fiaxhs 90c901a034 Merge remote-tracking branch 'upstream/master' 2018-01-11 11:31:48 +01:00
Edward Jones d2fe4200ed Update tests after irc-colors udpate to 1.4.1
irc-colors changed to use \x1d instead of \x16 for v1.4.1, which breaks
this test (erroneously); fix it by expecting the corrected character.

Motivation behind upstream change:
https://github.com/fent/irc-colors.js/issues/13
2017-12-27 22:27:09 +00:00
Edward Jones 0a13110c68 Update package.json, package-lock.json 2017-12-27 22:24:31 +00:00
Doppins aa00cfbce0 Upgrade dependency commander to 2.12.2 2017-11-28 07:09:09 +00:00
Martin Ek 68d0fd8f75 Merge pull request #339 from reactiflux/doppins/commander-equals-2.12.0
[Doppins] Upgrade dependency commander to 2.12.1
2017-11-23 12:32:21 +01:00
Doppins 8b62058541 Upgrade dependency commander to 2.12.1 2017-11-23 10:19:07 +00:00
Doppins 9ab541413f Upgrade dependency commander to 2.12.0 2017-11-22 23:05:09 +00:00
Martin Ek 7de32caa7a Merge pull request #333 from reactiflux/doppins/irc-upd-equals-0.8.1
[Doppins] Upgrade dependency irc-upd to 0.8.1
2017-11-16 22:12:03 +01:00
Doppins 93f1fc15d8 Upgrade dependency irc-upd to 0.8.1 2017-11-02 17:00:28 +00:00
Edward Jones 6e45493055 Fix typo in changelog (coveralls version) 2017-10-27 19:36:22 +01:00
Edward Jones 2e1fed8311 2.5.0 2017-10-27 19:23:54 +01:00
Edward Jones 88c50636b9 Update package-lock.json 2017-10-27 19:23:47 +01:00
Edward Jones 903eca635f Update changelog in preparation for 2.5.0 2017-10-27 19:20:03 +01:00
Martin Ek 4b2ffb2c2c Merge pull request #316 from fishyFrogFace/master
Make it work with group DM
2017-10-27 19:20:25 +02:00
Martin Ek a45e07c760 Merge pull request #273 from Throne3d/improve/mentions
Improve IRC → Discord mentions for non-word characters and partial word matches
2017-10-27 19:17:33 +02:00
Edward Jones cff6eee324 Fix linting in new test for long object 2017-10-23 01:07:02 +01:00
Edward Jones 0992dc2da1 Add tests for partial and overlapping matches 2017-10-23 01:07:02 +01:00
Edward Jones 188553b670 Improve IRC->Discord mentions for non-word characters and partial word matches 2017-10-23 01:07:02 +01:00
Martin Ek 569893adb6 Merge pull request #329 from Throne3d/test/node-8
Test against Node 8, update package-lock.json
2017-10-23 02:05:46 +02:00
Edward Jones 751b750776 Remove Node 7 from CI 2017-10-23 00:58:06 +01:00
Edward Jones 05573eedf4 Update package-lock.json
Some dependencies have changed version, and the package-lock.json file
hasn't been updated to reflect that. This rebuilds it to make it more in
line with the package.json file.
2017-10-23 00:53:56 +01:00
Edward Jones 3d2eeb2798 Test against Node 8
Node 8 has been out for a while, and should be supported as it seems
likely a lot of the userbase will be using it. Test it in Travis to make
sure there are no idiosyncracies between the versions.
2017-10-23 00:49:09 +01:00
Edward Jones db39ba237e Use a prepare script for transpiling instead of prepublish (#323)
From Travis logs:
As of npm@5, `prepublish` scripts will run only for `npm publish`.
(In npm@4 and previous versions, it also runs for `npm install`.)
See the deprecation note in `npm help scripts` for more information.

This was also causing discord-irc to fail to transpile when installed
using npm from source.

This modifies the script to run on the `prepare` hook, so it should
transpile when installed directly from source too.
2017-10-10 09:32:30 -07:00
Martin Ek 6eca392e00 Add missing commas 2017-10-10 09:31:57 -07:00
Martin Ek b86fd1eaa4 Merge remote-tracking branch 'origin/doppins/sinon-from-3.3.0-below-4.0.0' 2017-10-05 01:02:41 +02:00
Anirban Mukhopadhyay c3cac2b7ac Allow displayUsername to be used in command prelude (#321) 2017-10-05 01:01:47 +02:00
Martin Ek ab59a1ec66 Merge remote-tracking branch 'origin/doppins/babel-eslint-from-8.0.0-below-9.0.0' 2017-10-05 01:01:21 +02:00
Martin Ek dc27e8e137 Merge remote-tracking branch 'origin/doppins/discord.js-equals-11.2.0' 2017-10-05 01:00:38 +02:00
Martin Ek 0b266834f0 Set ircOptions.encoding in test configs 2017-10-05 00:59:27 +02:00
Martin Ek 87a3458bdd Upgrade eslint-config-airbnb 2017-10-05 00:54:01 +02:00
Doppins 1f49f74c85 Upgrade dependency winston to 2.4.0 (#318) 2017-10-05 00:35:18 +02:00
Doppins aa3d6fc665 Upgrade dependency mocha to ^4.0.0 (#319) 2017-10-05 00:35:12 +02:00
Martin Ek 3bd32206b4 Merge pull request #322 from anirbanmu/ignore-users-both-ways
Add the ability to ignore IRC/Discord users by nickname
2017-10-05 00:17:01 +02:00
Anirban Mukhopadhyay 94d90960c6 Respond to PR comments. Mostly cleanup. 2017-10-04 17:12:15 -05:00
Anirban Mukhopadhyay be281c5add Add ability to ignore discord users by nickname 2017-10-04 11:45:50 -05:00
Anirban Mukhopadhyay 0adcf50b02 Fix ESLint issue & add test for ignoring IRC users 2017-10-04 11:45:36 -05:00
Anirban Mukhopadhyay a12a186f8c Add ability to ignore certain IRC nicks 2017-10-04 11:45:11 -05:00
Doppins bc382d8d5c Upgrade dependency sinon to ^4.0.1 2017-10-04 08:58:09 +00:00
fishyFrogFace 78c4935614 Make it work with group DM 2017-09-30 23:12:17 +02:00
Edward Jones 7fbf1d0ba0 Set default encoding to UTF-8 (#315)
* Add a note about how to install optional charset converter dependencies

Fixes part of #252 and #237.

* Default ircOptions.encoding to utf-8 if node-irc can convert encodings

Also warn when started if the IRC library cannot convert between
encodings, in case users rely on this behavior.

* Improve config check and warning message around encodings
2017-09-30 16:35:59 +02:00
Doppins 1c0cc3fba4 Upgrade dependency coveralls to ^3.0.0 (#310) 2017-09-30 00:44:39 +02:00
Doppins 1cf6d644c8 [Doppins] Upgrade dependency simple-markdown to ^0.3.1 (#293)
* Upgrade dependency simple-markdown to ^0.3.0

* Upgrade dependency simple-markdown to ^0.3.1
2017-09-30 00:44:10 +02:00
Doppins 2fba3ee008 Upgrade dependency irc-upd to 0.8.0 (#313) 2017-09-30 00:43:26 +02:00
Doppins 59b9e071d5 Upgrade dependency babel-eslint to ^8.0.1 2017-09-27 20:53:30 +00:00
John M. Harris, Jr ddaa2e6325 Update README.md (#307)
If there's a link for Discord, there should be a link for IRC as well.
2017-09-27 01:51:42 +02:00
Doppins 69a8b8d9ae Upgrade dependency sinon to ^4.0.0 2017-09-26 07:58:57 +00:00
Doppins fdd7b1d200 Upgrade dependency sinon to ^3.3.0 2017-09-18 10:15:47 +00:00
Dan Hemberger 8bf36dd58d bot.js: enable autoRenick by default (#302)
When the client reconnects to IRC after a timeout, the bot nickname
is often still in use (the client receives an `err_nicknameinuse`
message), and the bot is given an alternate nickname by the server.
In this case, it is almost always desirable to try to change the
nickname back to the configured nickname, so we enable `autoRenick`
by default.

NOTE: `autoRenick` can be disabled by specifying `autoRenick: false`
in `ircOptions` in the discord-irc configuration file, or the
behavior can be modified with the `renickCount` and `renickDelay`
options. See the node-irc documentation for more details.
2017-09-18 06:56:13 +02:00
Eric Schneider c0a4133d03 Closes #299 (#301)
* I think this should work?

* Added test for multi-character command prefixes

(accidentally pushed to wrong branch there but let's hope no one notices)

* Fixed bot test. That looks better.
2017-09-18 00:54:36 +02:00
Doppins f8f7fea3b6 Upgrade dependency babel-eslint to ^8.0.0 2017-09-12 13:46:39 +00:00
Doppins 55b9d48c52 Upgrade dependency discord.js to 11.2.1 2017-09-03 18:56:14 +00:00
Doppins eecb782dc5 Upgrade dependency discord.js to 11.2.0 2017-09-03 17:25:30 +00:00
Martin Ek 345da09fcf Merge pull request #289 from reactiflux/release/2.4.2
Release 2.4.2
2017-08-31 00:41:26 -07:00
Edward Jones 65bb6fa85e 2.4.2 2017-08-21 15:56:35 +01:00
Edward Jones 631b0485aa Update changelog in preparation for 2.4.2 2017-08-21 15:56:30 +01:00
Martin Ek 552bba2c75 Merge pull request #284 from reactiflux/doppins/irc-upd-equals-0.7.0
[Doppins] Upgrade dependency irc-upd to 0.7.0
2017-08-20 21:06:18 -07:00
Martin Ek 1ff61413cc Merge pull request #279 from Throne3d/fix/test-windows
Fix test globbing on Windows
2017-08-20 21:06:00 -07:00
Doppins 7a7cd24695 Upgrade dependency irc-upd to 0.7.0 2017-08-06 23:33:19 +00:00
Fiaxhs 549b8fb767 One pass for webhook options
Variables renaming
Improved code readability
2017-08-03 13:52:25 +02:00
Fiaxhs ff788083d1 Better tests
Preventing crash on empty nickname
2017-07-31 15:12:31 +02:00
Fiaxhs e8c96e2a44 Fixed username/nickname matching 2017-07-31 10:59:58 +02:00
Edward Jones 92d5b437ba Fix test globbing on Windows
Windows doesn't support the inline evaluation `$(find..)` and also
doesn't support the find command. `nyc` can handle this itself, as can
it appears `_mocha` (i.e. this command works both without and with the
`--` given just before the globbing), so it doesn't seem the find
command is necessary.

This allows `npm test` to function on Windows using PowerShell. For some
reason the coverage report is missing data, but it misses data without
this change also.
2017-07-29 16:50:48 +01:00
Fiaxhs 8a23a91931 Fix avatar lookup function (and tests) 2017-07-28 11:54:02 +02:00
Fiaxhs 4facb56ebb Updated avatar tests with new guild/members stub 2017-07-28 11:40:20 +02:00
Fiaxhs 07662761b4 Merge remote-tracking branch 'upstream/master' 2017-07-28 11:25:46 +02:00
Fiaxhs 34cdd373af Avatar matching is now more accurate and case insensitive 2017-07-28 11:19:25 +02:00
Martin Ek ddd9c54645 Merge pull request #272 from Throne3d/improve/tests-discord-collections
Modify tests to use actual discord Collections and a single guild for clarity
2017-07-27 23:44:35 -07:00
Edward Jones f0ffc260cc Don't mutate given param, remove unnecessary guild constant 2017-07-19 15:02:18 +01:00
Martin Ek 2f6a3d5eed Merge pull request #271 from Throne3d/release/2.4.1
Release 2.4.1
2017-07-18 21:45:18 -07:00
Edward Jones e47d8e3aab Modify tests to use actual discord Collections and a single guild for clarity 2017-07-17 16:44:38 +01:00
Edward Jones f56b51a569 2.4.1 2017-07-16 13:00:07 +01:00
Edward Jones 74dea2b67d Update changelog in preparation for 2.4.1 2017-07-16 13:00:05 +01:00
Martin Ek 3a1841c8ca Merge pull request #270 from reactiflux/doppins/irc-upd-equals-0.6.2
[Doppins] Upgrade dependency irc-upd to 0.6.2
2017-07-16 00:26:29 -07:00
Doppins 531ea6bd95 Upgrade dependency irc-upd to 0.6.2 2017-07-16 00:24:08 +00:00
Martin Ek 726100eb98 Merge pull request #267 from Throne3d/fix/deprecation-sendmessage-send
Translate TextChannel#sendMessage to #send to fix deprecation warning
2017-07-15 15:08:21 -07:00
Edward Jones 7f7505cae7 Translate TextChannel#sendMessage to #send to fix deprecation warning
Fixes #266, changing references to "sendMessage" to "send". It seems to
work just fine with some brief testing and this reflects the fact the
method seems to just be a passthrough:
https://github.com/hydrabolt/discord.js/blob/11.1.0/src/structures/interfaces/TextBasedChannel.js#L415

This also changes the test stub "sendMessageStub" to be "sendStub" to
reflect the name change.
2017-07-11 21:10:27 +01:00
Martin Ek c9299a6269 Merge pull request #262 from reactiflux/doppins/commander-equals-2.11.0
[Doppins] Upgrade dependency commander to 2.11.0
2017-07-06 00:37:04 -07:00
Martin Ek ae5fc08222 Merge pull request #264 from Throne3d/fix/docs-readme-ircupd
Update link to IRC library docs (irc-upd instead of node-irc)
2017-07-06 00:36:25 -07:00
Edward Jones 031f22f1ec Update link to IRC library docs (irc-upd instead of node-irc) 2017-07-05 21:10:23 +01:00
Fiaxhs d62dcfb9e6 Merge remote-tracking branch 'upstream/master' 2017-07-04 10:29:03 +02:00
Doppins b299d80169 Upgrade dependency commander to 2.11.0 2017-07-03 10:07:40 +00:00
Martin Ek 85a55e6ef2 Merge pull request #260 from Throne3d/fix/239-skip-falsy-cmdprelude
Skip sending falsy command preludes
2017-07-02 18:26:42 -07:00
Edward Jones 1aff7a99ef Skip sending falsy command preludes
Fixes #239 by allowing falsy command preludes to override default, and
then manually skipping them in the sendToIrc and sendToDiscord methods.
2017-07-01 21:11:59 +01:00
Edward Jones 47a5a6c085 Release 2.4.0 (#259)
* Update changelog in preparation for 2.4.0

* 2.4.0
2017-07-01 12:45:05 -07:00
Doppins 483fc44e9b [Doppins] Upgrade dependency eslint to ^4.1.1 (#254)
* Upgrade dependency eslint to ^4.0.0

* Upgrade dependency eslint to ^4.1.0

* Upgrade dependency eslint to ^4.1.1

* lint: run eslint --fix
2017-07-01 12:08:49 -07:00
Martin Ek 67ac5f1605 Merge pull request #258 from Throne3d/upgrade/migrate-to-irc-upd
Move from irc 0.5.2 to irc-upd 0.6.1
2017-07-01 11:47:01 -07:00
Martin Ek d7b4ab5889 Merge pull request #257 from Throne3d/fix/nickname-differs
Use ircClient.nick instead of nickname when guarding against events for current nick
2017-07-01 11:45:43 -07:00
Edward Jones 474d298713 Translate custom emoji references from IRC to Discord (#256)
When an IRC user uses a custom emoji reference (e.g.
:testemoji:), it should be translated into the actual
emoji for Discord users, instead of appearing in plain
text.

This also adds tests to ensure other emoji-like phrases
do not get converted or cause the bot to crash.
2017-07-01 11:44:31 -07:00
Doppins afc5df4a86 Upgrade dependency commander to 2.10.0 (#255) 2017-07-01 11:42:55 -07:00
Doppins 6c30f7b933 [Doppins] Upgrade dependency nyc to ^11.0.3 (#247)
* Upgrade dependency nyc to ^11.0.0

* Upgrade dependency nyc to ^11.0.1

* Upgrade dependency nyc to ^11.0.2

* Upgrade dependency nyc to ^11.0.3
2017-07-01 11:42:46 -07:00
Doppins 596a9fdbae [Doppins] Upgrade dependency chai to ^4.0.2 (#245)
* Upgrade dependency chai to ^4.0.0

* Upgrade dependency chai to ^4.0.1

* Upgrade dependency chai to ^4.0.2
2017-07-01 11:42:39 -07:00
Edward Jones c0d443d9c5 Move from irc 0.5.2 to irc-upd 0.6.1
The irc module does not appear to be very actively maintained, and has
quite a few issues causing issues in this project itself.

This fork, maintained by me, has a few fixes to some major issues
already.

Changelogs:

- v0.6.0 - https://github.com/Throne3d/node-irc/releases/tag/v0.6.0
- v0.6.1 - https://github.com/Throne3d/node-irc/releases/tag/v0.6.1

Should fix #199, #200, as well as some issues not previously noted
(crash if unbanning a user who is not banned, crash in circumstances
with a poor internet connection).

It may also allow us to remove our workaround for the quit and nick
events having all channels in the associated array.
2017-07-01 17:29:33 +01:00
Edward Jones 76fda25a19 Use ircClient.nick instead of nickname when checking current nick
As the irc library can change the nick of the bot when
connecting (e.g. because the nick is currently taken, by
some other user), `this.nickname` may not correspond to the
current nickname and so when receiving a join event upon
joining a channel (prior to the names event), the current
guard against this can pass despite it being an event for
the bot.

This modifies it to check against ircClient.nick where
relevant, and also modifies the test stubs to allow adding
the nickname to the config and exposing this functionality
in tests.

To see the failure before this patch, enable
`ircStatusNotices` and run two copies of the bot; the
second should crash upon joining a channel, as it will have
a modified nickname (e.g. 'testbot1').
2017-07-01 01:11:49 +01:00
Martin Ek 80c3752074 Merge pull request #249 from reactiflux/doppins/check-env-equals-1.3.0
[Doppins] Upgrade dependency check-env to 1.3.0
2017-06-09 03:32:59 +02:00
Doppins efa3d513fe Upgrade dependency check-env to 1.3.0 2017-06-09 01:31:40 +00:00
Fiaxhs 8c0c11a2b1 Added webhooks section to readme 2017-05-30 16:11:59 +02:00
Fiaxhs 2bf761b163 getDiscordAvatar refactoring
Added test
2017-05-30 14:37:57 +02:00
Fiaxhs fa9ef71372 Merge remote-tracking branch 'upstream/master' 2017-05-30 14:35:58 +02:00
Martin Ek 8c4d83a37d Merge pull request #241 from Junky2k/master
check if an user is present in the channel for nickchange
2017-05-16 10:51:05 -04:00
Richard Schöbel fd95d7d9b0 check if an user is present in the channel 2017-05-16 16:06:39 +02:00
Martin Ek 5453e4589f Merge pull request #235 from Junky2k/master
send nick change from irc to discord
2017-05-16 08:53:18 -04:00
Richard Schöbel fd88a992b1 fixed 'nitpick' :D, and only sends to tracked channels,
edited tests to reflect these changes
2017-05-16 14:05:22 +02:00
Martin Ek 131b48fb01 Merge pull request #229 from reactiflux/doppins/discord.js-equals-11.1.0
[Doppins] Upgrade dependency discord.js to 11.1.0
2017-05-15 22:30:30 -04:00
Martin Ek a03433d357 Merge pull request #221 from Throne3d/add/discord-commands
Allow commandCharacters to work for messages sent to Discord
2017-05-15 22:30:05 -04:00
Richard Schöbel ec7ca8b88d more tests and usage of ircStatusNotices 2017-05-10 01:25:00 +02:00
Richard Schöbel 2e96dd7b79 Added test 2017-05-10 00:56:27 +02:00
Richard Schöbel 4edb307556 fixed linter stuff 2017-05-10 00:13:48 +02:00
Richard Schöbel e2eb354c0b removed tabs and so 2017-05-09 22:44:32 +02:00
Richard Schöbel 284d60b0ad send nick change fromn irc to discord 2017-05-09 22:19:52 +02:00
Fiaxhs b4452dd487 remove useless brackets 2017-05-02 13:06:21 +02:00
Fiaxhs 2c05038c37 Reworked webhook flow
IRC formatting
2017-05-02 13:03:00 +02:00
Fiaxhs 9ea90a9d96 Merge remote-tracking branch 'upstream/master' 2017-05-02 12:42:29 +02:00
Fiaxhs 3ca43ae0f4 use discord.js 11.1.0 2017-05-02 12:03:26 +02:00
Doppins 9c7bc2f8c7 Upgrade dependency discord.js to 11.1.0 2017-05-01 17:41:36 +00:00
Martin Ek fe37ec48a4 2.3.3 2017-04-29 22:15:01 -04:00
Martin Ek ef73243b21 Merge pull request #218 from Throne3d/fix/warn-on-no-names
Warn if a part/quit is received and no channelUsers is set
2017-04-29 22:14:21 -04:00
Edward Jones 03596570bc Warn if a part/quit is received and no channelUsers is set
Attempts to fix #216's crash but is unlikely to fix the
underlying issue (that somehow the client isn't saving
a list of nicks in a channel, either because the server
isn't sending a names event, or the node-irc library is
processing it poorly, or otherwise).
2017-04-29 23:49:56 +01:00
Martin Ek aefd88cd97 2.3.2 2017-04-27 09:50:57 -04:00
Martin Ek 4d238d9bd4 Merge pull request #219 from Throne3d/fix/statuses-casing
Fix ircStatusNotices when channels are not lowercase
2017-04-14 14:34:53 -04:00
Martin Ek 8c3ad07386 Merge pull request #222 from Throne3d/fix/docs
Add documentation for Discord channel IDs and the custom formatting
2017-04-14 14:34:13 -04:00
Edward Jones d877ae2fdd Add documentation for the custom formatting config 2017-04-14 00:37:26 +01:00
Edward Jones ce7db43ef1 Explain how to use Discord channel IDs in the README 2017-04-14 00:29:07 +01:00
Edward Jones 4120c5961b Allow commandCharacters to work for messages sent to Discord
Fixes #217.
- Reorganize the comments describing how to format the custom
formatting options
- Make 'author' and 'nickname' synonyms in the custom formatting
- Add a 'side' parameter for commandPrelude (takes 'Discord' or
  'IRC', depending on whether the message was from Discord or IRC)
- Add debug messages upon sending command messages
- Add similar functionality for command messages sent in IRC to
  Discord, as from Discord to IRC
- Add tests for the above and custom formatting of it
2017-04-13 19:13:38 +01:00
Edward Jones de448eac49 Fix ircStatusNotices when channels are not lowercase
Should fix #216, by lowercasing the channel name when
it receives each event. This also adds debug messages
to make it easier to see when the bot is actually
receiving (and presumably processing) these events.
2017-04-13 18:29:26 +01:00
Martin Ek 884f0cafa0 2.3.1 2017-04-05 16:12:10 -04:00
Martin Ek beb1b336d6 Merge pull request #214 from Throne3d/fix/quit-messages-all-channels
Fix IRC quit messages sending to all channels by tracking users
2017-04-05 16:11:05 -04:00
Edward Jones cc990d67e1 Use sets instead of arrays for user membership in channels 2017-04-05 20:52:38 +01:00
Edward Jones 1c8fa12def Fix IRC quit messages sending to all channels by tracking users
Keep a list of users in each channel, using the names event
in addition to the join/part events, so as to prevent spamming
unnecessary channels when the quit event is raised with all
channels from a server.

Fixes #213.
2017-04-04 17:15:14 +01:00
Martin Ek 27f9abe6c7 Add credits to mraof for version 2.3.0 as well 2017-04-03 23:22:01 -04:00
Martin Ek a41cd0c6a1 Fix typo in CHANGELOG 2017-04-03 23:20:10 -04:00
Martin Ek cb184cc023 2.3.0 2017-04-03 23:18:22 -04:00
Martin Ek c9fa8ba596 Merge pull request #207 from Throne3d/add/joinpart
Bridge IRC join/part/quit messages to Discord
2017-03-30 16:32:02 -05:00
Edward Jones f996405964 Add example to README for ircStatusNotices 2017-03-30 15:24:41 +01:00
Edward Jones 215c33baff Rename special->exact and getDiscordChannelFor->findDiscordChannel 2017-03-30 15:24:41 +01:00
Edward Jones 99e3a0f83f Add tests for not-in-channel vs channel-not-in-mapping 2017-03-30 15:24:41 +01:00
Edward Jones 2b85b8f458 Extract getDiscordChannelFor from send(Special)ToDiscord 2017-03-30 15:24:41 +01:00
Edward Jones de68c48202 Add test to ensure special messages send 2017-03-30 15:22:55 +01:00
Edward Jones 607cb687fd Allow users to have bot announce itself joining IRC to Discord 2017-03-30 15:22:55 +01:00
Edward Jones c39d751f4f Bot should not announce itself joining IRC 2017-03-30 15:22:55 +01:00
Edward Jones 0633c32b0a Add ability to disable join/part messages and test for this 2017-03-30 15:22:55 +01:00
Edward Jones 611aa6b6db Update part/quit messages and add tests
- Do not discard reason from part messages
- Output to each channel in the quit messages
- Add tests for join/part/quit events
- Add test that sendSpecialToDiscord doesn't send messages
  to outside the channel mapping
2017-03-30 15:22:55 +01:00
Edward Jones 4322ed595e Cleanup rebase to match newer code 2017-03-30 15:22:55 +01:00
Edward Jones 352065b019 Fix merge 2017-03-30 15:22:55 +01:00
stupid cat b60c86c858 Fixed trailing spaces 2017-03-30 15:22:55 +01:00
stupid cat 89ec8128f2 Fixed functions being broken 2017-03-30 15:22:55 +01:00
stupid cat 3356e99781 Fixed undefined variables and string concatenation 2017-03-30 15:22:55 +01:00
stupid cat 9439b9388c More line indents. Frigg, please 2017-03-30 15:22:55 +01:00
stupid cat eb1e56ffd9 Fixed spacing, hopefully lint is happier 2017-03-30 15:22:55 +01:00
stupid cat 3384c32c32 Fixed formatting 2017-03-30 15:22:55 +01:00
stupid cat c4944a4f7c Missed a function rename 2017-03-30 15:22:55 +01:00
stupid cat b163759c7d Fixed some line spacing? 2017-03-30 15:22:55 +01:00
stupid cat 79ecf68ec9 Added IRC users joining/parting/leaving 2017-03-30 15:22:55 +01:00
Martin Ek 1a7ea2d4a2 Merge pull request #204 from Throne3d/add/custom-formatting
Add custom formatting to IRC & Discord output
2017-03-30 09:19:15 -05:00
Edward Jones 9848a89dd6 Simplify substitutePattern 2017-03-29 22:24:07 +01:00
Edward Jones e4a994b996 Move formatting options into a separate 'format' object 2017-03-29 22:22:33 +01:00
Edward Jones b88695eb56 Add tests for custom IRC output, fix to connect in Discord tests 2017-03-29 22:14:57 +01:00
Edward Jones 8e7900c9c5 Split tests into config contexts, add Discord format tests
Also fix an issue in a previous commit whereby Discord
channel names were not prefixed with '#' (despite the
comments suggesting that to be the case).
2017-03-29 22:14:57 +01:00
Edward Jones 60e7d78c6f Refactor custom formatting to use a substitutePattern method 2017-03-29 22:14:57 +01:00
Edward Jones 4599e1731b Add custom formatting to Discord output 2017-03-29 22:14:00 +01:00
Edward Jones b345485366 Add custom output formatting to IRC output 2017-03-29 22:12:25 +01:00
Martin Ek 9915db1585 Merge pull request #205 from rahatarmanahmed/convert-formatting
Convert text styles between IRC/Discord
2017-03-29 15:29:24 -05:00
Rahat Ahmed 200a0b996e Use es6+ features instead of lodash 2017-03-29 14:52:07 -05:00
Martin Ek bc3f51750a Merge pull request #208 from Throne3d/fix/username-mentions
Convert username mentions even if nickname set
2017-03-29 15:25:22 -04:00
Martin Ek 1daf62e5a6 Merge pull request #203 from Throne3d/add/role-mentions
Parse role mentions appropriately, as with channel and user mentions
2017-03-29 15:08:17 -04:00
Martin Ek 8c37393ca6 Merge pull request #202 from Throne3d/add-channelids-tests
Add Discord channel ID matching (PR #187) and tests for it
2017-03-29 15:06:57 -04:00
Martin Ek 25eae441d1 Merge pull request #201 from Throne3d/fix/crash-on-undefined-channel
Make the bot not crash when a channel mentioned by ID fails to exist
2017-03-29 15:05:33 -04:00
Edward Jones 8ef4ba9d44 Convert username mentions even if nickname set 2017-03-27 00:06:46 +01:00
Rahat Ahmed 86fadd5979 Fix IRC to discord formatting nested styles 2017-03-25 14:10:41 -05:00
Rahat Ahmed bc712281b8 Add tests & catch reverse irc format 2017-03-25 13:28:56 -05:00
Rahat Ahmed 336e87e861 Use simple-markdown to format discord to irc 2017-03-25 12:55:48 -05:00
Rahat Ahmed cb35b49e4c Use irc-formatting for irc to discord formatting 2017-03-25 12:22:31 -05:00
Kevin Alberts 0684668c82 Make the leading 0 in the color optional in the regex. 2017-03-25 12:00:15 -05:00
Kevin Alberts 43d5e27ca1 Remove colors from IRC messages sent to Discord, as Discord does not support colorized text. 2017-03-25 12:00:15 -05:00
Kevin Alberts 31042c1eda Added formatting conversions to messages. Text formatting like bold, italics and underlining will now be converted between discord and IRC. 2017-03-25 12:00:15 -05:00
Edward Jones b30c4c34f3 Only translate role mentions from IRC if role is mentionable 2017-03-25 02:15:01 +00:00
Edward Jones 860a4137a7 Add IRC->Discord role mention parsing 2017-03-25 02:15:01 +00:00
Edward Jones a1dfdf65ff Match roles in parseText to display @-roles neatly in IRC 2017-03-25 02:15:01 +00:00
Edward Jones 91bbbad872 Add tests for discord ID mapping 2017-03-25 00:36:47 +00:00
Edward Jones 2ae9e370b6 Update check to look for presence, not equality (order unnecessary) 2017-03-25 00:36:47 +00:00
Edward Jones f882e15b8b Make the bot not crash when mentioned channel fails to exist
If a channel is referenced in Discord, e.g. <#1234>, and the
referenced channel ID does not exist, the bot will presently
crash. This fixes it to display '#deleted-channel', as it
does on the Discord side of the mirror.
2017-03-24 22:01:44 +00:00
Martin Ek 26626e55a5 Merge pull request #198 from reactiflux/doppins/sinon-from-2.0.0-below-3.0.0
[Doppins] Upgrade dependency sinon to ^2.0.0
2017-03-15 08:17:01 -04:00
Doppins a8fe5cb841 Upgrade dependency sinon to ^2.0.0 2017-03-15 06:19:38 +00:00
Martin Ek 7e896addbc 2.2.1 2017-03-12 19:46:42 -04:00
Martin Ek 59f4d7594e Revert "Merge pull request #193 from Sanqui/avoid-highlights"
This reverts commit ebe340b7cb, reversing
changes made to 0f48dfebe8.
2017-03-12 19:45:01 -04:00
Martin Ek a67e94c1a2 2.2.0 2017-03-06 00:30:44 -05:00
Martin Ek 1139f3db47 Remove unused frigg file 2017-03-06 00:29:13 -05:00
Martin Ek ebe340b7cb Merge pull request #193 from Sanqui/avoid-highlights
Avoid self-message highlights on IRC
2017-03-06 00:28:31 -05:00
Sanqui 6bfd774d1c Fix duplicate code in tests escaping the username 2017-03-01 13:37:06 -08:00
Sanqui 8482a5e493 Join the display name on IRC side with zero width spaces 2017-02-26 13:00:49 -08:00
Fiaxhs 2f59cbe2ef Implemented webhooks with matching avatars 2017-02-24 16:43:37 +01:00
mraof b6f53cb241 Apparently there were trailing spaces 2017-02-17 00:52:07 -05:00
mraof 17d27293ef Update bot.js 2017-02-17 00:05:18 -05:00
Doppins 0f48dfebe8 Upgrade dependency winston to 2.3.1 (#183) 2017-02-14 09:37:14 -05:00
mraof b4aef61c79 Fixed errors CI listed 2017-02-03 19:09:06 -05:00
mraof de8aa80b86 Support using discord channel ids 2017-02-03 19:02:37 -05:00
Martin Ek 8de8f4958a Clarify installation instructions in README 2017-01-18 23:57:40 -05:00
Martin Ek f865e46ed7 2.1.7 2017-01-10 16:23:05 -05:00
Doppins d69884e703 [Doppins] Upgrade dependency discord.js to 11.0.0 (#173)
* Upgrade dependency discord.js to 11.0.0

* Fix discord.js 11 breaking changes
2017-01-10 16:21:47 -05:00
Doppins c922d3bec5 Upgrade dependency lodash to 4.17.4 (#175) 2017-01-08 18:24:37 +01:00
Christina Korosec 79b56caae4 Merge pull request #171 from reactiflux/doppins/lodash-equals-4.17.3
[Doppins] Upgrade dependency lodash to 4.17.3
2016-12-31 06:32:24 +01:00
Doppins c3e9fc026a Upgrade dependency lodash to 4.17.3 2016-12-24 14:26:42 +00:00
Martin Ek fe841eac4d Merge pull request #169 from reactiflux/doppins/eslint-config-airbnb-base-from-11.0.0-below-12.0.0
[Doppins] Upgrade dependency eslint-config-airbnb-base to ^11.0.0
2016-12-12 02:28:47 -05:00
Doppins cb6e41889a Upgrade dependency eslint-config-airbnb-base to ^11.0.0 2016-12-12 07:15:37 +00:00
Martin Ek bac7069421 Add a test for irc's registered event and update existing 2016-12-08 23:52:00 -05:00
Martin Ek 4031f9e601 2.1.6 2016-12-08 23:35:55 -05:00
Martin Ek 38e4d3b818 Log info events upon connection, instead of debug 2016-12-08 23:33:28 -05:00
Martin Ek 8a6935c2e5 Listen to warn and debug events from discord 2016-12-08 23:32:31 -05:00
Martin Ek ad2c9747c3 Merge pull request #161 from reactiflux/doppins/irc-equals-0.5.2
[Doppins] Upgrade dependency irc to 0.5.2
2016-11-25 08:56:39 -05:00
Doppins ae71708e9c Upgrade dependency irc to 0.5.2 2016-11-25 08:56:09 +00:00
Christina Korosec 18f201b16f Merge pull request #160 from reactiflux/doppins/nyc-from-10.0.0-below-11.0.0
[Doppins] Upgrade dependency nyc to ^10.0.0
2016-11-22 19:45:15 +01:00
Doppins a5bda5fcfc Upgrade dependency nyc to ^10.0.0 2016-11-22 16:57:39 +00:00
Martin Ek 20c7b99db2 2.1.5 2016-11-17 15:57:35 -05:00
Martin Ek 3667bf1627 Merge remote-tracking branch 'origin/doppins/irc-equals-0.5.1' 2016-11-17 15:57:21 -05:00
Martin Ek cee885b7fe Merge pull request #155 from reactiflux/doppins/lodash-equals-4.17.2
[Doppins] Upgrade dependency lodash to 4.17.2
2016-11-17 15:53:47 -05:00
Doppins 31609e9245 Upgrade dependency irc to 0.5.1 2016-11-17 20:47:54 +00:00
Doppins 0b8ef54831 Upgrade dependency lodash to 4.17.2 2016-11-17 20:47:45 +00:00
Martin Ek 615991a69a Merge pull request #154 from reactiflux/doppins/lodash-equals-4.17.1
[Doppins] Upgrade dependency lodash to 4.17.1
2016-11-16 12:02:07 -05:00
Martin Ek 9727ec6c7b Merge pull request #153 from reactiflux/doppins/nyc-from-9.0.1-below-10.0.0
[Doppins] Upgrade dependency nyc to ^9.0.1
2016-11-16 12:02:02 -05:00
Doppins 7d312ffb26 Upgrade dependency lodash to 4.17.1 2016-11-16 07:22:02 +00:00
Doppins abc34f4049 Upgrade dependency nyc to ^9.0.1 2016-11-15 07:03:47 +00:00
Martin Ek 00527b5e09 2.1.4 2016-11-14 23:19:06 -05:00
Martin Ek fc80b4af0c Merge remote-tracking branch 'origin/doppins/discord.js-equals-10.0.1' 2016-11-14 23:15:08 -05:00
Martin Ek b4d6228ad9 Merge pull request #152 from reactiflux/doppins/lodash-equals-4.17.0
[Doppins] Upgrade dependency lodash to 4.17.0
2016-11-14 23:14:33 -05:00
Doppins 2b82f72476 Upgrade dependency lodash to 4.17.0 2016-11-15 00:13:19 +00:00
Martin Ek e6ee35b2be Merge pull request #151 from reactiflux/doppins/eslint-config-airbnb-base-from-10.0.1-below-11.0.0
[Doppins] Upgrade dependency eslint-config-airbnb-base to ^10.0.1
2016-11-14 12:44:47 -05:00
Martin Ek 29956a8ef1 Merge pull request #150 from reactiflux/doppins/winston-equals-2.3.0
[Doppins] Upgrade dependency winston to 2.3.0
2016-11-14 12:44:43 -05:00
Martin Ek 55dbfa622f Merge pull request #149 from reactiflux/doppins/lodash-equals-4.16.6
[Doppins] Upgrade dependency lodash to 4.16.6
2016-11-14 12:44:38 -05:00
Christina Korosec bb5b9a8719 Mentioning by guild nickname (#147)
* resolves reactiflux/discord-irc#63 nicknames

Use per server nickname instead of username.

* Fix whitespace

* Make server-nicknames pass testing

* Make server-nicknames pass testing (reverted from commit 89da7e09d499e3012416d489bc0a27149f7896c5)

* Stub server.detailsOfUser(username) for tests

* WIP - fix nickname mentions

Not tested yet since I'm not on my development machine

* createServerStub as arrow function

* User mentions from Discord to IRC should also use nicknames

* Allow mentions using server nicknames from IRC

* Yet another mention symbol.

I should consider using a regex at this point... but hotfix

* Correct merge mistakes

* FOSS-1 make nickname mentions work with new API version

* FOSS-1 mention by server-nickname fixed & tests fixed

* FOSS-1 add a test for server nickname mentions

* Test nickname != username when trying to mention by username

Test to make sure you can't mention someone by username if their nickname differs

* Refactor nickname mention code for readability
2016-11-14 12:31:28 -05:00
Doppins 1866a4160a Upgrade dependency eslint-config-airbnb-base to ^10.0.1 2016-11-10 01:54:29 +00:00
Doppins 5168aeaf3a Upgrade dependency winston to 2.3.0 2016-11-10 01:54:20 +00:00
Doppins 0779c64129 Upgrade dependency lodash to 4.16.6 2016-11-10 01:54:12 +00:00
Doppins 406ca0de59 Upgrade dependency discord.js to 10.0.1 2016-11-10 01:54:02 +00:00
Martin Ek 0d75a01ab1 2.1.3 2016-11-02 23:05:38 -04:00
Martin Ek 395213b67c Add filter() to discord-stub's channels 2016-11-02 23:03:46 -04:00
dlacewell c3881be0bb Send text messages only to text discord channels 2016-11-02 23:00:56 -04:00
Martin Ek 007e15cffe Fix readme error 2016-11-02 22:56:49 -04:00
Martin Ek 6da2fed645 Remove license from README (shown in GitHub UI) 2016-11-02 22:55:23 -04:00
Martin Ek ae6ebbe749 Replace frigg with travis/coveralls 2016-11-02 22:54:37 -04:00
Martin Ek e9f53ed68e 2.1.2 2016-11-01 15:41:39 -04:00
Martin Ek 9ceb1418c0 Merge pull request #144 from williamjacksn/patch-1
Use nickname, not username, in command prelude
2016-11-01 15:40:34 -04:00
William Jackson 2fd870fc1b Remove unused variable 2016-11-01 14:29:29 -05:00
William Jackson 7b934e5319 Use nickname, not username, in command prelude 2016-11-01 13:05:15 -05:00
Martin Ek 22d74daf9e 2.1.1 2016-10-21 00:15:45 -04:00
Martin Ek 6f0244949a Make sure attachments are posted to IRC, fixes #141 2016-10-21 00:14:34 -04:00
Martin Ek 479c0b2ced Loosen devDeps and upgrade eslint-plugin-import 2016-10-17 03:34:33 -04:00
Doppins be42399ab8 Upgrade dependency eslint-config-airbnb-base to ^9.0.0 2016-10-17 06:57:41 +00:00
Doppins 9ddd858722 Upgrade dependency mocha to 3.1.2 (#138) 2016-10-16 01:18:27 -04:00
Doppins a17584739b Upgrade dependency mocha to 3.1.1 (#136) 2016-10-10 02:53:58 -04:00
Martin Ek 35f060e1b0 Downgrade eslint-plugin-import to have the correct airbnb peer 2016-10-09 22:06:15 -04:00
Martin Ek 51f0d705e4 2.1.0 2016-10-09 21:10:54 -04:00
Martin Ek 44849df01b Update server nickname code to discord.js v9 2016-10-09 21:04:41 -04:00
Martin Ek 11fd54d76d Simplify server nick logic 2016-10-09 20:43:24 -04:00
Christina Lena Korosec a3b76d04d2 createServerStub as arrow function 2016-10-09 20:43:13 -04:00
Christina Korosec 55d195890d Stub server.detailsOfUser(username) for tests 2016-10-09 20:42:38 -04:00
Christina Korosec 8ea0cbd7bb Make server-nicknames pass testing (reverted from commit 89da7e09d499e3012416d489bc0a27149f7896c5) 2016-10-09 20:41:36 -04:00
Christina Korosec 80e2958329 Make server-nicknames pass testing 2016-10-09 20:41:36 -04:00
Christina Korosec ed2da6f9f6 Fix whitespace 2016-10-09 20:41:36 -04:00
Christina Korosec 29432c35e1 resolves reactiflux/discord-irc#63 nicknames
Use per server nickname instead of username.
2016-10-09 20:41:36 -04:00
Doppins e2a3423b11 Upgrade dependency lodash to 4.16.4 (#131) 2016-10-08 16:45:24 -04:00
Martin Ek 150e57ee6f Add build instructions to readme 2016-10-07 11:51:07 -04:00
Doppins ce56d7dd4d Upgrade dependency lodash to 4.16.3 (#130) 2016-10-03 12:47:37 -04:00
Martin Ek 0ada98223a 2.0.2 2016-10-02 19:38:52 -04:00
Jacob 633b490b23 Display custom emoji's nicely in IRC (#123)
* Display custom emoji's nicely in IRC

* add test for discord emotes

* fix spacing
2016-10-02 19:36:13 -04:00
Doppins add4f05877 Upgrade dependency eslint-plugin-import to ^2.0.0 (#127) 2016-10-02 19:08:28 -04:00
Doppins f197f9d2d5 Upgrade dependency mocha to 3.1.0 (#124) 2016-09-27 12:40:50 -04:00
Doppins 977d8a4a7c Upgrade dependency babel-eslint to ^7.0.0 2016-09-27 12:40:39 -04:00
Doppins bc2e66a654 Upgrade dependency lodash to 4.16.2 (#122) 2016-09-25 23:38:52 -04:00
Martin Ek 68bfe77635 2.0.1 2016-09-25 21:26:14 -04:00
Martin Ek 1aa90830d9 Update engine field 2016-09-25 21:20:09 -04:00
Martin Ek 6eed323c5d 2.0.0 2016-09-25 21:19:34 -04:00
Martin Ek 65e40b3b14 babel-preset-es2015 -> babel-preset-node6 2016-09-25 21:16:33 -04:00
Martin Ek 9e05344374 Migrate to discord.js v9.3 2016-09-25 21:16:28 -04:00
Martin Ek 483798cd54 Use airbnb directly and fix lint errors 2016-09-25 20:36:26 -04:00
Martin Ek 2039577f92 Merge remote-tracking branch 'origin/doppins/eslint-config-airbnb-from-11.1.0-below-12.0.0' 2016-09-20 21:57:14 -04:00
Martin Ek 4201ee76c0 Merge remote-tracking branch 'origin/doppins/nyc-from-8.1.0-below-9.0.0' 2016-09-20 21:56:44 -04:00
Doppins 6ffd5e13da [Doppins] Upgrade dependency lodash to 4.16.1 (#120)
* Upgrade dependency lodash to 4.16.0

* Upgrade dependency lodash to 4.16.1
2016-09-20 21:55:32 -04:00
Martin Ek 6e450c77b9 Merge pull request #119 from reactiflux/doppins/sinon-equals-1.17.6
[Doppins] Upgrade dependency sinon to 1.17.6
2016-09-20 21:55:25 -04:00
Doppins 29cc5a1c55 Upgrade dependency sinon to 1.17.6 2016-09-19 12:32:50 +00:00
Doppins d2b8aee321 Upgrade dependency nyc to ^8.3.0 2016-09-15 17:22:53 +00:00
Doppins 0d858790b8 Upgrade dependency eslint to ^3.5.0 2016-09-13 07:23:24 +00:00
Doppins 56bd19d6e4 Upgrade dependency eslint-config-airbnb to ^11.1.0 2016-09-13 07:23:13 +00:00
Martin Ek 6995a8fa23 1.0.3 2016-09-09 14:32:57 -04:00
Martin Ek 64e515e866 Use discord.js#indev-old
This reverts commit 48a4781cba.
2016-09-09 14:32:18 -04:00
Martin Ek a5a962c308 1.0.2 2016-09-09 00:43:41 -04:00
Martin Ek 48a4781cba Prepend bot tokens with 'Bot', fixes #110 2016-09-09 00:43:28 -04:00
Martin Ek e585270512 Merge pull request #105 from reactiflux/doppins/mocha-equals-3.0.2
[Doppins] Upgrade dependency mocha to 3.0.2
2016-08-20 23:39:15 +02:00
Martin Ek 8f876e3970 Merge pull request #104 from reactiflux/doppins/lodash-equals-4.15.0
[Doppins] Upgrade dependency lodash to 4.15.0
2016-08-20 23:38:57 +02:00
Doppins e94e506d91 Upgrade dependency nyc to ^8.1.0 2016-08-19 14:52:21 +00:00
Doppins a6271c02a6 Upgrade dependency mocha to 3.0.2 2016-08-19 14:51:50 +00:00
Doppins e0b2e4c9b1 Upgrade dependency lodash to 4.15.0 2016-08-19 14:51:22 +00:00
Martin Ek cb0a8b128a Merge pull request #96 from reactiflux/doppins/discord.js-equals-8.1.0
[Doppins] Upgrade dependency discord.js to 8.1.0
2016-08-12 22:53:43 +02:00
Doppins d0ded9a4e2 [Doppins] Upgrade dependency mocha to 3.0.1 (#93)
* Upgrade dependency mocha to 3.0.0

* Upgrade dependency mocha to 3.0.1
2016-08-08 00:54:55 +02:00
Doppins df04ee1b2e Upgrade dependency sinon to 1.17.5 (#90) 2016-08-08 00:54:49 +02:00
Doppins 50e8a434f7 [Doppins] Upgrade dependency lodash to 4.14.1 (#88)
* Upgrade dependency lodash to 4.14.0

* Upgrade dependency lodash to 4.14.1
2016-08-08 00:54:45 +02:00
Doppins a5ba794865 Upgrade dependency discord.js to 8.1.0 2016-08-04 20:35:51 +00:00
Martin Ek a3be583ccd Merge pull request #83 from reactiflux/doppins/nyc-from-7.0.0-below-8.0.0
[Doppins] Upgrade dependency nyc to ^7.0.0
2016-07-19 23:48:10 +02:00
Doppins 7d8415fb3a Upgrade dependency nyc to ^7.0.0 2016-07-10 12:44:42 +00:00
GinjaNinja32 bdfe3affcc Fix pings to users with nicknames showing as raw user IDs in IRC (#81)
* Fix pings to users with nicknames showing as raw user IDs in IRC

* Add test for user nickname mentions
2016-06-29 09:15:20 +02:00
Martin Ek 6d0dd1e404 1.0.1 2016-06-19 14:42:42 +02:00
Martin Ek a185d9aecc Merge remote-tracking branch 'origin/doppins/discord.js-equals-8.0.0' 2016-06-19 14:22:05 +02:00
Martin Ek 6f9ec0744f Merge remote-tracking branch 'origin/doppins/eslint-config-airbnb-from-8.0.0-below-9.0.0' 2016-06-19 14:21:51 +02:00
Doppins 007d6ceb99 [Doppins] Upgrade dependency mocha to 2.5.3 (#72)
* Upgrade dependency mocha to 2.5.2

* Upgrade dependency mocha to 2.5.3
2016-06-19 14:02:58 +02:00
Doppins c5e47bb4aa Upgrade dependency lodash to 4.13.1 (#71) 2016-06-19 14:02:51 +02:00
Doppins 064a333214 Upgrade dependency discord.js to 8.0.0 2016-06-09 02:42:43 +00:00
Doppins 36908e6865 Upgrade dependency lodash to 4.13.0 (#69) 2016-05-23 11:48:52 +02:00
Doppins 486003ee9f [Doppins] Upgrade dependency mocha to 2.5.1 (#70)
* Upgrade dependency mocha to 2.5.0

* Upgrade dependency mocha to 2.5.1
2016-05-23 11:48:31 +02:00
Doppins 770a0052a1 Upgrade dependency lodash to 4.12.0 (#66) 2016-05-12 01:34:41 +02:00
Doppins 14cc47f160 Upgrade dependency eslint-config-airbnb to ^9.0.1 2016-05-09 16:01:00 +00:00
Doppins 7e39e80001 Upgrade dependency eslint-config-airbnb to ^9.0.0 2016-05-07 18:08:35 +00:00
Martin Ek d3c3ccd27e Update license year 2016-05-06 16:44:12 +02:00
Martin Ek 5ffb103df2 Update readme and add changelog entry for 1.0.0
1.0.0
2016-05-06 16:42:06 +02:00
Benjamin Hoffmeyer 59d42e18af Use Discord's Bot Token instead of email/password (#61)
* Convert discordemail to token

* Update fixtures with new format

* Update README with instructions for making a discord bot.

* Update the stub to loginWithToken
Now I know why they are there.

* Remove the npm run build line
Its no longer needed since npm install calls npm build

* Forgot a qoute in the sample config -_-

* I didn't change all fixtures to use loginWithToken
2016-05-06 16:40:04 +02:00
Martin Ek 14d8015f8a Merge pull request #65 from reactiflux/doppins/sinon-equals-1.17.4
[Doppins] Upgrade dependency sinon to 1.17.4
2016-05-06 16:30:17 +02:00
Martin Ek 1538089f33 Merge pull request #64 from reactiflux/doppins/lodash-equals-4.11.2
[Doppins] Upgrade dependency lodash to 4.11.2
2016-05-06 16:30:09 +02:00
Doppins 7d67f6406c Upgrade dependency sinon to 1.17.4 2016-05-03 02:15:01 +00:00
Doppins 4634696ed9 Upgrade dependency lodash to 4.11.2 2016-05-02 16:00:45 +00:00
Doppins 56b280933a Upgrade dependency eslint-config-airbnb to ^8.0.0 2016-04-22 16:00:36 +00:00
Martin Ek 8a44fde1d3 0.8.2 2016-04-21 04:43:11 +02:00
Martin Ek b295e494b3 Enable auto reconnect for IRC and Discord 2016-04-21 04:42:37 +02:00
Martin Ek 6205e77f2c 0.8.1 2016-04-21 04:34:10 +02:00
Doppins 17e973ec40 Upgrade dependency discord.js to 7.0.1 2016-04-21 04:34:08 +02:00
Doppins e657317daa [Doppins] Upgrade dependency lodash to 4.11.1
* Upgrade dependency lodash to 4.11.0

* Upgrade dependency lodash to 4.11.1
2016-04-14 09:34:22 +02:00
Martin Ek fec2eacd1f Merge pull request #52 from reactiflux/doppins/eslint-config-airbnb-from-7.0.0-below-8.0.0
[Doppins] Upgrade dependency eslint-config-airbnb to ^7.0.0
2016-04-12 12:17:23 +02:00
Doppins 9d75cbcdaf Upgrade dependency eslint-config-airbnb to ^7.0.0 2016-04-12 02:23:53 +00:00
Martin Ek d53efaa8fe Merge pull request #51 from reactiflux/doppins/lodash-equals-4.10.0
[Doppins] Upgrade dependency lodash to 4.10.0
2016-04-12 01:34:07 +02:00
Doppins aa61b84d7d Upgrade dependency lodash to 4.10.0 2016-04-11 16:00:53 +00:00
Martin Ek a5221cc7d1 Merge pull request #50 from reactiflux/doppins/lodash-equals-4.9.0
[Doppins] Upgrade dependency lodash to 4.9.0
2016-04-08 18:42:45 +02:00
Doppins 9362083421 Upgrade dependency lodash to 4.9.0 2016-04-08 16:00:35 +00:00
Martin Ek 53d1ef0b6a Merge pull request #49 from reactiflux/doppins/lodash-equals-4.8.2
[Doppins] Upgrade dependency lodash to 4.8.2
2016-04-05 18:05:29 +02:00
Doppins 409835c12a Upgrade dependency lodash to 4.8.2 2016-04-05 16:00:38 +00:00
38 changed files with 9339 additions and 347 deletions
+17 -1
View File
@@ -1,3 +1,19 @@
{
"presets": ["es2015", "stage-0"]
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "12"
}
}
]
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}
+20
View File
@@ -0,0 +1,20 @@
.git
# Coverage directory used by tools like istanbul
coverage
.nyc_output
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
# Environment variables and configuration
.env
.environment
config.json
# Build
dist/
+13 -5
View File
@@ -1,11 +1,19 @@
{
"extends": "webkom",
"parser": "babel-eslint",
"rules": {
"spaced-comment": 0 // disable because of she-bang bug in index.js
},
"extends": "airbnb-base",
"parser": "@babel/eslint-parser",
"env": {
"mocha": true,
"node": true
},
"rules": {
"arrow-parens": 0,
"global-require": 0,
"comma-dangle": 0,
"func-names": 0,
"import/no-extraneous-dependencies": [2, { "devDependencies": true }],
"import/prefer-default-export": 0,
"import/no-dynamic-require": 0,
"operator-linebreak": 0,
"implicit-arrow-linebreak": 0
}
}
-8
View File
@@ -1,8 +0,0 @@
tasks:
- npm install
- npm run lint
- npm run coverage
coverage:
path: coverage/cobertura-coverage.xml
parser: cobertura
+26
View File
@@ -0,0 +1,26 @@
# This workflow will build the project's Dockerfile and publish images to Docker Hub
# For more information see: https://docs.github.com/en/actions/language-and-framework-guides/publishing-docker-images
name: Publish Docker image
on:
push:
branches: [ main ]
release:
types: [ published ]
jobs:
push_to_registry:
name: Publish to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and push to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: discordirc/discord-irc
tag_with_ref: true
tag_with_sha: true
+49
View File
@@ -0,0 +1,49 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 15.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
- run: npm run save-coverage
- name: Report to Coveralls (parallel)
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.node-version }}
parallel: true
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Report to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "@istanbuljs/nyc-config-babel"
}
-5
View File
@@ -1,5 +0,0 @@
language: node_js
node_js:
- '0.12'
- '4'
- '5'
+300
View File
@@ -1,6 +1,306 @@
# Changelog
This project adheres to [Semantic Versioning](http://semver.org/).
## [2.9.0] - 2020-10-03
This release comes with a (relatively large) change to use discord.js v12!
There were a lot of breaking changes in the upstream library, including removal of support for Node <12, which prompted a 2.9.0-alpha release before this main version.
Everything seemed to go fine, which is why you're now receiving this latest update!
### Added
* IRC nick colors are now customizable in the config (thanks to [KWeaver87](https://github.com/reactiflux/discord-irc/pull/561))
### Changed
* Upgrade discord.js to 12.3.1 (the pre-release came with 12.2.0) - this changes a lot of how the bot works behind the scenes, and prepares us for upcoming Discord API changes - [#555](https://github.com/reactiflux/discord-irc/pull/555), [#564](https://github.com/reactiflux/discord-irc/pull/564)
* Add support for Node 14 ([#549](https://github.com/reactiflux/discord-irc/pull/549)); drop support for Node 6, 8 and 10 ([#550](https://github.com/reactiflux/discord-irc/pull/550))
### Fixed
* A bunch of vulnerabilities listed in `npm audit` are now gone - [#544](https://github.com/reactiflux/discord-irc/pull/544), [#548](https://github.com/reactiflux/discord-irc/pull/548), [#551](https://github.com/reactiflux/discord-irc/pull/551), [#552](https://github.com/reactiflux/discord-irc/pull/552), [#553](https://github.com/reactiflux/discord-irc/pull/553), [#562](https://github.com/reactiflux/discord-irc/pull/562)
* Log messages now typically take up one line again (fixing a relatively long-standing bug, at this point – oops!) - [#554](https://github.com/reactiflux/discord-irc/pull/554)
* Mentioning the same user more than once in a single message is now fixed (thanks to [Qyriad](https://github.com/reactiflux/discord-irc/pull/541))
* Our Discord client now uses a retry limit of 3 (rather than 1) on internal server errors (hopefully fixing [#461](https://github.com/reactiflux/discord-irc/issues/461)) - [#565](https://github.com/reactiflux/discord-irc/pull/565)
## [2.8.1] - 2020-03-16
### Fixed
* Large avatars failed to display when bridging through webhooks - (thanks to [Miosame](https://github.com/reactiflux/discord-irc/pull/511), follow up in [#530](https://github.com/reactiflux/discord-irc/pull/530))
* Update acorn to 7.1.1 - [#534](https://github.com/reactiflux/discord-irc/pull/534)
* Remove code coverage instrumentation from `dist/` files - [#536](https://github.com/reactiflux/discord-irc/pull/536)
## [2.8.0] - 2019-12-14
### Added
* `format.webhookAvatarURL`, to customize the unrecognized user webhook avatar (thanks to [Geo1088](https://github.com/reactiflux/discord-irc/pull/419))
* `parallelPingFix`, disabled by default, to prevent users of both Discord and IRC getting pings whenever their messages are mirrored to IRC (thanks to [qaisjp](https://github.com/reactiflux/discord-irc/pull/243) originally, follow up in [#502](https://github.com/reactiflux/discord-irc/pull/502) and [#520](https://github.com/reactiflux/discord-irc/pull/520))
* `ignoreUsers.discordIds`, to ignore specific Discord users through the bridge by ID instead of name (thanks to [nsavch](https://github.com/reactiflux/discord-irc/pull/508))
* A basic Docker image, found at [discordirc/discord-irc](https://hub.docker.com/r/discordirc/discord-irc)! This may not be often updated with the release tags we publish on GitHub, but it should contain a `latest` tag in addition to whichever Git hash is available on main (thanks to [gdude2002](https://github.com/reactiflux/discord-irc/pull/421), follow up in [#498](https://github.com/reactiflux/discord-irc/pull/498))
### Changed
* Add support for Node 13, drop testing for Node 6 - [#521](https://github.com/reactiflux/discord-irc/pull/521)
### Fixed
* Upgrade various dependencies: babel, commander, coveralls, discord.js, eslint, mocha, simple-markdown, sinon, sinon-chai - [#488](https://github.com/reactiflux/discord-irc/pull/488), [#503](https://github.com/reactiflux/discord-irc/pull/503), [#522](https://github.com/reactiflux/discord-irc/pull/522), [#523](https://github.com/reactiflux/discord-irc/pull/523), [#524](https://github.com/reactiflux/discord-irc/pull/524/files), [#525](https://github.com/reactiflux/discord-irc/pull/525)
## [2.7.2] - 2019-08-08
### Fixed
* Defer to discord permissions for allowing `@everyone` and `@here` in webhook messages - [#497](https://github.com/reactiflux/discord-irc/pull/497)
* Support Node 10 and 12 - [#499](https://github.com/reactiflux/discord-irc/pull/499)
* Upgrade dependencies
* Tests: Fix lint config deprecation - [#500](https://github.com/reactiflux/discord-irc/pull/500)
* Tests: Ensure all tests are run in dev environment - [#501](https://github.com/reactiflux/discord-irc/pull/501)
## [2.7.1] - 2019-06-15
### Changed
* Upgraded dependencies.
## [2.7.0] - 2019-04-02
### Changed
* Convert channel mentions to codified mentions (thanks to [Throne3d](https://github.com/reactiflux/discord-irc/pull/476)).
* Match IRC style mentions at the beginning of message (thanks to [rdb](https://github.com/reactiflux/discord-irc/pull/470)).
* Upgraded dependencies.
## [2.6.2] - 2018-09-19
### Changed
* Upgraded dependencies.
## [2.6.1] - 2018-05-11
### Changed
* Upgraded dependencies.
## [2.6.0] - 2018-03-22
### Added
* Support for posting messages to Discord using webhooks (thanks to
[Fiaxhs](https://github.com/reactiflux/discord-irc/pull/230)!).
Webhooks lets you override nicknames and avatars, so messages coming from IRC
can appear as regular Discord messages:
![discord-webhook](http://i.imgur.com/lNeJIUI.jpg)
To enable webhooks, follow part 1 of [this
guide](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
to create and retrieve a webhook URL for a specific channel, then enable it in
discord-irc's config as follows:
```json
"webhooks": {
"#discord-channel": "https://discord.com/api/webhooks/id/token"
}
```
## [2.5.1] - 2018-01-18
### Fixed
* Upgraded dependencies.
## [2.5.0] - 2017-10-27
### Added
* Support multi-character command prefixes - [#301](https://github.com/reactiflux/discord-irc/pull/301)
* Enable auto-renicking by default, so the bot tries to get the target nickname after it fails - [#302](https://github.com/reactiflux/discord-irc/pull/302)
* Add the ability to ignore IRC/Discord users by nickname - [#322](https://github.com/reactiflux/discord-irc/pull/322)
### Fixed
* Improve IRC → Discord mentions around non-word characters and nickname prefix matches - [#273](https://github.com/reactiflux/discord-irc/pull/273)
* Default to UTF-8 encoding when bridging messages to prevent character corruption - [#315](https://github.com/reactiflux/discord-irc/pull/315)
* Fix a crash when using the bot in a group DM - [#316](https://github.com/reactiflux/discord-irc/pull/316)
* Use a `prepare` script for transpiling instead of `prepublish`, fixing `npm` installation direct from the GitHub repository - [#323](https://github.com/reactiflux/discord-irc/pull/323)
* Update dependencies:
- discord.js to 11.2.1
- sinon to ^4.0.1
- irc-upd to 0.8.0 - [#313](https://github.com/reactiflux/discord-irc/pull/313)
- simple-markdown to ^0.3.1
- coveralls to ^3.0.0
- mocha to ^4.0.0
- winston to 2.4.0
### Changed
* Add a link to the IRC spec in the README - [#307](https://github.com/reactiflux/discord-irc/pull/307)
* Drop testing for Node 7, add testing for Node 8 - [#329](https://github.com/reactiflux/discord-irc/pull/329)
## [2.4.2] - 2017-08-21
### Fixed
* Tests: Use globbing instead of `find` so tests work on Windows - [#279](https://github.com/reactiflux/discord-irc/pull/279)
### Changed
* Update dependency irc-upd to [0.7.0](https://github.com/Throne3d/node-irc/releases/tag/v0.7.0) - [#284](https://github.com/reactiflux/discord-irc/pull/284)
* Tests: Use Discord objects to simplify code - [#272](https://github.com/reactiflux/discord-irc/pull/272)
## [2.4.1] - 2017-07-16
### Added
* Falsy command preludes are no longer sent (previously would choose default prelude) - [#260](https://github.com/reactiflux/discord-irc/pull/260)
### Fixed
* Update link to IRC library in README so it points to the new irc-upd library - [#264](https://github.com/reactiflux/discord-irc/pull/264)
* Update dependency commander to 2.11.0 - [#262](https://github.com/reactiflux/discord-irc/pull/262)
* Fix deprecation warning on `TextChannel#sendMessage` - [#267](https://github.com/reactiflux/discord-irc/pull/267)
* Fix reconnection by updating dependency irc-upd to 0.6.2 - [#270](https://github.com/reactiflux/discord-irc/pull/270)
## [2.4.0] - 2017-07-01
This project now uses [irc-upd](https://github.com/Throne3d/node-irc) as a dependency, instead of the old [irc](https://github.com/martynsmith/node-irc) package – this fork should be better maintained and will solve some bugs, detailed below.
### Added
* Allow commandCharacters to work for messages sent to Discord - [#221](https://github.com/reactiflux/discord-irc/pull/221).
* Send nick changes from IRC to Discord with `ircStatusNotices` - [#235](https://github.com/reactiflux/discord-irc/pull/235), [#241](https://github.com/reactiflux/discord-irc/pull/241).
* Translate custom emoji references from IRC to Discord - [#256](https://github.com/reactiflux/discord-irc/pull/256).
### Fixed
* Use `ircClient.nick` instead of `nickname` when checking if the `ircStatusNotices` event is for the bot, to prevent a potential crash - [#257](https://github.com/reactiflux/discord-irc/pull/257).
* Use the updated `irc-upd` library instead of `irc`, causing IRC messages to now be split by byte instead of character (fixing [#199](https://github.com/reactiflux/discord-irc/issues/199)) and adding support for certain Unicode characters in nicknames (fixing [#200](https://github.com/reactiflux/discord-irc/issues/200)) - [#258](https://github.com/reactiflux/discord-irc/pull/258).
* Update dependencies:
- discord.js to 11.1.0
- check-env to 1.3.0
- chai to ^4.0.2
- nyc to ^11.0.3
- commander to 2.10.0
- eslint to ^4.1.1
## [2.3.3] - 2017-04-29
### Fixed
* Warn if a part/quit is received and no channelUsers is set -
[#218](https://github.com/reactiflux/discord-irc/pull/218).
## [2.3.2] - 2017-04-27
### Fixed
* Fix ircStatucNotices when channels are not lowercase -
[#219](https://github.com/reactiflux/discord-irc/pull/219).
## [2.3.1] - 2017-04-05
### Fixed
* Fix IRC quit messages sending to all channels by tracking users - [#214](https://github.com/reactiflux/discord-irc/pull/214#pullrequestreview-31156291).
## [2.3.0] - 2017-04-03
A huge thank you to [@Throne3d](https://github.com/Throne3d),
[@rahatarmanahmed](https://github.com/rahatarmanahmed), [@mraof](https://github.com/mraof)
and [@Ratismal](https://github.com/Ratismal) for all the fixes and features
in this release.
### Added
* Bridge IRC join/part/quit messages to Discord
(enable by setting ircStatusNotices to true) -
[#207](https://github.com/reactiflux/discord-irc/pull/207).
* Convert text styles between IRC and Discord
[#205](https://github.com/reactiflux/discord-irc/pull/205).
* Allow users to configure the patterns of messages on
IRC and Discord using the format options object
[#204](https://github.com/reactiflux/discord-irc/pull/204).
* Add Discord channel ID matching to the channel mapping
[#202](https://github.com/reactiflux/discord-irc/pull/202).
### Fixed
* Parse role mentions appropriately, as with channel and user mentions
[#203](https://github.com/reactiflux/discord-irc/pull/203).
* Make the bot not crash when a channel mentioned by ID fails to exist
[#201](https://github.com/reactiflux/discord-irc/pull/201).
### Changed
* Convert username mentions even if nickname is set -
[#208](https://github.com/reactiflux/discord-irc/pull/208).
## [2.2.1] - 2017-03-12
### Fixed
* Reverts the changes in 2.2.0 due to incompatibilities with different clients.
See https://github.com/reactiflux/discord-irc/issues/196 for more
information.
## [2.2.0] - 2017-03-06
### Fixed
* Added a zero width character between each letter of the IRC nicknames, to
avoid unwanted highlights. Fixed by @Sanqui in
[#193](https://github.com/reactiflux/discord-irc/pull/193).
## [2.1.6] - 2017-01-10
### Fixed
* Upgraded discord.js.
## [2.1.6] - 2016-12-08
### Fixed
* Listen to warn events from Discord.
* Listen to debug events from Discord (only in development).
* Log info events upon connection, instead of debug
## [2.1.5] - 2016-11-17
### Fixed
* Upgraded node-irc to 0.5.1, fixing #129.
## [2.1.4] - 2016-11-14
### Fixed
* Added support for highlighting users by their nicknames,
thanks to @DarkSpyro003.
* Upgraded to discord.js v10.
## [2.1.3] - 2016-11-02
### Fixed
* Send text messages only to text channels (thanks @dustinlacewell).
## [2.1.2] - 2016-11-01
### Fixed
* Use nickname, not username, in command prelude.
Thanks to @williamjacksn.
## [2.1.1] - 2016-10-21
### Fixed
* A bug where Discord attachment URLs weren't posted to IRC, thanks to @LordAlderaan for the report.
## [2.1.0] - 2016-10-09
### Added
* Messages sent to IRC will now use the correct server nickname,
instead of the user's global username (thanks to @DarkSpyro003).
## [2.0.2] - 2016-10-02
### Fixed
- Display custom emojis correctly, thanks to @macdja38.
## [2.0.0] - 2016-09-25
### Fixed
- Upgrade to version 9.3 of discord.js.
This removes support for Node.js versions older than v6,
as that's the oldest discord.js supports.
## [1.0.3] - 2016-09-09
### Fixed
- Replace changes in 1.0.2 with the #indev-old version
of discord.js.
## [1.0.2] - 2016-09-09
### Fixed
- Discord's API now requires bot tokens
to be prefixed with "Bot". This adds
a hotfix that does exactly that.
## [1.0.1] - 2016-06-19
### Fixed
- Upgraded dependencies.
## [1.0.0] - 2016-05-06
### Changed
- Breaking: discord-irc now uses tokens for authentication, instead of
email/password, thanks to @TheDoctorsLife. See the README for more instructions.
## [0.8.2] - 2016-04-21
### Fixed
- Enable auto reconnect for IRC and Discord.
## [0.8.1] - 2016-04-21
### Fixed
- Upgrade discord.js to 7.0.1.
## [0.8.0] - 2016-04-04
Implemented by @rce:
### Added
+15
View File
@@ -0,0 +1,15 @@
FROM node:12-alpine
ENV LIBRARY_PATH=/lib:/usr/lib
RUN mkdir /bot
COPY . /bot
WORKDIR /bot
RUN apk add --update tini && \
npm install && \
npm run build && \
mkdir /config
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["npm", "start", "--", "--config", "/config/config.json"]
+1 -1
View File
@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 Martin Ek mail@ekmartin.no
Copyright (c) 2016 Martin Ek mail@ekmartin.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+2
View File
@@ -0,0 +1,2 @@
build:
docker-compose -f docker-compose.yml up -d --build --remove-orphans
+94 -31
View File
@@ -1,14 +1,22 @@
# discord-irc [![Build status](https://ci.frigg.io/badges/reactiflux/discord-irc/)](https://ci.frigg.io/reactiflux/discord-irc/last/) [![Coverage status](https://ci.frigg.io/badges/coverage/reactiflux/discord-irc/)](https://ci.frigg.io/reactiflux/discord-irc/last/)
[![Coverage Status](https://coveralls.io/repos/github/reactiflux/discord-irc/badge.svg?branch=main)](https://coveralls.io/github/reactiflux/discord-irc?branch=main)
> Connects [Discord](https://discordapp.com/) and IRC channels by sending messages back and forth.
A mostly feature complete port of [slack-irc](https://github.com/ekmartin/slack-irc).
> Connects [Discord](https://discord.com/) and [IRC](https://www.ietf.org/rfc/rfc1459.txt) channels by sending messages back and forth.
## Example
![discord-irc](http://i.imgur.com/oI6iCrf.gif)
## Installation and usage
Either by installing through npm:
**Note**: discord-irc requires Node.js version 12 or newer, as it depends on [discord.js](https://github.com/hydrabolt/discord.js).
Future versions may require newer Node.js versions, though we should support active releases.
Before you can run discord-irc you need to create a configuration file by
following the instructions [here](https://github.com/reactiflux/discord-irc#configuration).
After you've done that you can replace `/path/to/config.json` in the commands
below with the path to your newly created configuration file - or just `config.json` if it's
in the same directory as the one you're starting the bot from.
When you've done that you can install and start the bot either through npm:
```bash
$ npm install -g discord-irc
$ discord-irc --config /path/to/config.json
@@ -19,7 +27,7 @@ or by cloning the repository:
```bash
In the repository folder:
$ npm install
$ npm run build # Transpile ES6 to ES5 using Babel
$ npm run build
$ npm start -- --config /path/to/config.json # Note the extra double dash
```
@@ -30,8 +38,26 @@ import config from './config.json';
discordIRC(config);
```
## Docker
As an alternative to running discord-irc directly on your machine, we provide a [Docker container image](https://hub.docker.com/r/discordirc/discord-irc).
After creating a configuration file, you can fetch the image from Docker Hub and run it with the following command:
```bash
docker run -v /path/to/config:/config/config.json discordirc/discord-irc
```
If you've checked out the repository already, you can build the Docker image locally and run that instead:
```bash
docker build -t discord-irc .
docker run -v /path/to/config:/config/config.json discord-irc
```
Note that the path to the config file on the host (`/path/to/config`) _must_ be a valid absolute path to a config file.
Otherwise, you may get the error "illegal operation on a directory".
## Configuration
Create a discord user and join the server you want to connect to IRC.
First you need to create a Discord bot user, which you can do by following the instructions [here](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token).
### Example configuration
```js
@@ -40,8 +66,7 @@ Create a discord user and join the server you want to connect to IRC.
{
"nickname": "test2",
"server": "irc.testbot.org",
"discordEmail": "user@mail.com",
"discordPassword": "letmein123",
"discordToken": "botwantsin123",
"channelMapping": {
"#other-discord": "#new-irc-channel"
}
@@ -51,29 +76,82 @@ Create a discord user and join the server you want to connect to IRC.
{
"nickname": "test",
"server": "irc.bottest.org",
"discordEmail": "user@mail.com",
"discordPassword": "letmein123",
"discordToken": "botwantsin123",
"autoSendCommands": [ // Commands that will be sent on connect
["PRIVMSG", "NickServ", "IDENTIFY password"],
["MODE", "test", "+x"],
["AUTH", "test", "password"]
],
"channelMapping": { // Maps each Discord-channel to an IRC-channel, used to direct messages to the correct place
"#discord": "#irc channel-password" // Add channel keys after the channel name
"#discord": "#irc channel-password", // Add channel keys after the channel name
"1234567890": "#channel" // Use a discord channel ID instead of its name (so you can rename it or to disambiguate)
},
"ircOptions": { // Optional node-irc options
"floodProtection": false, // On by default
"floodProtectionDelay": 1000 // 500 by default
"floodProtectionDelay": 1000, // 500 by default
"port": "6697", // 6697 by default
"secure": true, // enable SSL, false by default
"sasl": true, // false by default
"username": "test", // nodeirc by default
"password": "p455w0rd" // empty by default
},
"format": { // Optional custom formatting options
// Patterns, represented by {$patternName}, are replaced when sending messages
"commandPrelude": "Command sent by {$nickname}", // Message sent before a command
"ircText": "<{$displayUsername}> {$text}", // When sending a message to IRC
"urlAttachment": "<{$displayUsername}> {$attachmentURL}", // When sending a Discord attachment to IRC
"discord": "**<{$author}>** {$withMentions}", // When sending a message to Discord
// Other patterns that can be used:
// {$discordChannel} (e.g. #general)
// {$ircChannel} (e.g. #irc)
"webhookAvatarURL": "https://robohash.org/{$nickname}" // Default avatar to use for webhook messages
},
"ircNickColor": false, // Gives usernames a color in IRC for better readability (on by default)
"ircNickColors": ['light_blue', 'dark_blue', 'light_red', 'dark_red', 'light_green', 'dark_green', 'magenta', 'light_magenta', 'orange', 'yellow', 'cyan', 'light_cyan'], // Which irc-upd colors to use
"parallelPingFix": true, // Prevents users of both IRC and Discord from being mentioned in IRC when they speak in Discord (off by default)
// Makes the bot hide the username prefix for messages that start
// with one of these characters (commands):
"commandCharacters": ["!", "."]
"commandCharacters": ["!", "."],
"ircStatusNotices": true, // Enables notifications in Discord when people join/part in the relevant IRC channel
"ignoreUsers": {
"irc": ["irc_nick1", "irc_nick2"], // Ignore specified IRC nicks and do not send their messages to Discord.
"discord": ["discord_nick1", "discord_nick2"], // Ignore specified Discord nicks and do not send their messages to IRC.
"discordIds": ["198528216523210752"] // Ignore specified Discord ids and do not send their messages to IRC.
},
// List of webhooks per channel
"webhooks": {
"#discord": "https://discord.com/api/webhooks/id/token"
}
}
]
```
The `ircOptions` object is passed directly to node-irc ([available options](http://node-irc.readthedocs.org/en/latest/API.html#irc.Client)).
The `ircOptions` object is passed directly to irc-upd ([available options](https://node-irc-upd.readthedocs.io/en/latest/API.html#irc.Client)).
To retrieve a discord channel ID, write `\#channel` on the relevant server – it should produce something of the form `<#1234567890>`, which you can then use in the `channelMapping` config.
### Webhooks
Webhooks lets you override nicknames and avatars, so messages coming from IRC
can appear as regular Discord messages:
![discord-webhook](http://i.imgur.com/lNeJIUI.jpg)
To enable webhooks, follow part 1 of [this
guide](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
to create and retrieve a webhook URL for a specific channel, then enable it in
discord-irc's config as follows:
```json
"webhooks": {
"#discord-channel": "https://discord.com/api/webhooks/id/token"
}
```
### Encodings
If you encounter trouble with some characters being corrupted from some clients (particularly umlauted characters, such as `ä` or `ö`), try installing the optional dependencies `iconv` and `node-icu-charset-detector`.
The bot will produce a warning when started if the IRC library is unable to convert between encodings.
Further information can be found in [the installation section of irc-upd](https://github.com/Throne3d/node-irc#character-set-detection).
## Tests
Run the tests with:
@@ -82,24 +160,9 @@ $ npm test
```
## Style Guide
discord-irc uses a slightly modified version of the
[Airbnb Style Guide](https://github.com/airbnb/javascript/tree/master/es5).
discord-irc follows the [Airbnb Style Guide](https://github.com/airbnb/javascript).
[ESLint](http://eslint.org/) is used to make sure this is followed correctly, which can be run with:
```bash
$ npm run lint
```
The deviations from the Airbnb Style Guide can be seen in the [.eslintrc](.eslintrc) file.
## License
(The MIT License)
Copyright (c) 2015 Martin Ek <mail@ekmartin.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+10
View File
@@ -0,0 +1,10 @@
version: "3.9"
services:
discord-irc:
image: discord-irc
restart: unless-stopped
build:
context: .
dockerfile: ./Dockerfile
volumes:
- ./config:/config/config.json
+483 -51
View File
@@ -1,13 +1,19 @@
import _ from 'lodash';
import irc from 'irc';
import logger from 'winston';
import irc from 'irc-upd';
import discord from 'discord.js';
import logger from './logger';
import { ConfigurationError } from './errors';
import { validateChannelMapping } from './validators';
import { formatFromDiscordToIRC, formatFromIRCToDiscord } from './formatting';
const REQUIRED_FIELDS = ['server', 'nickname', 'channelMapping', 'discordEmail', 'discordPassword'];
const NICK_COLORS = ['light_blue', 'dark_blue', 'light_red', 'dark_red', 'light_green',
// Usernames need to be between 2 and 32 characters for webhooks:
const USERNAME_MIN_LENGTH = 2;
const USERNAME_MAX_LENGTH = 32;
const REQUIRED_FIELDS = ['server', 'nickname', 'channelMapping', 'discordToken'];
const DEFAULT_NICK_COLORS = ['light_blue', 'dark_blue', 'light_red', 'dark_red', 'light_green',
'dark_green', 'magenta', 'light_magenta', 'orange', 'yellow', 'cyan', 'light_cyan'];
const patternMatch = /{\$(.+?)}/g;
/**
* An IRC bot, works as a middleman for all communication
@@ -15,7 +21,7 @@ const NICK_COLORS = ['light_blue', 'dark_blue', 'light_red', 'dark_red', 'light_
*/
class Bot {
constructor(options) {
REQUIRED_FIELDS.forEach(field => {
REQUIRED_FIELDS.forEach((field) => {
if (!options[field]) {
throw new ConfigurationError(`Missing configuration field ${field}`);
}
@@ -23,18 +29,64 @@ class Bot {
validateChannelMapping(options.channelMapping);
this.discord = new discord.Client();
this.discord = new discord.Client({
autoReconnect: true,
retryLimit: 3,
});
this.server = options.server;
this.nickname = options.nickname;
this.ircOptions = options.ircOptions;
this.discordEmail = options.discordEmail;
this.discordPassword = options.discordPassword;
this.discordToken = options.discordToken;
this.commandCharacters = options.commandCharacters || [];
this.ircNickColor = options.ircNickColor !== false; // default to true
this.ircNickColors = options.ircNickColors || DEFAULT_NICK_COLORS;
this.parallelPingFix = options.parallelPingFix === true; // default: false
this.channels = _.values(options.channelMapping);
this.ircStatusNotices = options.ircStatusNotices;
this.announceSelfJoin = options.announceSelfJoin;
this.webhookOptions = options.webhooks;
// Nicks to ignore
this.ignoreUsers = options.ignoreUsers || {};
this.ignoreUsers.irc = this.ignoreUsers.irc || [];
this.ignoreUsers.discord = this.ignoreUsers.discord || [];
this.ignoreUsers.discordIds = this.ignoreUsers.discordIds || [];
// "{$keyName}" => "variableValue"
// author/nickname: nickname of the user who sent the message
// discordChannel: Discord channel (e.g. #general)
// ircChannel: IRC channel (e.g. #irc)
// text: the (appropriately formatted) message content
this.format = options.format || {};
// "{$keyName}" => "variableValue"
// displayUsername: nickname with wrapped colors
// attachmentURL: the URL of the attachment (only applicable in formatURLAttachment)
this.formatIRCText = this.format.ircText || '<{$displayUsername}> {$text}';
this.formatURLAttachment = this.format.urlAttachment || '<{$displayUsername}> {$attachmentURL}';
// "{$keyName}" => "variableValue"
// side: "Discord" or "IRC"
if ('commandPrelude' in this.format) {
this.formatCommandPrelude = this.format.commandPrelude;
} else {
this.formatCommandPrelude = 'Command sent from {$side} by {$nickname}:';
}
// "{$keyName}" => "variableValue"
// withMentions: text with appropriate mentions reformatted
this.formatDiscord = this.format.discord || '**<{$author}>** {$withMentions}';
// "{$keyName} => "variableValue"
// nickname: nickame of IRC message sender
this.formatWebhookAvatarURL = this.format.webhookAvatarURL;
// Keep track of { channel => [list, of, usernames] } for ircStatusNotices
this.channelUsers = {};
this.channelMapping = {};
this.webhooks = {};
// Remove channel passwords from the mapping and lowercase IRC channel names
_.forOwn(options.channelMapping, (ircChan, discordChan) => {
@@ -47,7 +99,17 @@ class Bot {
connect() {
logger.debug('Connecting to IRC and Discord');
this.discord.login(this.discordEmail, this.discordPassword);
this.discord.login(this.discordToken);
// Extract id and token from Webhook urls and connect.
_.forOwn(this.webhookOptions, (url, channel) => {
const [id, token] = url.split('/').slice(-2);
const client = new discord.WebhookClient(id, token);
this.webhooks[channel] = {
id,
client
};
});
const ircOptions = {
userName: this.nickname,
@@ -55,34 +117,58 @@ class Bot {
channels: this.channels,
floodProtection: true,
floodProtectionDelay: 500,
retryCount: 10,
autoRenick: true,
// options specified in the configuration file override the above defaults
...this.ircOptions
};
// default encoding to UTF-8 so messages to Discord aren't corrupted
if (!Object.prototype.hasOwnProperty.call(ircOptions, 'encoding')) {
if (irc.canConvertEncoding()) {
ircOptions.encoding = 'utf-8';
} else {
logger.warn('Cannot convert message encoding; you may encounter corrupted characters with non-English text.\n' +
'For information on how to fix this, please see: https://github.com/Throne3d/node-irc#character-set-detection');
}
}
this.ircClient = new irc.Client(this.server, this.nickname, ircOptions);
this.attachListeners();
}
disconnect() {
this.ircClient.disconnect();
this.discord.destroy();
Object.values(this.webhooks).forEach(x => x.client.destroy());
}
attachListeners() {
this.discord.on('ready', () => {
logger.debug('Connected to Discord');
logger.info('Connected to Discord');
});
this.ircClient.on('registered', message => {
this.ircClient.on('registered', (message) => {
logger.info('Connected to IRC');
logger.debug('Registered event: ', message);
this.autoSendCommands.forEach(element => {
this.autoSendCommands.forEach((element) => {
this.ircClient.send(...element);
});
});
this.ircClient.on('error', error => {
this.ircClient.on('error', (error) => {
logger.error('Received error event from IRC', error);
});
this.discord.on('error', error => {
this.discord.on('error', (error) => {
logger.error('Received error event from Discord', error);
});
this.discord.on('message', message => {
this.discord.on('warn', (warning) => {
logger.warn('Received warn event from Discord', warning);
});
this.discord.on('message', (message) => {
// Ignore bot messages and people leaving/joining
this.sendToIRC(message);
});
@@ -93,6 +179,72 @@ class Bot {
this.sendToDiscord(author, to, `*${text}*`);
});
this.ircClient.on('nick', (oldNick, newNick, channels) => {
if (!this.ircStatusNotices) return;
channels.forEach((channelName) => {
const channel = channelName.toLowerCase();
if (this.channelUsers[channel]) {
if (this.channelUsers[channel].has(oldNick)) {
this.channelUsers[channel].delete(oldNick);
this.channelUsers[channel].add(newNick);
this.sendExactToDiscord(channel, `*${oldNick}* is now known as ${newNick}`);
}
} else {
logger.warn(`No channelUsers found for ${channel} when ${oldNick} changed.`);
}
});
});
this.ircClient.on('join', (channelName, nick) => {
logger.debug('Received join:', channelName, nick);
if (!this.ircStatusNotices) return;
if (nick === this.ircClient.nick && !this.announceSelfJoin) return;
const channel = channelName.toLowerCase();
// self-join is announced before names (which includes own nick)
// so don't add nick to channelUsers
if (nick !== this.ircClient.nick) this.channelUsers[channel].add(nick);
this.sendExactToDiscord(channel, `*${nick}* has joined the channel`);
});
this.ircClient.on('part', (channelName, nick, reason) => {
logger.debug('Received part:', channelName, nick, reason);
if (!this.ircStatusNotices) return;
const channel = channelName.toLowerCase();
// remove list of users when no longer in channel (as it will become out of date)
if (nick === this.ircClient.nick) {
logger.debug('Deleting channelUsers as bot parted:', channel);
delete this.channelUsers[channel];
return;
}
if (this.channelUsers[channel]) {
this.channelUsers[channel].delete(nick);
} else {
logger.warn(`No channelUsers found for ${channel} when ${nick} parted.`);
}
this.sendExactToDiscord(channel, `*${nick}* has left the channel (${reason})`);
});
this.ircClient.on('quit', (nick, reason, channels) => {
logger.debug('Received quit:', nick, channels);
if (!this.ircStatusNotices || nick === this.ircClient.nick) return;
channels.forEach((channelName) => {
const channel = channelName.toLowerCase();
if (!this.channelUsers[channel]) {
logger.warn(`No channelUsers found for ${channel} when ${nick} quit, ignoring.`);
return;
}
if (!this.channelUsers[channel].delete(nick)) return;
this.sendExactToDiscord(channel, `*${nick}* has quit (${reason})`);
});
});
this.ircClient.on('names', (channelName, nicks) => {
logger.debug('Received names:', channelName, nicks);
if (!this.ircStatusNotices) return;
const channel = channelName.toLowerCase();
this.channelUsers[channel] = new Set(Object.keys(nicks));
});
this.ircClient.on('action', (author, to, text) => {
this.sendToDiscord(author, to, `_${text}_`);
});
@@ -106,57 +258,134 @@ class Bot {
logger.debug('Joining channel:', channel);
}
});
if (logger.level === 'debug') {
this.discord.on('debug', (message) => {
logger.debug('Received debug event from Discord', message);
});
}
}
static getDiscordNicknameOnServer(user, guild) {
if (guild) {
const userDetails = guild.members.cache.get(user.id);
if (userDetails) {
return userDetails.nickname || user.username;
}
}
return user.username;
}
parseText(message) {
const text = message.mentions.reduce((content, mention) => (
content.replace(`<@${mention.id}>`, `@${mention.username}`)
), message.content);
const text = message.mentions.users.reduce((content, mention) => {
const displayName = Bot.getDiscordNicknameOnServer(mention, message.guild);
const userMentionRegex = RegExp(`<@(&|!)?${mention.id}>`, 'g');
return content.replace(userMentionRegex, `@${displayName}`);
}, message.content);
return text
.replace(/\n|\r\n|\r/g, ' ')
.replace(/<#(\d+)>/g, (match, channelId) => {
const channel = this.discord.channels.get('id', channelId);
return `#${channel.name}`;
});
const channel = this.discord.channels.cache.get(channelId);
if (channel) return `#${channel.name}`;
return '#deleted-channel';
})
.replace(/<@&(\d+)>/g, (match, roleId) => {
const role = message.guild.roles.cache.get(roleId);
if (role) return `@${role.name}`;
return '@deleted-role';
})
.replace(/<a?(:\w+:)\d+>/g, (match, emoteName) => emoteName);
}
isCommandMessage(message) {
return this.commandCharacters.indexOf(message[0]) !== -1;
return this.commandCharacters.some(prefix => message.startsWith(prefix));
}
ignoredIrcUser(user) {
return this.ignoreUsers.irc.some(i => i.toLowerCase() === user.toLowerCase());
}
ignoredDiscordUser(discordUser) {
const ignoredName = this.ignoreUsers.discord.some(
i => i.toLowerCase() === discordUser.username.toLowerCase()
);
const ignoredId = this.ignoreUsers.discordIds.some(i => i === discordUser.id);
return ignoredName || ignoredId;
}
static substitutePattern(message, patternMapping) {
return message.replace(patternMatch, (match, varName) => patternMapping[varName] || match);
}
sendToIRC(message) {
const author = message.author;
const { author } = message;
// Ignore messages sent by the bot itself:
if (author.id === this.discord.user.id) return;
if (author.id === this.discord.user.id ||
Object.keys(this.webhooks).some(channel => this.webhooks[channel].id === author.id)
) return;
// Do not send to IRC if this user is on the ignore list.
if (this.ignoredDiscordUser(author)) {
return;
}
const channelName = `#${message.channel.name}`;
const ircChannel = this.channelMapping[channelName];
const ircChannel = this.channelMapping[message.channel.id] ||
this.channelMapping[channelName];
logger.debug('Channel Mapping', channelName, this.channelMapping[channelName]);
if (ircChannel) {
const username = author.username;
const fromGuild = message.guild;
const nickname = Bot.getDiscordNicknameOnServer(author, fromGuild);
let text = this.parseText(message);
let displayUsername = username;
if (this.ircNickColor) {
const colorIndex = (username.charCodeAt(0) + username.length) % NICK_COLORS.length;
displayUsername = irc.colors.wrap(NICK_COLORS[colorIndex], username);
let displayUsername = nickname;
if (this.parallelPingFix) {
// Prevent users of both IRC and Discord from
// being mentioned in IRC when they talk in Discord.
displayUsername = `${displayUsername.slice(0, 1)}\u200B${displayUsername.slice(1)}`;
}
if (this.ircNickColor) {
const colorIndex = (nickname.charCodeAt(0) + nickname.length) % this.ircNickColors.length;
displayUsername = irc.colors.wrap(this.ircNickColors[colorIndex], displayUsername);
}
const patternMap = {
author: nickname,
nickname,
displayUsername,
text,
discordChannel: channelName,
ircChannel
};
if (this.isCommandMessage(text)) {
const prelude = `Command sent from Discord by ${username}:`;
this.ircClient.say(ircChannel, prelude);
patternMap.side = 'Discord';
logger.debug('Sending command message to IRC', ircChannel, text);
// if (prelude) this.ircClient.say(ircChannel, prelude);
if (this.formatCommandPrelude) {
const prelude = Bot.substitutePattern(this.formatCommandPrelude, patternMap);
this.ircClient.say(ircChannel, prelude);
}
this.ircClient.say(ircChannel, text);
} else {
if (text !== '') {
text = `<${displayUsername}> ${text}`;
// Convert formatting
text = formatFromDiscordToIRC(text);
patternMap.text = text;
text = Bot.substitutePattern(this.formatIRCText, patternMap);
logger.debug('Sending message to IRC', ircChannel, text);
this.ircClient.say(ircChannel, text);
}
if (message.attachments && message.attachments.length) {
message.attachments.forEach(a => {
const urlMessage = `<${displayUsername}> ${a.url}`;
if (message.attachments && message.attachments.size) {
message.attachments.forEach((a) => {
patternMap.attachmentURL = a.url;
const urlMessage = Bot.substitutePattern(this.formatURLAttachment, patternMap);
logger.debug('Sending attachment URL to IRC', ircChannel, urlMessage);
this.ircClient.say(ircChannel, urlMessage);
});
@@ -165,28 +394,231 @@ class Bot {
}
}
sendToDiscord(author, channel, text) {
const discordChannelName = this.invertedMapping[channel.toLowerCase()];
findDiscordChannel(ircChannel) {
const discordChannelName = this.invertedMapping[ircChannel.toLowerCase()];
if (discordChannelName) {
// #channel -> channel before retrieving:
const discordChannel = this.discord.channels.get('name', discordChannelName.slice(1));
// #channel -> channel before retrieving and select only text channels:
let discordChannel = null;
if (!discordChannel) {
logger.info('Tried to send a message to a channel the bot isn\'t in: ',
discordChannelName);
return;
if (this.discord.channels.cache.has(discordChannelName)) {
discordChannel = this.discord.channels.cache.get(discordChannelName);
} else if (discordChannelName.startsWith('#')) {
discordChannel = this.discord.channels.cache
.filter(c => c.type === 'text')
.find(c => c.name === discordChannelName.slice(1));
}
const withMentions = text.replace(/@[^\s]+\b/g, match => {
const user = this.discord.users.get('username', match.substring(1));
return user ? user.mention() : match;
if (!discordChannel) {
logger.info(
'Tried to send a message to a channel the bot isn\'t in: ',
discordChannelName
);
return null;
}
return discordChannel;
}
return null;
}
findWebhook(ircChannel) {
const discordChannelName = this.invertedMapping[ircChannel.toLowerCase()];
return discordChannelName && this.webhooks[discordChannelName];
}
getDiscordAvatar(nick, channel) {
const guildMembers = this.findDiscordChannel(channel).guild.members.cache;
const findByNicknameOrUsername = caseSensitive =>
(member) => {
if (caseSensitive) {
return member.user.username === nick || member.nickname === nick;
}
const nickLowerCase = nick.toLowerCase();
return member.user.username.toLowerCase() === nickLowerCase
|| (member.nickname && member.nickname.toLowerCase() === nickLowerCase);
};
// Try to find exact matching case
let users = guildMembers.filter(findByNicknameOrUsername(true));
// Now let's search case insensitive.
if (users.size === 0) {
users = guildMembers.filter(findByNicknameOrUsername(false));
}
// No matching user or more than one => default avatar
if (users && users.size === 1) {
const url = users.first().user.avatarURL({ size: 128, format: 'png' });
if (url) return url;
}
// If there isn't a URL format, don't send an avatar at all
if (this.formatWebhookAvatarURL) {
return Bot.substitutePattern(this.formatWebhookAvatarURL, { nickname: nick });
}
return null;
}
// compare two strings case-insensitively
// for discord mention matching
static caseComp(str1, str2) {
return str1.toUpperCase() === str2.toUpperCase();
}
// check if the first string starts with the second case-insensitively
// for discord mention matching
static caseStartsWith(str1, str2) {
return str1.toUpperCase().startsWith(str2.toUpperCase());
}
sendToDiscord(author, channel, text) {
const discordChannel = this.findDiscordChannel(channel);
if (!discordChannel) return;
// Do not send to Discord if this user is on the ignore list.
if (this.ignoredIrcUser(author)) {
return;
}
// Convert text formatting (bold, italics, underscore)
const withFormat = formatFromIRCToDiscord(text);
const patternMap = {
author,
nickname: author,
displayUsername: author,
text: withFormat,
discordChannel: `#${discordChannel.name}`,
ircChannel: channel
};
if (this.isCommandMessage(text)) {
patternMap.side = 'IRC';
logger.debug('Sending command message to Discord', `#${discordChannel.name}`, text);
if (this.formatCommandPrelude) {
const prelude = Bot.substitutePattern(this.formatCommandPrelude, patternMap);
discordChannel.send(prelude);
}
discordChannel.send(text);
return;
}
const { guild } = discordChannel;
const withMentions = withFormat.replace(/@([^\s#]+)#(\d+)/g, (match, username, discriminator) => {
// @username#1234 => mention
// skips usernames including spaces for ease (they cannot include hashes)
// checks case insensitively as Discord does
const user = guild.members.cache.find(x =>
Bot.caseComp(x.user.username, username)
&& x.user.discriminator === discriminator);
if (user) return user;
return match;
}).replace(/^([^@\s:,]+)[:,]|@([^\s]+)/g, (match, startRef, atRef) => {
const reference = startRef || atRef;
// this preliminary stuff is ultimately unnecessary
// but might save time over later more complicated calculations
// @nickname => mention, case insensitively
const nickUser = guild.members.cache.find(x =>
x.nickname && Bot.caseComp(x.nickname, reference));
if (nickUser) return nickUser;
// @username => mention, case insensitively
const user = guild.members.cache.find(x => Bot.caseComp(x.user.username, reference));
if (user) return user;
// @role => mention, case insensitively
const role = guild.roles.cache.find(x => x.mentionable && Bot.caseComp(x.name, reference));
if (role) return role;
// No match found checking the whole word. Check for partial matches now instead.
// @nameextra => [mention]extra, case insensitively, as Discord does
// uses the longest match, and if there are two, whichever is a match by case
let matchLength = 0;
let bestMatch = null;
let caseMatched = false;
// check if a partial match is found in reference and if so update the match values
const checkMatch = function (matchString, matchValue) {
// if the matchString is longer than the current best and is a match
// or if it's the same length but it matches by case unlike the current match
// set the best match to this matchString and matchValue
if ((matchString.length > matchLength && Bot.caseStartsWith(reference, matchString))
|| (matchString.length === matchLength && !caseMatched
&& reference.startsWith(matchString))) {
matchLength = matchString.length;
bestMatch = matchValue;
caseMatched = reference.startsWith(matchString);
}
};
// check users by username and nickname
guild.members.cache.forEach((member) => {
checkMatch(member.user.username, member);
if (bestMatch === member || !member.nickname) return;
checkMatch(member.nickname, member);
});
// check mentionable roles by visible name
guild.roles.cache.forEach((member) => {
if (!member.mentionable) return;
checkMatch(member.name, member);
});
// Add bold formatting:
const withAuthor = `**<${author}>** ${withMentions}`;
logger.debug('Sending message to Discord', withAuthor, channel, '->', discordChannelName);
this.discord.sendMessage(discordChannel, withAuthor);
// if a partial match was found, return the match and the unmatched trailing characters
if (bestMatch) return bestMatch.toString() + reference.substring(matchLength);
return match;
}).replace(/:(\w+):/g, (match, ident) => {
// :emoji: => mention, case sensitively
const emoji = guild.emojis.cache.find(x => x.name === ident && x.requiresColons);
if (emoji) return emoji;
return match;
}).replace(/#([^\s#@'!?,.]+)/g, (match, channelName) => {
// channel names can't contain spaces, #, @, ', !, ?, , or .
// (based on brief testing. they also can't contain some other symbols,
// but these seem likely to be common around channel references)
// discord matches channel names case insensitively
const chan = guild.channels.cache.find(x => Bot.caseComp(x.name, channelName));
return chan || match;
});
// Webhooks first
const webhook = this.findWebhook(channel);
if (webhook) {
logger.debug('Sending message to Discord via webhook', withMentions, channel, '->', `#${discordChannel.name}`);
const permissions = discordChannel.permissionsFor(this.discord.user);
let canPingEveryone = false;
if (permissions) {
canPingEveryone = permissions.has(discord.Permissions.FLAGS.MENTION_EVERYONE);
}
const avatarURL = this.getDiscordAvatar(author, channel);
const username = _.padEnd(author.substring(0, USERNAME_MAX_LENGTH), USERNAME_MIN_LENGTH, '_');
webhook.client.send(withMentions, {
username,
avatarURL,
disableMentions: canPingEveryone ? 'none' : 'everyone',
}).catch(logger.error);
return;
}
patternMap.withMentions = withMentions;
// Add bold formatting:
// Use custom formatting from config / default formatting with bold author
const withAuthor = Bot.substitutePattern(this.formatDiscord, patternMap);
logger.debug('Sending message to Discord', withAuthor, channel, '->', `#${discordChannel.name}`);
discordChannel.send(withAuthor);
}
/* Sends a message to Discord exactly as it appears */
sendExactToDiscord(channel, text) {
const discordChannel = this.findDiscordChannel(channel);
if (!discordChannel) return;
logger.debug('Sending special message to Discord', text, channel, '->', `#${discordChannel.name}`);
discordChannel.send(text);
}
}
+6 -4
View File
@@ -3,7 +3,6 @@
import fs from 'fs';
import program from 'commander';
import path from 'path';
import checkEnv from 'check-env';
import stripJsonComments from 'strip-json-comments';
import { endsWith } from 'lodash';
import * as helpers from './helpers';
@@ -26,14 +25,17 @@ function readJSONConfig(filePath) {
function run() {
program
.version(version)
.option('-c, --config <path>',
.option(
'-c, --config <path>',
'Sets the path to the config file, otherwise read from the env variable CONFIG_FILE.'
)
.parse(process.argv);
const opts = program.opts();
// If no config option is given, try to use the env variable:
if (!program.config) checkEnv(['CONFIG_FILE']);
else process.env.CONFIG_FILE = program.config;
if (opts.config) process.env.CONFIG_FILE = opts.config;
if (!process.env.CONFIG_FILE) throw new Error('Missing environment variable CONFIG_FILE');
const completePath = path.resolve(process.cwd(), process.env.CONFIG_FILE);
const config = endsWith(process.env.CONFIG_FILE, '.js') ?
+53
View File
@@ -0,0 +1,53 @@
import ircFormatting from 'irc-formatting';
import SimpleMarkdown from 'simple-markdown';
import colors from 'irc-colors';
function mdNodeToIRC(node) {
let { content } = node;
if (Array.isArray(content)) content = content.map(mdNodeToIRC).join('');
switch (node.type) {
case 'em':
return colors.italic(content);
case 'strong':
return colors.bold(content);
case 'u':
return colors.underline(content);
default:
return content;
}
}
export function formatFromDiscordToIRC(text) {
const markdownAST = SimpleMarkdown.defaultInlineParse(text);
return markdownAST.map(mdNodeToIRC).join('');
}
export function formatFromIRCToDiscord(text) {
const blocks = ircFormatting.parse(text).map(block => ({
// Consider reverse as italic, some IRC clients use that
...block,
italic: block.italic || block.reverse
}));
let mdText = '';
for (let i = 0; i <= blocks.length; i += 1) {
// Default to unstyled blocks when index out of range
const block = blocks[i] || {};
const prevBlock = blocks[i - 1] || {};
// Add start markers when style turns from false to true
if (!prevBlock.italic && block.italic) mdText += '*';
if (!prevBlock.bold && block.bold) mdText += '**';
if (!prevBlock.underline && block.underline) mdText += '__';
// Add end markers when style turns from true to false
// (and apply in reverse order to maintain nesting)
if (prevBlock.underline && !block.underline) mdText += '__';
if (prevBlock.bold && !block.bold) mdText += '**';
if (prevBlock.italic && !block.italic) mdText += '*';
mdText += block.text || '';
}
return mdText;
}
+1 -1
View File
@@ -11,7 +11,7 @@ export function createBots(configFile) {
// The config file can be both an array and an object
if (Array.isArray(configFile)) {
configFile.forEach(config => {
configFile.forEach((config) => {
const bot = new Bot(config);
bot.connect();
bots.push(bot);
-6
View File
@@ -1,12 +1,6 @@
#!/usr/bin/env node
import { createBots } from './helpers';
import logger from 'winston';
/* istanbul ignore next */
if (process.env.NODE_ENV === 'development') {
logger.level = 'debug';
}
/* istanbul ignore next */
if (!module.parent) {
+27
View File
@@ -0,0 +1,27 @@
import winston, { format } from 'winston';
import { inspect } from 'util';
function simpleInspect(value) {
if (typeof value === 'string') return value;
return inspect(value, { depth: null });
}
function formatter(info) {
const splat = info[Symbol.for('splat')] || [];
const stringifiedRest = splat.length > 0 ? ` ${splat.map(simpleInspect).join(' ')}` : '';
const padding = (info.padding && info.padding[info.level]) || '';
return `${info.timestamp} ${info.level}:${padding} ${info.message}${stringifiedRest}`;
}
const logger = winston.createLogger({
transports: [new winston.transports.Console()],
level: process.env.NODE_ENV === 'development' ? 'debug' : 'info',
format: format.combine(
format.colorize(),
format.timestamp(),
format.printf(formatter),
)
});
export default logger;
+6644
View File
File diff suppressed because it is too large Load Diff
+31 -24
View File
@@ -1,6 +1,6 @@
{
"name": "discord-irc",
"version": "0.8.0",
"version": "2.9.0",
"description": "Connects IRC and Discord channels by sending messages back and forth.",
"keywords": [
"discord",
@@ -11,7 +11,7 @@
"reactiflux"
],
"engines": {
"node": ">=0.12.7"
"node": ">=12.0.0"
},
"main": "dist/index.js",
"bin": "dist/index.js",
@@ -25,9 +25,10 @@
"scripts": {
"start": "node dist/index.js",
"build": "babel lib --out-dir dist",
"prepublish": "npm run build",
"prepare": "npm run build",
"lint": "eslint . --ignore-path .gitignore",
"coverage": "nyc --require babel-core/register _mocha -- $(find test -name '*.test.js') && nyc report --reporter=cobertura",
"coverage": "cross-env NODE_ENV=test nyc --require @babel/register mocha -- 'test/*.test.js'",
"save-coverage": "nyc report --reporter=lcov",
"test": "npm run lint && npm run coverage"
},
"author": {
@@ -35,27 +36,33 @@
},
"license": "MIT",
"dependencies": {
"check-env": "1.2.0",
"commander": "2.9.0",
"discord.js": "6.1.0",
"irc": "0.5.0",
"lodash": "4.8.1",
"strip-json-comments": "2.0.1",
"winston": "2.2.0"
"commander": "^7.2.0",
"discord.js": "^12.5.3",
"irc-colors": "1.5.0",
"irc-formatting": "1.0.0-rc3",
"irc-upd": "0.11.0",
"lodash": "^4.17.21",
"simple-markdown": "^0.7.3",
"strip-json-comments": "^3.1.1",
"winston": "^3.3.3"
},
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-core": "^6.7.4",
"babel-eslint": "^6.0.2",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-0": "^6.5.0",
"chai": "3.5.0",
"eslint": "^2.6.0",
"eslint-config-airbnb": "^6.2.0",
"eslint-config-webkom": "^1.3.4",
"mocha": "2.4.5",
"nyc": "^6.1.1",
"sinon": "1.17.3",
"sinon-chai": "2.8.0"
"@babel/cli": "^7.13.16",
"@babel/core": "^7.13.16",
"@babel/eslint-parser": "^7.13.14",
"@babel/preset-env": "^7.13.15",
"@babel/register": "^7.13.16",
"@istanbuljs/nyc-config-babel": "^3.0.0",
"babel-plugin-istanbul": "^6.0.0",
"chai": "^4.3.4",
"coveralls": "^3.1.0",
"cross-env": "^7.0.3",
"eslint": "^7.25.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"mocha": "^8.3.2",
"nyc": "^15.1.0",
"sinon": "^10.0.0",
"sinon-chai": "^3.6.0"
}
}
+260 -21
View File
@@ -2,47 +2,66 @@
import chai from 'chai';
import sinonChai from 'sinon-chai';
import sinon from 'sinon';
import irc from 'irc';
import irc from 'irc-upd';
import discord from 'discord.js';
import logger from 'winston';
import Bot from '../lib/bot';
import DiscordStub from './stubs/discord-stub';
import logger from '../lib/logger';
import createDiscordStub from './stubs/discord-stub';
import createWebhookStub from './stubs/webhook-stub';
import ClientStub from './stubs/irc-client-stub';
import config from './fixtures/single-test-config.json';
chai.should();
chai.use(sinonChai);
describe('Bot Events', function() {
const sandbox = sinon.sandbox.create({
describe('Bot Events', function () {
const sandbox = sinon.createSandbox({
useFakeTimers: false,
useFakeServer: false
});
beforeEach(function() {
const createBot = (optConfig = null) => {
const useConfig = optConfig || config;
const bot = new Bot(useConfig);
bot.sendToIRC = sandbox.stub();
bot.sendToDiscord = sandbox.stub();
bot.sendExactToDiscord = sandbox.stub();
return bot;
};
beforeEach(function () {
this.infoSpy = sandbox.stub(logger, 'info');
this.debugSpy = sandbox.stub(logger, 'debug');
this.warnSpy = sandbox.stub(logger, 'warn');
this.errorSpy = sandbox.stub(logger, 'error');
this.sendStub = sandbox.stub();
irc.Client = ClientStub;
discord.Client = DiscordStub;
discord.Client = createDiscordStub(this.sendStub);
discord.WebhookClient = createWebhookStub(this.sendStub);
ClientStub.prototype.send = sandbox.stub();
ClientStub.prototype.join = sandbox.stub();
this.bot = new Bot(config);
this.bot.sendToIRC = sandbox.stub();
this.bot.sendToDiscord = sandbox.stub();
this.bot = createBot();
this.bot.connect();
});
afterEach(function() {
afterEach(function () {
this.bot.disconnect();
sandbox.restore();
});
it('should log on discord ready event', function() {
it('should log on discord ready event', function () {
this.bot.discord.emit('ready');
this.debugSpy.should.have.been.calledWithExactly('Connected to Discord');
this.infoSpy.should.have.been.calledWithExactly('Connected to Discord');
});
it('should try to send autoSendCommands on registered IRC event', function() {
it('should log on irc registered event', function () {
const message = 'registered';
this.bot.ircClient.emit('registered', message);
this.infoSpy.should.have.been.calledWithExactly('Connected to IRC');
this.debugSpy.should.have.been.calledWithExactly('Registered event: ', message);
});
it('should try to send autoSendCommands on registered IRC event', function () {
this.bot.ircClient.emit('registered');
ClientStub.prototype.send.should.have.been.calledTwice;
ClientStub.prototype.send.getCall(0)
@@ -51,7 +70,7 @@ describe('Bot Events', function() {
.args.should.deep.equal(config.autoSendCommands[1]);
});
it('should error log on error events', function() {
it('should error log on error events', function () {
const discordError = new Error('discord');
const ircError = new Error('irc');
this.bot.discord.emit('error', discordError);
@@ -62,7 +81,15 @@ describe('Bot Events', function() {
this.errorSpy.getCall(1).args[1].should.equal(ircError);
});
it('should send messages to irc if correct', function() {
it('should warn log on warn events from discord', function () {
const discordError = new Error('discord');
this.bot.discord.emit('warn', discordError);
const [message, error] = this.warnSpy.firstCall.args;
message.should.equal('Received warn event from Discord');
error.should.equal(discordError);
});
it('should send messages to irc if correct', function () {
const message = {
type: 'message'
};
@@ -71,7 +98,7 @@ describe('Bot Events', function() {
this.bot.sendToIRC.should.have.been.calledWithExactly(message);
});
it('should send messages to discord', function() {
it('should send messages to discord', function () {
const channel = '#channel';
const author = 'user';
const text = 'hi';
@@ -79,7 +106,7 @@ describe('Bot Events', function() {
this.bot.sendToDiscord.should.have.been.calledWithExactly(author, channel, text);
});
it('should send notices to discord', function() {
it('should send notices to discord', function () {
const channel = '#channel';
const author = 'user';
const text = 'hi';
@@ -88,7 +115,36 @@ describe('Bot Events', function() {
this.bot.sendToDiscord.should.have.been.calledWithExactly(author, channel, formattedText);
});
it('should send actions to discord', function() {
it('should not send name change event to discord', function () {
const channel = '#channel';
const oldnick = 'user1';
const newnick = 'user2';
this.bot.ircClient.emit('nick', oldnick, newnick, [channel]);
this.bot.sendExactToDiscord.should.not.have.been.called;
});
it('should send name change event to discord', function () {
const channel1 = '#channel1';
const channel2 = '#channel2';
const channel3 = '#channel3';
const oldNick = 'user1';
const newNick = 'user2';
const user3 = 'user3';
const bot = createBot({ ...config, ircStatusNotices: true });
const staticChannel = new Set([bot.nickname, user3]);
bot.connect();
bot.ircClient.emit('names', channel1, { [bot.nickname]: '', [oldNick]: '' });
bot.ircClient.emit('names', channel2, { [bot.nickname]: '', [user3]: '' });
const channelNicksPre = new Set([bot.nickname, oldNick]);
bot.channelUsers.should.deep.equal({ '#channel1': channelNicksPre, '#channel2': staticChannel });
const formattedText = `*${oldNick}* is now known as ${newNick}`;
const channelNicksAfter = new Set([bot.nickname, newNick]);
bot.ircClient.emit('nick', oldNick, newNick, [channel1, channel2, channel3]);
bot.sendExactToDiscord.should.have.been.calledWithExactly(channel1, formattedText);
bot.channelUsers.should.deep.equal({ '#channel1': channelNicksAfter, '#channel2': staticChannel });
});
it('should send actions to discord', function () {
const channel = '#channel';
const author = 'user';
const text = 'hi';
@@ -98,7 +154,190 @@ describe('Bot Events', function() {
this.bot.sendToDiscord.should.have.been.calledWithExactly(author, channel, formattedText);
});
it('should join channels when invited', function() {
it('should keep track of users through names event when irc status notices enabled', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
bot.channelUsers.should.be.an('object');
const channel = '#channel';
// nick => '' means the user is not a special user
const nicks = {
[bot.nickname]: '', user: '', user2: '@', user3: '+'
};
bot.ircClient.emit('names', channel, nicks);
const channelNicks = new Set([bot.nickname, 'user', 'user2', 'user3']);
bot.channelUsers.should.deep.equal({ '#channel': channelNicks });
});
it('should lowercase the channelUsers mapping', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
const channel = '#channelName';
const nicks = { [bot.nickname]: '' };
bot.ircClient.emit('names', channel, nicks);
const channelNicks = new Set([bot.nickname]);
bot.channelUsers.should.deep.equal({ '#channelname': channelNicks });
});
it('should send join messages to discord when config enabled', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
const channel = '#channel';
bot.ircClient.emit('names', channel, { [bot.nickname]: '' });
const nick = 'user';
const text = `*${nick}* has joined the channel`;
bot.ircClient.emit('join', channel, nick);
bot.sendExactToDiscord.should.have.been.calledWithExactly(channel, text);
const channelNicks = new Set([bot.nickname, nick]);
bot.channelUsers.should.deep.equal({ '#channel': channelNicks });
});
it('should not announce itself joining by default', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
const channel = '#channel';
bot.ircClient.emit('names', channel, { [bot.nickname]: '' });
const nick = bot.nickname;
bot.ircClient.emit('join', channel, nick);
bot.sendExactToDiscord.should.not.have.been.called;
const channelNicks = new Set([bot.nickname]);
bot.channelUsers.should.deep.equal({ '#channel': channelNicks });
});
it('should announce the bot itself when config enabled', function () {
// self-join is announced before names (which includes own nick)
// hence don't trigger a names and don't expect anything of bot.channelUsers
const bot = createBot({ ...config, ircStatusNotices: true, announceSelfJoin: true });
bot.connect();
const channel = '#channel';
const nick = this.bot.nickname;
const text = `*${nick}* has joined the channel`;
bot.ircClient.emit('join', channel, nick);
bot.sendExactToDiscord.should.have.been.calledWithExactly(channel, text);
});
it('should send part messages to discord when config enabled', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
const channel = '#channel';
const nick = 'user';
bot.ircClient.emit('names', channel, { [bot.nickname]: '', [nick]: '' });
const originalNicks = new Set([bot.nickname, nick]);
bot.channelUsers.should.deep.equal({ '#channel': originalNicks });
const reason = 'Leaving';
const text = `*${nick}* has left the channel (${reason})`;
bot.ircClient.emit('part', channel, nick, reason);
bot.sendExactToDiscord.should.have.been.calledWithExactly(channel, text);
// it should remove the nickname from the channelUsers list
const channelNicks = new Set([bot.nickname]);
bot.channelUsers.should.deep.equal({ '#channel': channelNicks });
});
it('should not announce itself leaving a channel', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
const channel = '#channel';
bot.ircClient.emit('names', channel, { [bot.nickname]: '', user: '' });
const originalNicks = new Set([bot.nickname, 'user']);
bot.channelUsers.should.deep.equal({ '#channel': originalNicks });
const reason = 'Leaving';
bot.ircClient.emit('part', channel, bot.nickname, reason);
bot.sendExactToDiscord.should.not.have.been.called;
// it should remove the nickname from the channelUsers list
bot.channelUsers.should.deep.equal({});
});
it('should only send quit messages to discord for channels the user is tracked in', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
const channel1 = '#channel1';
const channel2 = '#channel2';
const channel3 = '#channel3';
const nick = 'user';
bot.ircClient.emit('names', channel1, { [bot.nickname]: '', [nick]: '' });
bot.ircClient.emit('names', channel2, { [bot.nickname]: '' });
bot.ircClient.emit('names', channel3, { [bot.nickname]: '', [nick]: '' });
const reason = 'Quit: Leaving';
const text = `*${nick}* has quit (${reason})`;
// send quit message for all channels on server, as the node-irc library does
bot.ircClient.emit('quit', nick, reason, [channel1, channel2, channel3]);
bot.sendExactToDiscord.should.have.been.calledTwice;
bot.sendExactToDiscord.getCall(0).args.should.deep.equal([channel1, text]);
bot.sendExactToDiscord.getCall(1).args.should.deep.equal([channel3, text]);
});
it('should not crash with join/part/quit messages and weird channel casing', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
function wrap() {
const nick = 'user';
const reason = 'Leaving';
bot.ircClient.emit('names', '#Channel', { [bot.nickname]: '' });
bot.ircClient.emit('join', '#cHannel', nick);
bot.ircClient.emit('part', '#chAnnel', nick, reason);
bot.ircClient.emit('join', '#chaNnel', nick);
bot.ircClient.emit('quit', nick, reason, ['#chanNel']);
}
(wrap).should.not.throw();
});
it('should be possible to disable join/part/quit messages', function () {
const bot = createBot({ ...config, ircStatusNotices: false });
bot.connect();
const channel = '#channel';
const nick = 'user';
const reason = 'Leaving';
bot.ircClient.emit('names', channel, { [bot.nickname]: '' });
bot.ircClient.emit('join', channel, nick);
bot.ircClient.emit('part', channel, nick, reason);
bot.ircClient.emit('join', channel, nick);
bot.ircClient.emit('quit', nick, reason, [channel]);
bot.sendExactToDiscord.should.not.have.been.called;
});
it('should warn if it receives a part/quit before a names event', function () {
const bot = createBot({ ...config, ircStatusNotices: true });
bot.connect();
const channel = '#channel';
const reason = 'Leaving';
bot.ircClient.emit('part', channel, 'user1', reason);
bot.ircClient.emit('quit', 'user2', reason, [channel]);
this.warnSpy.should.have.been.calledTwice;
this.warnSpy.getCall(0).args.should.deep.equal([`No channelUsers found for ${channel} when user1 parted.`]);
this.warnSpy.getCall(1).args.should.deep.equal([`No channelUsers found for ${channel} when user2 quit, ignoring.`]);
});
it('should not crash if it uses a different name from config', function () {
// this can happen when a user with the same name is already connected
const bot = createBot({ ...config, nickname: 'testbot' });
bot.connect();
const newName = 'testbot1';
bot.ircClient.nick = newName;
function wrap() {
bot.ircClient.emit('join', '#channel', newName);
}
(wrap).should.not.throw;
});
it('should not listen to discord debug messages in production', function () {
logger.level = 'info';
const bot = createBot();
bot.connect();
const listeners = bot.discord.listeners('debug');
listeners.length.should.equal(0);
});
it('should listen to discord debug messages in development', function () {
logger.level = 'debug';
const bot = createBot();
bot.connect();
const listeners = bot.discord.listeners('debug');
listeners.length.should.equal(1);
});
it('should join channels when invited', function () {
const channel = '#irc';
const author = 'user';
this.bot.ircClient.emit('invite', channel, author);
@@ -113,7 +352,7 @@ describe('Bot Events', function() {
secondCall.args[1].should.equal(channel);
});
it('should not join channels that aren\'t in the channel mapping', function() {
it('should not join channels that aren\'t in the channel mapping', function () {
const channel = '#wrong';
const author = 'user';
this.bot.ircClient.emit('invite', channel, author);
+1040 -126
View File
File diff suppressed because it is too large Load Diff
+8 -2
View File
@@ -1,5 +1,5 @@
import chai from 'chai';
import irc from 'irc';
import irc from 'irc-upd';
import discord from 'discord.js';
import Bot from '../lib/bot';
import config from './fixtures/single-test-config.json';
@@ -38,7 +38,7 @@ describe('Channel Mapping', () => {
const bot = new Bot(config);
bot.channelMapping['#discord'].should.equal('#irc');
bot.invertedMapping['#irc'].should.equal('#discord');
bot.channels[0].should.equal('#irc channelKey');
bot.channels.should.contain('#irc channelKey');
});
it('should lowercase IRC channel names', () => {
@@ -46,4 +46,10 @@ describe('Channel Mapping', () => {
bot.channelMapping['#discord'].should.equal('#irc');
bot.channelMapping['#otherDiscord'].should.equal('#otherirc');
});
it('should work with ID maps', () => {
const bot = new Bot(config);
bot.channelMapping['1234'].should.equal('#channelforid');
bot.invertedMapping['#channelforid'].should.equal('1234');
});
});
+9 -9
View File
@@ -10,49 +10,49 @@ import singleTestConfig from './fixtures/single-test-config.json';
chai.should();
chai.use(sinonChai);
describe('CLI', function() {
const sandbox = sinon.sandbox.create({
describe('CLI', function () {
const sandbox = sinon.createSandbox({
useFakeTimers: false,
useFakeServer: false
});
beforeEach(function() {
beforeEach(function () {
this.createBotsStub = sandbox.stub(helpers, 'createBots');
});
afterEach(function() {
afterEach(function () {
sandbox.restore();
});
it('should be possible to give the config as an env var', function() {
it('should be possible to give the config as an env var', function () {
process.env.CONFIG_FILE = `${process.cwd()}/test/fixtures/test-config.json`;
process.argv = ['node', 'index.js'];
cli();
this.createBotsStub.should.have.been.calledWith(testConfig);
});
it('should strip comments from JSON config', function() {
it('should strip comments from JSON config', function () {
process.env.CONFIG_FILE = `${process.cwd()}/test/fixtures/test-config-comments.json`;
process.argv = ['node', 'index.js'];
cli();
this.createBotsStub.should.have.been.calledWith(testConfig);
});
it('should support JS configs', function() {
it('should support JS configs', function () {
process.env.CONFIG_FILE = `${process.cwd()}/test/fixtures/test-javascript-config.js`;
process.argv = ['node', 'index.js'];
cli();
this.createBotsStub.should.have.been.calledWith(testConfig);
});
it('should throw a ConfigurationError for invalid JSON', function() {
it('should throw a ConfigurationError for invalid JSON', function () {
process.env.CONFIG_FILE = `${process.cwd()}/test/fixtures/invalid-json-config.json`;
process.argv = ['node', 'index.js'];
const wrap = () => cli();
(wrap).should.throw('The configuration file contains invalid JSON');
});
it('should be possible to give the config as an option', function() {
it('should be possible to give the config as an option', function () {
delete process.env.CONFIG_FILE;
process.argv = [
'node',
+9 -9
View File
@@ -13,33 +13,33 @@ import { createBots } from '../lib/helpers';
chai.should();
chai.use(sinonChai);
describe('Create Bots', function() {
const sandbox = sinon.sandbox.create({
describe('Create Bots', function () {
const sandbox = sinon.createSandbox({
useFakeTimers: false,
useFakeServer: false
});
beforeEach(function() {
beforeEach(function () {
this.connectStub = sandbox.stub(Bot.prototype, 'connect');
});
afterEach(function() {
afterEach(function () {
sandbox.restore();
});
it('should work when given an array of configs', function() {
it('should work when given an array of configs', function () {
const bots = createBots(testConfig);
bots.length.should.equal(2);
this.connectStub.should.have.been.called;
});
it('should work when given an object as a config file', function() {
it('should work when given an object as a config file', function () {
const bots = createBots(singleTestConfig);
bots.length.should.equal(1);
this.connectStub.should.have.been.called;
});
it('should throw a configuration error if any fields are missing', function() {
it('should throw a configuration error if any fields are missing', function () {
function wrap() {
createBots(badConfig);
}
@@ -47,7 +47,7 @@ describe('Create Bots', function() {
(wrap).should.throw('Missing configuration field nickname');
});
it('should throw if a configuration file is neither an object or an array', function() {
it('should throw if a configuration file is neither an object or an array', function () {
function wrap() {
createBots(stringConfig);
}
@@ -55,7 +55,7 @@ describe('Create Bots', function() {
(wrap).should.throw('Invalid configuration file given');
});
it('should be possible to run it through require(\'discord-irc\')', function() {
it('should be possible to run it through require(\'discord-irc\')', function () {
const bots = index(singleTestConfig);
bots.length.should.equal(1);
this.connectStub.should.have.been.called;
+1 -1
View File
@@ -1,7 +1,7 @@
[
{
"server": "irc.bottest.org",
"token": "hei",
"discordToken": "hei",
"channelMapping": {
"#discord": "#irc"
}
+1 -2
View File
@@ -1,8 +1,7 @@
{
"nickname": "Reactiflux",
"server": "irc.freenode.net",
"discordEmail": "discord@test.com",
"discordPassword": "whatapassword",
"discordToken": "discord@test.com",
"commandCharacters": ["!", "."],
"autoSendCommands": [
["MODE", "test", "+x"],
+12
View File
@@ -0,0 +1,12 @@
{
"nickname": "Reactiflux",
"server": "irc.freenode.net",
"discordToken": "whatapassword",
"commandCharacters": ["!", "."],
"ircOptions": {
"encoding": "utf-8"
},
"channelMapping": {
"#discord": "#irc"
}
}
+15 -3
View File
@@ -1,15 +1,27 @@
{
"nickname": "Reactiflux",
"server": "irc.freenode.net",
"discordEmail": "discord@test.com",
"discordPassword": "whatapassword",
"discordToken": "whatapassword",
"commandCharacters": ["!", "."],
"ircOptions": {
"encoding": "utf-8"
},
"autoSendCommands": [
["MODE", "test", "+x"],
["AUTH", "test", "password"]
],
"channelMapping": {
"#discord": "#irc channelKey",
"#notinchannel": "#otherIRC"
"#notinchannel": "#otherIRC",
"1234": "#channelforid",
"#withwebhook": "#ircwebhook"
},
"webhooks": {
"#withwebhook": "https://discord.com/api/webhooks/id/token"
},
"ignoreUsers": {
"irc": ["irc_ignored_user"],
"discord": ["discord_ignored_user"],
"discordIds": ["4499"]
}
}
+8 -4
View File
@@ -2,8 +2,10 @@
{
"nickname": "test",
"server": "irc.freenode.net",
"discordEmail": "discord@test.com",
"discordPassword": /* comment */ "whatapassword",
"discordToken": /* comment */ "whatapassword",
"ircOptions": {
"encoding": "utf-8"
},
"channelMapping": {
"#discord": "#irc" // Comment
}
@@ -12,8 +14,10 @@
{
"nickname": "test2",
"server": "irc.freenode.net",
"discordEmail": "discord@test.com",
"discordPassword": "whatapassword",
"discordToken": "whatapassword",
"ircOptions": {
"encoding": "utf-8"
},
"channelMapping": {
"#discord": "#irc"
}
+8 -4
View File
@@ -2,8 +2,10 @@
{
"nickname": "test",
"server": "irc.freenode.net",
"discordEmail": "discord@test.com",
"discordPassword": "whatapassword",
"discordToken": "whatapassword",
"ircOptions": {
"encoding": "utf-8"
},
"channelMapping": {
"#discord": "#irc"
}
@@ -11,8 +13,10 @@
{
"nickname": "test2",
"server": "irc.freenode.net",
"discordEmail": "discord@test.com",
"discordPassword": "whatapassword",
"discordToken": "whatapassword",
"ircOptions": {
"encoding": "utf-8"
},
"channelMapping": {
"#discord": "#irc"
}
+8 -4
View File
@@ -2,8 +2,10 @@ module.exports = [
{
nickname: 'test',
server: 'irc.freenode.net',
discordEmail: 'discord@test.com',
discordPassword: 'whatapassword',
discordToken: 'whatapassword',
ircOptions: {
encoding: 'utf-8'
},
channelMapping: {
'#discord': '#irc'
}
@@ -11,8 +13,10 @@ module.exports = [
{
nickname: 'test2',
server: 'irc.freenode.net',
discordEmail: 'discord@test.com',
discordPassword: 'whatapassword',
discordToken: 'whatapassword',
ircOptions: {
encoding: 'utf-8'
},
channelMapping: {
'#discord': '#irc'
}
+64
View File
@@ -0,0 +1,64 @@
/* eslint-disable prefer-arrow-callback */
import chai from 'chai';
import { formatFromDiscordToIRC, formatFromIRCToDiscord } from '../lib/formatting';
chai.should();
describe('Formatting', () => {
describe('Discord to IRC', () => {
it('should convert bold markdown', () => {
formatFromDiscordToIRC('**text**').should.equal('\x02text\x02');
});
it('should convert italic markdown', () => {
formatFromDiscordToIRC('*text*').should.equal('\x1dtext\x1d');
formatFromDiscordToIRC('_text_').should.equal('\x1dtext\x1d');
});
it('should convert underline markdown', () => {
formatFromDiscordToIRC('__text__').should.equal('\x1ftext\x1f');
});
it('should ignore strikethrough markdown', () => {
formatFromDiscordToIRC('~~text~~').should.equal('text');
});
it('should convert nested markdown', () => {
formatFromDiscordToIRC('**bold *italics***')
.should.equal('\x02bold \x1ditalics\x1d\x02');
});
});
describe('IRC to Discord', () => {
it('should convert bold IRC format', () => {
formatFromIRCToDiscord('\x02text\x02').should.equal('**text**');
});
it('should convert reverse IRC format', () => {
formatFromIRCToDiscord('\x16text\x16').should.equal('*text*');
});
it('should convert italic IRC format', () => {
formatFromIRCToDiscord('\x1dtext\x1d').should.equal('*text*');
});
it('should convert underline IRC format', () => {
formatFromIRCToDiscord('\x1ftext\x1f').should.equal('__text__');
});
it('should ignore color IRC format', () => {
formatFromIRCToDiscord('\x0306,08text\x03').should.equal('text');
});
it('should convert nested IRC format', () => {
formatFromIRCToDiscord('\x02bold \x16italics\x16\x02')
.should.equal('**bold *italics***');
});
it('should convert nested IRC format', () => {
formatFromIRCToDiscord('\x02bold \x1funderline\x1f\x02')
.should.equal('**bold __underline__**');
});
});
});
+76 -24
View File
@@ -1,29 +1,81 @@
/* eslint-disable class-methods-use-this */
import events from 'events';
import sinon from 'sinon';
import discord from 'discord.js';
export function getChannel(key, value) {
if (key === 'name' && value !== 'discord') return null;
return {
name: 'discord',
id: 1234
export default function createDiscordStub(sendStub) {
return class DiscordStub extends events.EventEmitter {
constructor() {
super();
this.user = {
id: 'testid'
};
this.channels = new discord.ChannelManager(this, []);
this.options = {
http: {
cdn: ''
}
};
this.users = new discord.UserManager(this, []);
this.guilds = new discord.GuildManager(this, []);
const guild = this.createGuildStub();
this.guilds.cache.set(guild.id, guild);
this.rest = this.createRestStub();
}
destroy() {}
addTextChannel(guild, textChannel) {
const textChannelData = {
type: discord.Constants.ChannelTypes.TEXT,
...textChannel
};
const textChannelObj = new discord.TextChannel(guild, textChannelData);
textChannelObj.send = sendStub;
const permissions = new discord.Collection();
textChannelObj.setPermissionStub = (user, perms) => permissions.set(user, perms);
textChannelObj.permissionsFor = user => permissions.get(user);
this.channels.cache.set(textChannelObj.id, textChannelObj);
return textChannelObj;
}
createGuildStub(guildData = {}) {
const guild = {
id: '1',
client: this,
addTextChannel: (textChannel) => {
const textChannelObj = this.addTextChannel(guild, textChannel);
textChannelObj.guild.channels.cache.set(textChannelObj.id, textChannelObj);
return textChannelObj;
}
};
guild.roles = new discord.RoleManager(guild, []);
guild.members = new discord.GuildMemberManager(guild, []);
guild.emojis = new discord.GuildEmojiManager(guild, []);
guild.channels = new discord.GuildChannelManager(guild, []);
Object.assign(guild, guildData);
this.guilds.cache.set(guild.id, guild);
if (guild.id === '1') {
guild.addTextChannel({
name: 'discord',
id: '1234',
});
}
return guild;
}
createRestStub() {
return {
cdn: discord.Constants.Endpoints.CDN(''),
};
}
login() {
return sinon.stub();
}
};
}
class DiscordStub extends events.EventEmitter {
constructor() {
super();
this.user = {
id: 'testid'
};
this.channels = {
get: getChannel
};
}
login() {
return sinon.stub();
}
}
export default DiscordStub;
+9 -1
View File
@@ -1,5 +1,13 @@
import events from 'events';
class ClientStub extends events.EventEmitter {}
/* eslint-disable class-methods-use-this */
class ClientStub extends events.EventEmitter {
constructor(...args) {
super();
this.nick = args[1]; // eslint-disable-line prefer-destructuring
}
disconnect() {}
}
export default ClientStub;
+16
View File
@@ -0,0 +1,16 @@
/* eslint-disable class-methods-use-this */
export default function createWebhookStub(sendWebhookMessage) {
return class WebhookStub {
constructor(id, token) {
this.id = id;
this.token = token;
}
send(...args) {
sendWebhookMessage(...args);
return new Promise(() => {});
}
destroy() {}
};
}