ソースを参照

Add basic support for incoming voice messages

Tulir Asokan 2 年 前
コミット
ed020c4233
3 ファイル変更15 行追加3 行削除
  1. 1 1
      go.mod
  2. 2 2
      go.sum
  3. 12 0
      portal_convert.go

+ 1 - 1
go.mod

@@ -37,4 +37,4 @@ require (
 	maunium.net/go/mauflag v1.0.0 // indirect
 )
 
-replace github.com/bwmarrin/discordgo => github.com/beeper/discordgo v0.0.0-20230301201402-cf4c62e5f53d
+replace github.com/bwmarrin/discordgo => github.com/beeper/discordgo v0.0.0-20230416132336-325ee6a8c961

+ 2 - 2
go.sum

@@ -1,6 +1,6 @@
 github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
-github.com/beeper/discordgo v0.0.0-20230301201402-cf4c62e5f53d h1:xo6A9gSSu7mnxIXHBD1EPDyKEQFlI0N8r57Yf0gWiy8=
-github.com/beeper/discordgo v0.0.0-20230301201402-cf4c62e5f53d/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
+github.com/beeper/discordgo v0.0.0-20230416132336-325ee6a8c961 h1:eSGaliexlehYBeP4YQW8dQpV9XWWgfR1qH8kfHgrDcY=
+github.com/beeper/discordgo v0.0.0-20230416132336-325ee6a8c961/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
 github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

+ 12 - 0
portal_convert.go

@@ -137,9 +137,20 @@ func (portal *Portal) convertDiscordAttachment(intent *appservice.IntentAPI, att
 		content.FileName = att.Filename
 	}
 
+	var extra map[string]any
+
 	switch strings.ToLower(strings.Split(att.ContentType, "/")[0]) {
 	case "audio":
 		content.MsgType = event.MsgAudio
+		if att.Waveform != nil {
+			// TODO convert waveform
+			extra = map[string]any{
+				"org.matrix.1767.audio": map[string]any{
+					"duration": int(att.DurationSeconds * 1000),
+				},
+				"org.matrix.msc3245.voice": map[string]any{},
+			}
+		}
 	case "image":
 		content.MsgType = event.MsgImage
 	case "video":
@@ -152,6 +163,7 @@ func (portal *Portal) convertDiscordAttachment(intent *appservice.IntentAPI, att
 		AttachmentID: att.ID,
 		Type:         event.EventMessage,
 		Content:      content,
+		Extra:        extra,
 	}
 }