Handle Matrix stickers as images. Closes #33
This commit is contained in:
2
go.mod
2
go.mod
@@ -33,4 +33,4 @@ require (
|
|||||||
maunium.net/go/mauflag v1.0.0 // indirect
|
maunium.net/go/mauflag v1.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/bwmarrin/discordgo => github.com/beeper/discordgo v0.0.0-20230128125530-7c5c85c576ec
|
replace github.com/bwmarrin/discordgo => github.com/beeper/discordgo v0.0.0-20230128130408-ec0d4a43f122
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -1,6 +1,6 @@
|
|||||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||||
github.com/beeper/discordgo v0.0.0-20230128125530-7c5c85c576ec h1:/qfpiffS/BMmkHigNz+3n2216oY67i1UvMoe5B6Baes=
|
github.com/beeper/discordgo v0.0.0-20230128130408-ec0d4a43f122 h1:VbdWGvPQbbxURlc6bmEbluJo2jv/FwwBGVb1zX9E+7o=
|
||||||
github.com/beeper/discordgo v0.0.0-20230128125530-7c5c85c576ec/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
github.com/beeper/discordgo v0.0.0-20230128130408-ec0d4a43f122/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||||
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
|||||||
23
portal.go
23
portal.go
@@ -11,13 +11,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"maunium.net/go/mautrix/bridge/status"
|
|
||||||
"maunium.net/go/mautrix/crypto/attachment"
|
|
||||||
"maunium.net/go/mautrix/format"
|
|
||||||
"maunium.net/go/mautrix/util"
|
|
||||||
"maunium.net/go/mautrix/util/variationselector"
|
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"github.com/gabriel-vasile/mimetype"
|
||||||
|
|
||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
|
|
||||||
@@ -25,8 +20,13 @@ import (
|
|||||||
"maunium.net/go/mautrix/appservice"
|
"maunium.net/go/mautrix/appservice"
|
||||||
"maunium.net/go/mautrix/bridge"
|
"maunium.net/go/mautrix/bridge"
|
||||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
||||||
|
"maunium.net/go/mautrix/bridge/status"
|
||||||
|
"maunium.net/go/mautrix/crypto/attachment"
|
||||||
"maunium.net/go/mautrix/event"
|
"maunium.net/go/mautrix/event"
|
||||||
|
"maunium.net/go/mautrix/format"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
"maunium.net/go/mautrix/util"
|
||||||
|
"maunium.net/go/mautrix/util/variationselector"
|
||||||
|
|
||||||
"go.mau.fi/mautrix-discord/config"
|
"go.mau.fi/mautrix-discord/config"
|
||||||
"go.mau.fi/mautrix-discord/database"
|
"go.mau.fi/mautrix-discord/database"
|
||||||
@@ -1262,7 +1262,7 @@ func (portal *Portal) sendMatrixMessage(intent *appservice.IntentAPI, eventType
|
|||||||
|
|
||||||
func (portal *Portal) handleMatrixMessages(msg portalMatrixMessage) {
|
func (portal *Portal) handleMatrixMessages(msg portalMatrixMessage) {
|
||||||
switch msg.evt.Type {
|
switch msg.evt.Type {
|
||||||
case event.EventMessage:
|
case event.EventMessage, event.EventSticker:
|
||||||
portal.handleMatrixMessage(msg.user, msg.evt)
|
portal.handleMatrixMessage(msg.user, msg.evt)
|
||||||
case event.EventRedaction:
|
case event.EventRedaction:
|
||||||
portal.handleMatrixRedaction(msg.user, msg.evt)
|
portal.handleMatrixRedaction(msg.user, msg.evt)
|
||||||
@@ -1435,7 +1435,7 @@ func (portal *Portal) sendStatusEvent(evtID id.EventID, err error) {
|
|||||||
func (portal *Portal) sendMessageMetrics(evt *event.Event, err error, part string) {
|
func (portal *Portal) sendMessageMetrics(evt *event.Event, err error, part string) {
|
||||||
var msgType string
|
var msgType string
|
||||||
switch evt.Type {
|
switch evt.Type {
|
||||||
case event.EventMessage:
|
case event.EventMessage, event.EventSticker:
|
||||||
msgType = "message"
|
msgType = "message"
|
||||||
case event.EventReaction:
|
case event.EventReaction:
|
||||||
msgType = "reaction"
|
msgType = "reaction"
|
||||||
@@ -1513,6 +1513,13 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
|
|||||||
|
|
||||||
var sendReq discordgo.MessageSend
|
var sendReq discordgo.MessageSend
|
||||||
|
|
||||||
|
if evt.Type == event.EventSticker {
|
||||||
|
content.MsgType = event.MsgImage
|
||||||
|
if mimeData := mimetype.Lookup(content.Info.MimeType); mimeData != nil {
|
||||||
|
content.Body = "sticker" + mimeData.Extension()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch content.MsgType {
|
switch content.MsgType {
|
||||||
case event.MsgText, event.MsgEmote, event.MsgNotice:
|
case event.MsgText, event.MsgEmote, event.MsgNotice:
|
||||||
if replyToMXID := content.RelatesTo.GetNonFallbackReplyTo(); replyToMXID != "" {
|
if replyToMXID := content.RelatesTo.GetNonFallbackReplyTo(); replyToMXID != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user