mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-19 01:22:38 +01:00
Add UserTypingSupport (discord) (#914)
* Add Discord to UserTypingSupport * discord: start typing in a channel on EventUserTyping receive * discord: emit EventUserTyping to gateway
This commit is contained in:
parent
da3868c104
commit
ba6759010b
@ -72,6 +72,7 @@ func (b *Bdiscord) Connect() error {
|
|||||||
}
|
}
|
||||||
b.Log.Info("Connection succeeded")
|
b.Log.Info("Connection succeeded")
|
||||||
b.c.AddHandler(b.messageCreate)
|
b.c.AddHandler(b.messageCreate)
|
||||||
|
b.c.AddHandler(b.messageTyping)
|
||||||
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)
|
||||||
@ -188,6 +189,14 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
|
|||||||
return "", fmt.Errorf("Could not find channelID for %v", msg.Channel)
|
return "", fmt.Errorf("Could not find channelID for %v", msg.Channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if msg.Event == config.EventUserTyping {
|
||||||
|
if b.GetBool("ShowUserTyping") {
|
||||||
|
err := b.c.ChannelTyping(channelID)
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
// Make a action /me of the message
|
// Make a action /me of the message
|
||||||
if msg.Event == config.EventUserAction {
|
if msg.Event == config.EventUserAction {
|
||||||
msg.Text = "_" + msg.Text + "_"
|
msg.Text = "_" + msg.Text + "_"
|
||||||
|
@ -37,6 +37,19 @@ func (b *Bdiscord) messageDeleteBulk(s *discordgo.Session, m *discordgo.MessageD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bdiscord) messageTyping(s *discordgo.Session, m *discordgo.TypingStart) {
|
||||||
|
if !b.GetBool("ShowUserTyping") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rmsg := config.Message{Account: b.Account, Event: config.EventUserTyping}
|
||||||
|
rmsg.Channel = b.getChannelName(m.ChannelID)
|
||||||
|
if b.useChannelID {
|
||||||
|
rmsg.Channel = "ID:" + m.ChannelID
|
||||||
|
}
|
||||||
|
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
|
||||||
|
@ -41,5 +41,6 @@ var (
|
|||||||
|
|
||||||
UserTypingSupport = map[string]struct{}{
|
UserTypingSupport = map[string]struct{}{
|
||||||
"slack": {},
|
"slack": {},
|
||||||
|
"discord": {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user