From d088da41b4a3896852fd5dbb8765d05ed13e744a Mon Sep 17 00:00:00 2001 From: Will Hunt <half-shot@molrams.com> Date: Sat, 18 Feb 2017 17:44:29 +0000 Subject: [PATCH] Add support for file uploads --- README.md | 12 ++++++------ src/discordbot.ts | 8 ++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f5dec01..e475dbf 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,16 @@ A very WIP bridge between Matrix and Discord in node. - [ ] Initiating - Matrix -> Discord - [x] Text content - - [ ] Image content - - [ ] Audio/Video content - - [ ] Typing notifs + - [x] Image content + - [x] Audio/Video content + - [ ] Typing notifs (**Not supported, requires syncing**) - [x] User Profiles - Discord -> Matrix - [x] Text content - - [ ] Image content - - [ ] Audio/Video content + - [x] Image content + - [x] Audio/Video content - [x] Typing notifs - - [ ] User Profiles + - [x] User Profiles - [ ] Presence - [ ] Webhooks (allows for prettier messages to discord) - [ ] Rooms react to Discord updates diff --git a/src/discordbot.ts b/src/discordbot.ts index cc5ac86..da30362 100644 --- a/src/discordbot.ts +++ b/src/discordbot.ts @@ -52,13 +52,10 @@ export class DiscordBot { } public ProcessMatrixMsgEvent(event, guild_id: string, channel_id: string): Promise<any> { - if (["m.text", "m.image"].indexOf(event.content.msgtype) === -1) { - return Promise.reject("The AS doesn't support non m.text messages"); - } let chan; let embed; const mxClient = this.bridge.getClientFactory().getClientAs(); - this.LookupRoom(guild_id, channel_id).then((channel) => { + return this.LookupRoom(guild_id, channel_id).then((channel) => { chan = channel; return mxClient.getProfileInfo(event.sender); }).then((profile) => { @@ -77,7 +74,7 @@ export class DiscordBot { }, description: event.content.body, }); - if (event.content.msgtype === "m.image") { + if (["m.image", "m.audio", "m.video", "m.file"].indexOf(event.content.msgtype) !== -1) { return Util.DownloadFile(mxClient.mxcUrlToHttp(event.content.url)); } else { @@ -95,7 +92,6 @@ export class DiscordBot { return {} }).then((opts) => { chan.sendEmbed(embed, opts); - log.info("DiscordBot", "Outgoing Message ", embed); }).catch((err) => { log.error("DiscordBot", "Couldn't send message. ", err); }); -- GitLab