implement steam->matrix image sending

This commit is contained in:
Robin Appelman 2020-05-09 14:18:12 +02:00
commit d4893cf67b
2 changed files with 21 additions and 3 deletions

View file

@ -11,6 +11,13 @@ export interface IIncomingFriendMessage {
ordinal: number,
local_echo: boolean,
low_priority: boolean
message_bbcode_parsed: BBCodeNode[]
}
export interface BBCodeNode {
tag: string
attrs: { [attr: string]: string },
content: BBCodeNode[]
}
export interface IIncomingChatMessage {

View file

@ -205,10 +205,21 @@ export class Steam {
const p = this.puppets[puppetId];
log.verbose("Got message from steam to pass on");
await this.bridge.sendMessage(await this.getSendParams(puppetId, message, fromSteamId), {
body: message.message,
let sendParams = await this.getSendParams(puppetId, message, fromSteamId);
// message is only an embedded image
if (
message.message_bbcode_parsed.length === 1
&& message.message_bbcode_parsed[0].tag === 'img'
&& message.message_no_bbcode === message.message_bbcode_parsed[0].attrs['src']
) {
await this.bridge.sendImage(sendParams, message.message_bbcode_parsed[0].attrs['src']);
} else {
await this.bridge.sendMessage(sendParams, {
body: message.message_no_bbcode,
});
}
}
public async handleFriendTyping(puppetId: number, message: IIncomingFriendMessage) {
await this.bridge.setUserTyping({