Giter Site home page Giter Site logo

matrix-appservice-discord's Introduction

Matrix Discord Bridge

A bridge between Matrix and Discord. Currently the bridge is in Beta and quite usable for everyday bridging, with one or two bugs cropping up.

Screenshot of Element and Discord working together

Helping out

Build Status Docker Automated build #discord:half-shot.uk

PRs

PRs are graciously accepted, so please come talk to us in #discord-bridge:matrix.org about any neat ideas you might have. If you are going to make a change, please merge it with the develop branch :).

Issues

You can also file bug reports/ feature requests on Github Issues which also helps a ton. Please remember to include logs. Please also be aware that this is an unoffical project worked on in our spare time.

Setting up

The bridge has been tested against the Synapse homeserver, although any homeserver that implements the AS API should work with this bridge.

The bridge supports any version of Node.js between v18.X - v20.X. View the releases for more details.

The bridge uses Yarn for dependency management and package scripts. For the time being, only Yarn Classic / v1 is supported. To install it, follow these instructions.

If you already have Yarn 2+ installed, you may configure just this project to use Yarn Classic by running yarn set version classic in the directory where you cloned this repository.

Set up the bridge

  • Run yarn to grab the dependencies.

  • Copy config/config.sample.yaml to config.yaml and edit it to reflect your setup.

    • Note that you are expected to set domain and homeserverURL to your public host name. While localhost would work, it does not resolve correctly with Webhooks/Avatars. Please note that a self-signed SSL certificate won't work, either.
    bridge:
        domain: "example.com"
        homeserverUrl: "https://example.com"
  • Run yarn start -r -u "http://localhost:9005"

  • Modify your HSs appservices config so that it includes the generated file.

    • e.g. On synapse, adding to app_service_config_files array in homeserver.yaml
    app_service_config_files:
      - "discord-registration.yaml"
    • Copy discord-registration.yaml to your Synapse's directory.

Docker

Following the instructions above, generate a registration file. The file may also be hand-crafted if you're familiar with the layout. You'll need this file to use the Docker image.

# Create the volume where we'll keep the bridge's files
mkdir -p /matrix-appservice-discord

# Create the configuration file. Use the sample configuration file as a template.
# Be sure to set the database paths to something like this:
#  database:
#    filename: "/data/discord.db"
#    userStorePath: "/data/user-store.db"
#    roomStorePath: "/data/room-store.db"
nano /matrix-appservice-discord/config.yaml

# Copy the registration file to the volume
cp discord-registration.yaml /matrix-appservice-discord/discord-registration.yaml

# Optional: Build the container yourself (requires a git clone, and to be in the root of the project)
docker build -t halfshot/matrix-appservice-discord .

# Run the container
docker run -v /matrix-appservice-discord:/data -p 9005:9005 halfshot/matrix-appservice-discord

Metrics

The bridge supports reporting metrics via Prometheus. You can configure metrics support in the config file. The metrics will be reported under the URL provided in the registration file, on the /metrics endpoint.

3PID Protocol Support

This bridge support searching for rooms within networks via the 3pid system used in clients like Element. Any new servers/guilds you bridge should show up in the network list on Element and other clients.

Setting up Discord

  • Create a new application via https://discord.com/developers/applications
  • Make sure to create a bot user. Fill in config.yaml
  • Run yarn addbot to get a authorisation link.
  • Give this link to owners of the guilds you plan to bridge.
  • Finally, you can join a room with #_discord_guildid_channelid
    • These can be taken from the url ("/$GUILDID/$CHANNELID") when you are in a channel.
    • Element (and other clients with third party protocol support) users can directly join channels from the room directory.
  • You can use Webhooks to make messages relayed by the bridge not nested by the bot user. This will also display the avatar of the user speaking on matrix with their messages.
    • The bot should create this automatically, but if not perform the following:
      • Enable Manage Webhooks on the role added by the bot.
      • Add the _matrix Webhook for each channel you'd like to enable this feature on.

Running the Bridge

  • For the bot to appear online on Discord you need to run the bridge itself.
  • yarn start
  • Particular configuration keys can be overridden by defining corresponding environment variables. For instance, auth.botToken can be set with APPSERVICE_DISCORD_AUTH_BOT_TOKEN.

Howto

End User Documentation

Bridging a Room

You must get an authorization link from bridge owner. You must be a server admin or get help from server admin on Discord side.

  • Invite the Matrix side bot to your room and wait for it to join.
  • On Discord side use the authorization link to invite bot to Discord server.
  • Find out a serverid and channelid for your server/channel you want to bridge. Search the web for instructions.
  • In Matrix room give command !discord bridge ServerID ChannelID
  • The bridge will ask for confirmation from the Discord server admins to complete the bridge. Once approved, you're all set.

Unbridging a Room

  • In Matrix room give command !discord unbridge

Features and Roadmap

In a vague order of what is coming up next

  • Matrix -> Discord
    • Text content
    • Image content
    • Audio/Video content
    • Typing notifs (Not supported, requires syncing)
    • User Profiles
  • Discord -> Matrix
    • Text content
    • Image content
    • Audio/Video content
    • Typing notifs
    • User Profiles
    • Presence
    • Per-guild display names.
  • Group messages
  • Third Party Lookup
    • Rooms
    • Users
  • Puppet a user's real Discord account.
    • Sending messages
    • Direct messages
    • UI for setup
  • Rooms react to Discord updates
  • Integrate Discord into existing rooms
    • Feature
    • UI
  • Manage channel from Matrix (possibly)
    • Authorise admin rights from Discord to Matrix users
    • Topic
    • Room Name
  • Provisioning API
  • Webhooks (allows for prettier messages to discord)
  • VOIP (Hard | Unlikely to be finished anytime soon)

Contact

My Matrix ID: @Half-Shot:half-shot.uk

matrix-appservice-discord's People

Contributors

andrewferr avatar anoadragon453 avatar auscompgeek avatar captainbeyondds8 avatar eeeeeta avatar erdnaxe avatar fflorent avatar half-shot avatar jaller94 avatar jhui19 avatar johni0702 avatar karolyi avatar kmorton1988 avatar miepee avatar oleg-fiksel-acn avatar ollieh avatar opaquereptile avatar pacien avatar scrufulufugus avatar sethfalco avatar sorunome avatar ssweeny avatar tadzik avatar thestranjer avatar turboss avatar turt2live avatar v02460 avatar verymilan avatar vranki avatar zeratax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matrix-appservice-discord's Issues

Error with username in channel

WARN There was an error sending a matrix event SyntaxError: Invalid regular expression: /Smiley  =)/: Unmatched ')'
WARN There was an error sending a matrix event     at DiscordBot.HandleMentions (/root/matrix-appservice-discord/build/src/bot.js:228:33)
WARN There was an error sending a matrix event     at DiscordBot.MatrixEventToEmbed (/root/matrix-appservice-discord/build/src/bot.js:132:35)
WARN There was an error sending a matrix event     at DiscordBot.<anonymous> (/root/matrix-appservice-discord/build/src/bot.js:148:32)
WARN There was an error sending a matrix event     at next (native)
WARN There was an error sending a matrix event     at fulfilled (/root/matrix-appservice-discord/build/src/bot.js:4:58)
WARN There was an error sending a matrix event     at process._tickCallback (internal/process/next_tick.js:109:7)

discord-registration.yaml not generated

Either instructions arent clear, or I've done something wrong? For example, do I place the information for the bot BEFORE I run the build command, and where does the file output to, what is the name of the generated file? discord-registration.yaml?

EDIT: I was able to get it working with my initial questions being the answer.

It needs to be clarified in the documentation that you need to have the bot token, seceret, and bot id all in the config.yaml before running the build command to invite the bot, and that the file will drop in the root of the directory, called discord-registration.yaml. Also to add path/to/config.yaml as config.yaml did not work for me. Can be closed.

It may seem obvious, but honestly, if this is going for a wider appeal, it needs to be simplified and clarified.

Webhooks permission

Manage webhooks permission seem to be needed for the Discord bot to work properly (please verify). If that's really the case, just need to add the MANAGE_WEBHOOKS flag to addbot.ts

bot from develop branch only reacts one way

current develop branch only reacts one way on my matrix server:

discord -> matrix

the other way matrix -> discord doesn't work. bot log shows no error when sending the message.

Create bridge-test tests for the bridge

bridge-test is a versatile tool for running automated tests against bridges, and I'd like for some tests to be run on this too.

There is quite a bit more work involved than it first appears though. Bridge test requires a mockup of the services's API to be useful, so this could be quite difficult.

Can't join rooms on matrix

Discord side works (bot is online and recives presence changes from discord)
but i can't join the rooms on my local matrix server.

Bot log shows:
GET //rooms/%23_discord_22497740072xxxxxx_22497817263xxxxx%3Axxxxxx.de?access_token= HTTP/1.1" 404 160 "-" "Synapse/0.19.2"

Application service has not registered this user

Hi,

I successfully installed the bridge, configured it and run it. I configurated the HS.

I can see the room in matrix and the bot user.
I have the bot in discord.
I typed a message in matrix but it never comes in the discord chat and reciprocally
The bridge is running
The HS is running and has registered the bridge at startup
Here is my configuration (config.yaml):

bridge:
  domain: "exemple.org"
  homeserverUrl: "https://example.org"
  disablePresence: false
  disableTypingNotifications: false
  disableDiscordMentions: false
auth:
  clientID: "blablabla" # Get from discord
  secret: "blablabla"
  botToken: "blablabla"
logging:
  level: "warn" #silly, verbose, info, http, warn, error
database:
  filename: "discord.db"
verb DiscordBot Bulk presence update
verb matrix-appservice-bridge [-] PUT https://exemple.org/_matrix/client/r0/presence/%40_discord_1074867890098760%3Aexemple.org/status (@_discord_10678998762960:exemple.org) Body: {"presence":"unavailable"}
verb matrix-appservice-bridge [-] PUT https://exemple.org/_matrix/client/r0/presence/%40_discord_3576876567876482%3Aexemple.org/status (@_discord_357656789098776482:exemple.org) Body: {"presence":"online"}
verb matrix-appservice-bridge [-] PUT https://exemple.org/_matrix/client/r0/presence/%40_discord_3576366789876482%3Aexemple.org/status (@_discord_3576368765678909:exemple.org) HTTP 403 Error: {"errcode":"M_FORBIDDEN","error":"Application service has not registered this user"}
verb matrix-appservice-bridge [-] PUT https://exemple.org/_matrix/client/r0/presence/%40_discord_1074887656789060%3Aexemple.org/status (@_discord_10876789876789:exemple.org) HTTP 200 {}

Any idea about Application service has not registered this user 403 error?
Thanks for your help.

Scripts shouldn't need to sync to do an action

Scripts like the adminme script shouldn't need to sync to work. In cases where the discord bridge is potentially in hundreds of rooms, the js-sdk times out trying to get the initialSync done. Settings power levels for a room does not require syncing and it shouldn't need to.

For reference, here's the script I use to admin people on t2bot.io: https://gist.github.com/turt2live/f3de58d79aff02da0b2291031c87a6ec
It intentionally doesn't sync and just does a fetch of the current event and populates the required parts. It does make some assumptions about file names, however.

Group Guild Mapping

Just as you can join a matrix room and have it be bridged to a Discord room, would be cool if you could join a group with a special format and have a group be created with rooms linked to each channel in the Discord Server.

walle303: The format could be something like +_discord_guildid:homeserver

Spread out presence updates

Currently I'm seeing hundreds of presence updates every minute or so. It would be nice if this spike in load was spread out instead of being a spike.

Update profile before joining room

For the somewhat rare case of people bridging irc <--> matrix <--> discord. When the discord bridge joins the user to the matrix room it doesn't always have a display name set, so the IRC bridge picks up the user ID, leading to IRC users not having a clue who is speaking.

Blocking the join on a successful profile update would seem reasonable to me.

npm run-script build fails

Hello !

Thanks for the work of a pretty good developpment of a bridge with Matrix ecosystem

When I run npm run-script build, I face to that error. Any clues ?

> [email protected] build /home/blabla/matrix/bridges/matrix-appservice-discord
> tsc

src/discordbot.ts(85,5): error TS2322: Type 'Promise<GuildChannel>' is not assignable to type 'Promise<TextChannel>'.
  Type 'GuildChannel' is not assignable to type 'TextChannel'.
    Property 'lastMessageID' is missing in type 'GuildChannel'.
src/discordbot.ts(229,9): error TS2322: Type '"unavailable"' is not assignable to type '"offline" | "online" | "idle" | "dnd"'.

Kind regards

npm run-script build fails

Develop (a956b18) branch

node --version
v6.11.1
npm --version
5.3.0
โ””> npm install                                                                                                                                                                           <<<
npm WARN deprecated @types/[email protected]: Use '--lib es6' to get Promise types.
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

> [email protected] install /opt/discord/matrix-appservice-discord/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/bin/node',
node-pre-gyp verb cli   '/opt/discord/matrix-appservice-discord/node_modules/sqlite3/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | linux | arm
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/opt/discord/matrix-appservice-discord/node_modules/sqlite3/lib/binding/node-v48-linux-arm/node_sqlite3.node" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v48-linux-arm.tar.gz
node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v48-linux-arm.tar.gz
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v48-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v48 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v48-linux-arm.tar.gz
node-pre-gyp verb command build [ 'rebuild' ]
make: Entering directory '/opt/discord/matrix-appservice-discord/node_modules/sqlite3/build'
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3150000/sqlite3.o

<snip> sqlite make build on armv7h </snip>

make: Leaving directory '/opt/discord/matrix-appservice-discord/node_modules/sqlite3/build'
node-pre-gyp info ok
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of bufferutil@^3.0.0 but none was installed.
npm WARN [email protected] requires a peer of erlpack@hammerandchisel/erlpack but none was installed.
npm WARN [email protected] requires a peer of node-opus@^0.2.5 but none was installed.
npm WARN [email protected] requires a peer of opusscript@^0.0.3 but none was installed.
npm WARN [email protected] requires a peer of sodium@^2.0.1 but none was installed.
npm WARN [email protected] requires a peer of libsodium-wrappers@^0.5.1 but none was installed.
npm WARN [email protected] requires a peer of uws@^0.14.1 but none was installed.

added 742 packages in 790.797s
npm run-script build

> [email protected] build /opt/discord/matrix-appservice-discord
> tsc

src/dbschema/v1.ts(6,5): error TS2322: Type 'Promise<Error>' is not assignable to type 'Promise<null>'.
  Type 'Error' is not assignable to type 'null'.
src/dbschema/v2.ts(6,5): error TS2322: Type 'Promise<[Error, Error]>' is not assignable to type 'Promise<null>'.
  Type '[Error, Error]' is not assignable to type 'null'.
src/dbschema/v3.ts(38,5): error TS2322: Type 'Promise<[any, any]>' is not assignable to type 'Promise<null>'.
  Type '[any, any]' is not assignable to type 'null'.
src/store.ts(26,7): error TS2322: Type 'Promise<void>' is not assignable to type 'Promise<null>'.
  Type 'void' is not assignable to type 'null'.
src/store.ts(30,5): error TS2322: Type 'Promise<{}>' is not assignable to type 'Promise<null>'.
  Type '{}' is not assignable to type 'null'.
test/mocks/discordclientfactory.ts(9,5): error TS2322: Type 'Promise<void>' is not assignable to type 'Promise<null>'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Presence seems to become desynchronized from registered users

2017-07-17 18:14:13,875 - synapse.http.server - 123 - INFO - PUT-4755844- <XForwardedForRequest at 0x7f7bd6c6a488 method=PUT uri=/_matrix/client/r0/presence/%40_discord_275408063312429056%3At2bot.io/status?access_token=<redacted>&user_id=%40_discord_275408063312429056%3At2bot.io clientproto=HTTP/1.0 site=8008> SynapseError: 403 - Application service has not registered this user

Saw the above error in my logs. It should have the user registered, shouldn't it?

Display custom emotes from discord

As Riot is now capable of displaying inline images using mxc:// URLs in img tags as of 0.12, it should be possible to display custom emotes from discord.

Example:
015

With this being the content of the message

{
    "body": "Kappa this Kappa is Kappa a Kappa test Kappa",
    "msgtype": "m.text",
    "formatted_body": "<img title=\"Kappa\" height=\"42\" width=\"32\" src=\"mxc://kek.community/ERVtAdcAFAJkFzCZSDNtscSA\"></img> this <img title=\"Kappa\" height=\"42\" width=\"32\" src=\"mxc://kek.community/ERVtAdcAFAJkFzCZSDNtscSA\"></img> is <img title=\"Kappa\" height=\"42\" width=\"32\" src=\"mxc://kek.community/ERVtAdcAFAJkFzCZSDNtscSA\"></img> a <img title=\"Kappa\" height=\"42\" width=\"32\" src=\"mxc://kek.community/ERVtAdcAFAJkFzCZSDNtscSA\"></img> test <img title=\"Kappa\" height=\"42\" width=\"32\" src=\"mxc://kek.community/ERVtAdcAFAJkFzCZSDNtscSA\"></img>",
    "format": "org.matrix.custom.html"
  }

Proxy embeds to Matrix

Many other Discord bots use embeds to communicate what is going on. It would be nice to see these in Matrix, at least at a rudimentary level.

iirc, embeds are also used for quoting other users.

Send messages from discord to matrix and reciprocally

Hi,

I successfully installed the bridge, configured it and run it. I configurated the HS but maybe I missed something...

  1. I can see the room in matrix and the bot user.
  2. I have the bot in discord.
  3. I typed a message in matrix but it never comes in the discord chat and reciprocally
  4. The bridge is running
  5. The HS is running and has registered the bridge at startup

Here is my configuration (config.yaml):

bridge:
  domain: "localhost"
  homeserverUrl: "http://localhost:8008"
  disablePresence: false
  disableTypingNotifications: false
  disableDiscordMentions: false
auth:
  clientID: "blablabla" # Get from discord
  secret: "blablabla"
  botToken: "blablabla"
logging:
  level: "warn" #silly, verbose, info, http, warn, error
database:
  filename: "discord.db"
info discordas Starting Discord AS
info discordas Initing bridge.
info AppServ Started listening on port 9005 at Wed, 13 Sep 2017 22:44:52 GMT
info discordas Initing store.
info DiscordStore Starting DB Init
info DiscordStore Opening SQLITE database discord.db
info DiscordStore Updated database to the latest schema
info discordas Initing bot.
info DiscordBot Discord bot client logged in.
verb DiscordBot Bulk presence update
verb matrix-appservice-bridge [-] PUT http://localhost:8008/_matrix/client/r0/presence/%40_discord_107486792604712960%3Alocalhost/status (@_discord_107486792604712960:localhost) Body: {"presence":"online"}
verb matrix-appservice-bridge [-] PUT http://localhost:8008/_matrix/client/r0/presence/%40_discord_357636529696276482%3Alocalhost/status (@_discord_357636529696276482:localhost) Body: {"presence":"online"}
info discordas Discordbot started successfully.
verb matrix-appservice-bridge [-] PUT http://localhost:8008/_matrix/client/r0/presence/%40_discord_107486792604712960%3Alocalhost/status (@_discord_107486792604712960:localhost) HTTP 403 Error: {"errcode":"M_FORBIDDEN","error":"Application service has not registered this user"}
verb matrix-appservice-bridge [-] PUT http://localhost:8008/_matrix/client/r0/presence/%40_discord_357636529696276482%3Alocalhost/status (@_discord_357636529696276482:localhost) HTTP 403 Error: {"errcode":"M_FORBIDDEN","error":"Application service has not registered this user"}

Any clues ?
Thanks for your help.

Room icons on matrix side

Discord doesn't seem to have per-room icons, however each guild does seem to have an icon. Maybe use the guild icon as the room icon until matrix supports groups/threading/whatever?

Webhooks sent in Discord carry over as a random user

2017-09-27-134619

2017-09-27-134308

Alright, so here I'm doing an experiment with "editing" other user's messages. You send a message, the bot records it, deletes the original, then posts a new message as a webhook under your name and avatar.

This works fine on the Discord side as you can see from the above screenshot, but the bridge gets confused with the webhook talking in the channel and prints it as (in my experience) some random user.

The webhook isn't a real user on either Matrix or Discord, so I can see why it would be confused, but we should be able to still get the avatar and name of the webhook to pass it over the bridge, right? Maybe just have a fake user on the Matrix side for posting webhooks? Perhaps that user would change their nick and avatar every time to match the webhook's? :P


Edit:
2017-09-27-141350

2017-09-27-141235

It seems that a new user is already created for the webhook, and it changes its name and avatar already based on the webhook. However if I spawn another webhook, the avatar and name isn't changed again (the Peppermint Lime#4801#0000 should be Violet Ray instead). Also I'm not sure what's up with the double #xxxx#xxxx's. Also my nick changed for some reason, when it shouldn't.

URL previews for images from Discord appear to bridge

Discord:
image
Only the URL was sent, the image is a result of the Discord url previewing.

Riot/matrix:
image
Again, the image is a result of the URL preview.

The concern is with the strange-looking message that got bridged. Here is the source from Riot:

{
  "origin_server_ts": 1507437246988,
  "sender": "@_discord_215664408641273858:t2bot.io",
  "event_id": "$150743724620527VwIlZ:t2bot.io",
  "unsigned": {
    "age": 139
  },
  "content": {
    "body": "https://t2bot.io/img/logos/mx-discord.png\n\n----\n##### [undefined](https://t2bot.io/img/logos/mx-discord.png)",
    "msgtype": "m.text",
    "formatted_body": "<p><a href=\"https://t2bot.io/img/logos/mx-discord.png\">https://t2bot.io/img/logos/mx-discord.png</a></p>\n<hr>\n<h5 id=\"-undefined-https-t2bot-io-img-logos-mx-discord-png-\"><a href=\"https://t2bot.io/img/logos/mx-discord.png\">undefined</a></h5>\n",
    "format": "org.matrix.custom.html"
  },
  "type": "m.room.message",
  "room_id": "!pDynKLEzozBZzARqct:t2bot.io"
}

Deleted channels are handled awkwardly

There should be some kind of indication when a channel is deleted, because in their current state, deleted channels do not show any sign of deletion, and can cause confusion.

Some of the following should be done to reduce confusion:

  • Changing name/topic
  • Setting message sending power level to 100
  • Room directory delisting[Current homeserver only, obviously]
  • Unsetting appservice room alias
  • Setting invite only mode.
  • Parting all appservice ghosts
  • Stop bridging join/parts&avatar/nick changes

Config option to make new rooms non-public by default

Users of my bridge can connect to any discord channel, and it'll display on the public room directory.

...This might not be ideal, for reasons.

The ability to tell the bot to mark new rooms as not public (specifically to set m.room.join_rules to 'invite' instead of 'public'), would be really helpful!

Check for attachments once discord.js 11.2.0 is released

        };
        // Uncomment this and remove !hasAttachment above after https://github.com/hydrabolt/discord.js/pull/1449 pulled
        // if (hasAttachment) {
        //   hookOpts.file = opts.file;
        //   msg = await hook.send(embed.description, hookOpts);
        // } else {
        msg = await hook.send(embed.description, hookOpts);
// }

From: https://github.com/Half-Shot/matrix-appservice-discord/blob/develop/src/bot.ts#L206

discordjs/discord.js#1449 is now merged, so maybe you want to uncomment it? :P

Ability to mark first user that joins as an admin

As a convenience option, marking the first matrix user that joins the room as room admin would avoid having the run the adminme tool each time a room is created.

If somebody else joins the room before you and becomes admin, you can just use adminme at that point to correct the permissions.

Mention parser is too strict

2017-09-17-043945

Currently the regex code for mention parsing will only create a mention if we type the user's displayname exactly.

At the very least this should be case-insensitive, and at most allow for matching their Discord ID (username#1234) as well as everything previously mentioned with an '@' in front.

Text used in above image:

* Pouar
* pouar#5184
* @Pouar
* pouar

'types/chai-as-promised' is not in the npm registry.

Hi there, looks like we have a tiny problem :)

npm ERR! 404 Not Found
npm ERR! 404 
npm ERR! 404 'types/chai-as-promised' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 It was specified as a dependency of 'matrix-appservice-discord'
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Linux 4.9.11-1-ARCH
npm ERR! command "/home/user/.nvm/v0.10.32/bin/node" "/home/technics/.nvm/v0.10.32/bin/npm" "install"
npm ERR! cwd /home/user/app/matrix-appservice-discord
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code E404
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/user/app/matrix-appservice-discord/npm-debug.log
npm ERR! not ok code 0

Multiple runs of npm start break database

Running npm start initially works fine and the bot starts up. However killing the process and running npm start again causes the following error output, forcing a full recreation of the database to start correctly again:

WARN MatrixRoomHandler Skipping event due to age 13307669916 > 900000 
WARN MatrixRoomHandler Skipping event due to age 323627349 > 900000 
 
^C 
root@ubuntu:~/.matrix-appservice-discord# npm start 
 
> [email protected] start /root/.matrix-appservice-discord 
> npm run-script build && node ./build/src/discordas.js -p 9005 -c config.yaml 
 
 
> [email protected] build /root/.matrix-appservice-discord 
> tsc 
 
Loading config file /root/.matrix-appservice-discord/config.yaml 
ERR! DiscordStore Couldn't update database to schema 2 
ERR! DiscordStore Error: Error creating 'dm_rooms': Error: SQLITE_ERROR: table dm_rooms already exists 
ERR! DiscordStore     at db.runAsync.then.catch (/root/.matrix-appservice-discord/build/src/store.js:96:19) 
ERR! DiscordStore     at tryCatcher (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/util.js:16:23) 
ERR! DiscordStore     at Promise._settlePromiseFromHandler (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:512:31) 
ERR! DiscordStore     at Promise._settlePromise (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:569:18) 
ERR! DiscordStore     at Promise._settlePromise0 (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:614:10) 
ERR! DiscordStore     at Promise._settlePromises (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:689:18) 
ERR! DiscordStore     at Async._drainQueue (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:133:16) 
ERR! DiscordStore     at Async._drainQueues (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:143:10) 
ERR! DiscordStore     at Immediate.Async.drainQueues (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:17:14) 
ERR! DiscordStore     at runCallback (timers.js:672:20) 
ERR! DiscordStore     at tryOnImmediate (timers.js:645:5) 
ERR! DiscordStore     at processImmediate [as _immediateCallback] (timers.js:617:5) 
ERR! DiscordStore  { Error: Error creating 'dm_rooms': Error: SQLITE_ERROR: table dm_rooms already exists 
ERR! DiscordStore     at db.runAsync.then.catch (/root/.matrix-appservice-discord/build/src/store.js:96:19) 
ERR! DiscordStore     at tryCatcher (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/util.js:16:23) 
ERR! DiscordStore     at Promise._settlePromiseFromHandler (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:512:31) 
ERR! DiscordStore     at Promise._settlePromise (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:569:18) 
ERR! DiscordStore     at Promise._settlePromise0 (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:614:10) 
ERR! DiscordStore     at Promise._settlePromises (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:689:18) 
ERR! DiscordStore     at Async._drainQueue (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:133:16)
ERR! DiscordStore     at Async._drainQueues (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:143:10)
ERR! DiscordStore     at Immediate.Async.drainQueues (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:17:14)
ERR! DiscordStore     at runCallback (timers.js:672:20)
ERR! DiscordStore     at tryOnImmediate (timers.js:645:5)
ERR! DiscordStore     at processImmediate [as _immediateCallback] (timers.js:617:5)
ERR! DiscordStore   stack: 'Error: Error creating \'dm_rooms\': Error: SQLITE_ERROR: table dm_rooms already exists\n    at db.runAsync.then.catch (/root/.matrix-appservice-discord/build/src/store.js:96:19)\n    at tryCatcher (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:512:31)\n    at Promise._settlePromise (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:569:18)\n    at Promise._settlePromise0 (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:614:10)\n    at Promise._settlePromises (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/promise.js:689:18)\n    at Async._drainQueue (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:133:16)\n    at Async._drainQueues (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:143:10)\n    at Immediate.Async.drainQueues (/root/.matrix-appservice-discord/node_modules/bluebird/js/release/async.js:17:14)\n    at runCallback (timers.js:672:20)\n    at tryOnImmediate (timers.js:645:5)\n    at processImmediate [as _immediateCallback] (timers.js:617:5)' }
ERR! discordas Error: Failure to update to latest schema.
ERR! discordas     at Error (native)
ERR! discordas     at DiscordStore.<anonymous> (/root/.matrix-appservice-discord/build/src/store.js:81:27)
ERR! discordas     at next (native)
ERR! discordas     at fulfilled (/root/.matrix-appservice-discord/build/src/store.js:4:58)
ERR! discordas  { Error: Failure to update to latest schema.
ERR! discordas     at Error (native)
ERR! discordas     at DiscordStore.<anonymous> (/root/.matrix-appservice-discord/build/src/store.js:81:27)
ERR! discordas     at next (native)
ERR! discordas     at fulfilled (/root/.matrix-appservice-discord/build/src/store.js:4:58)
ERR! discordas   stack: 'Error: Failure to update to latest schema.\n    at Error (native)\n    at DiscordStore.<anonymous> (/root/.matrix-appservice-discord/build/src/store.js:81:27)\n    at next (native)\n    at fulfilled (/root/.matrix-appservice-discord/build/src/store.js:4:58)' }
ERR! discordas Failure during startup. Exiting.

npm ERR! Linux 4.9.7-x86_64-linode80
npm ERR! argv "/root/.nvm/versions/node/v6.11.1/bin/node" "/root/.nvm/versions/node/v6.11.1/bin/npm" "start"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `npm run-script build && node ./build/src/discordas.js -p 9005 -c config.yaml`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script 'npm run-script build && node ./build/src/discordas.js -p 9005 -c config.yaml'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the matrix-appservice-discord package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run-script build && node ./build/src/discordas.js -p 9005 -c config.yaml
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs matrix-appservice-discord
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls matrix-appservice-discord
npm ERR! There is likely additional logging output above.
 
npm ERR! Please include the following file with any support request:
npm ERR!     /root/.matrix-appservice-discord/npm-debug.log
root@ubuntu:~/.matrix-appservice-discord#

Bridge Message Edits

screenshot_20170930-083045

This is how the gitter bridge shows message edits without the ability to edit messages on the matrix side and I thought it was gorgeous. The repo for that bridge is here.

I do not believe you can edit webhook messages, but once/if matrix gets message editing capabilities, we can send a similar message on the discord side, however perhaps with italics rather than colors, as discord is monocolor.

Unable to register bot user error after restarting bridge

Right, so after upgrading the bridge to a new commit, I tried regenerating the config file and seem to have gotten myself into quite a pickle. At the moment, the bot can POST user's messages from Discord into Matrix, but it's not sending messages back over from Matrix to Discord.

Doing some digging, I found the following in the logs:

verb matrix-appservice-bridge [-] POST http://public.url:8008/_matrix/client/r0/register (AS) Body: {"auth":{},"username":"_discord_306101814091055113"}
verb matrix-appservice-bridge [-] POST http://public.url:8008/_matrix/client/r0/register (AS) HTTP 400 Error: {"errcode":"M_USER_IN_USE","error":"User ID already taken."}
...
verb matrix-appservice-bridge [-] PUT http://public.url:8008/_matrix/client/r0/presence/%40_discord_342097752093884417%3Apublic.url/status (@_discord_342097752093884417:public.url) HTTP 403 Error: {"errcode":"M_FORBIDDEN","error":"Application service has not registered this user"}

It seems that the bot is trying to re-register the same user, and not handling the error if that user already exists, thus getting errors down the line as it tries to use that user which it wasn't allowed to create.

Instead, it would be best if it could realize that the user was already registered and just log in as them, or barring that, create a new user with a different name if the user_id is already taken.

Bot mentions users with special characters in name when messaging matrix -> discord

Updated with:
get pull remote: Counting objects: 34, done. remote: Compressing objects: 100% (3/3), done. remote: Total 34 (delta 23), reused 24 (delta 23), pack-reused 8 Unpacking objects: 100% (34/34), done. From https://github.com/Half-Shot/matrix-appservice-discord a956b18..9c1b5be develop -> origin/develop Updating a956b18..9c1b5be

Then ran like normal:
node ./build/src/discordas.js -p 9005 -c config.yaml

The bot started adding mentions to an online user with special characters in their name to every character in the message from matrix.
Matrix -> Discord message: test
Discord displays: @... t @... e @... s @... t @...

Logs are normal; no unusual error reporting,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.