mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-14 03:50:26 +00:00
Support bulk deletions (discord)
This commit is contained in:
parent
a5bd3c4dda
commit
76c7b69e4e
@ -75,6 +75,7 @@ func (b *Bdiscord) Connect() error {
|
|||||||
b.c.AddHandler(b.memberUpdate)
|
b.c.AddHandler(b.memberUpdate)
|
||||||
b.c.AddHandler(b.messageUpdate)
|
b.c.AddHandler(b.messageUpdate)
|
||||||
b.c.AddHandler(b.messageDelete)
|
b.c.AddHandler(b.messageDelete)
|
||||||
|
b.c.AddHandler(b.messageDeleteBulk)
|
||||||
b.c.AddHandler(b.memberAdd)
|
b.c.AddHandler(b.memberAdd)
|
||||||
b.c.AddHandler(b.memberRemove)
|
b.c.AddHandler(b.memberRemove)
|
||||||
err = b.c.Open()
|
err = b.c.Open()
|
||||||
|
@ -16,6 +16,27 @@ func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelet
|
|||||||
b.Remote <- rmsg
|
b.Remote <- rmsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(qaisjp): if other bridges support bulk deletions, it could be fanned out centrally
|
||||||
|
func (b *Bdiscord) messageDeleteBulk(s *discordgo.Session, m *discordgo.MessageDeleteBulk) { //nolint:unparam
|
||||||
|
for _, msgID := range m.Messages {
|
||||||
|
rmsg := config.Message{
|
||||||
|
Account: b.Account,
|
||||||
|
ID: msgID,
|
||||||
|
Event: config.EventMsgDelete,
|
||||||
|
Text: config.EventMsgDelete,
|
||||||
|
Channel: "ID:" + m.ChannelID,
|
||||||
|
}
|
||||||
|
|
||||||
|
if !b.useChannelID {
|
||||||
|
rmsg.Channel = b.getChannelName(m.ChannelID)
|
||||||
|
}
|
||||||
|
|
||||||
|
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
|
||||||
|
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||||
|
b.Remote <- rmsg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) { //nolint:unparam
|
func (b *Bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) { //nolint:unparam
|
||||||
if b.GetBool("EditDisable") {
|
if b.GetBool("EditDisable") {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user