mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-21 10:12:00 -08:00
Add support for edited messages (discord)
This commit is contained in:
parent
02612c0061
commit
d1dd6c3440
@ -52,6 +52,7 @@ func (b *bdiscord) Connect() error {
|
|||||||
flog.Info("Connection succeeded")
|
flog.Info("Connection succeeded")
|
||||||
b.c.AddHandler(b.messageCreate)
|
b.c.AddHandler(b.messageCreate)
|
||||||
b.c.AddHandler(b.memberUpdate)
|
b.c.AddHandler(b.memberUpdate)
|
||||||
|
b.c.AddHandler(b.messageUpdate)
|
||||||
err = b.c.Open()
|
err = b.c.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
flog.Debugf("%#v", err)
|
flog.Debugf("%#v", err)
|
||||||
@ -104,6 +105,18 @@ func (b *bdiscord) Send(msg config.Message) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) {
|
||||||
|
if b.Config.EditDisable {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// only when message is actually edited
|
||||||
|
if m.Message.EditedTimestamp != "" {
|
||||||
|
flog.Debugf("Sending edit message")
|
||||||
|
m.Content = m.Content + b.Config.EditSuffix
|
||||||
|
b.messageCreate(s, (*discordgo.MessageCreate)(m))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
// not relay our own messages
|
// not relay our own messages
|
||||||
if m.Author.Username == b.Nick {
|
if m.Author.Username == b.Nick {
|
||||||
|
@ -391,6 +391,14 @@ Token="Yourtokenhere"
|
|||||||
#REQUIRED
|
#REQUIRED
|
||||||
Server="yourservername"
|
Server="yourservername"
|
||||||
|
|
||||||
|
#Disable sending of edits to other bridges
|
||||||
|
#OPTIONAL (default false)
|
||||||
|
EditDisable=false
|
||||||
|
|
||||||
|
#Message to be appended to every edited message
|
||||||
|
#OPTIONAL (default empty)
|
||||||
|
EditSuffix=" (edited)"
|
||||||
|
|
||||||
#Nicks you want to ignore.
|
#Nicks you want to ignore.
|
||||||
#Messages from those users will not be sent to other bridges.
|
#Messages from those users will not be sent to other bridges.
|
||||||
#OPTIONAL
|
#OPTIONAL
|
||||||
|
Loading…
Reference in New Issue
Block a user