Improve typing notification handling
This commit is contained in:
18
portal.go
18
portal.go
@@ -1282,6 +1282,24 @@ func (portal *Portal) handleDiscordMessageDelete(user *User, msg *discordgo.Mess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (portal *Portal) handleDiscordTyping(evt *discordgo.TypingStart) {
|
||||||
|
puppet := portal.bridge.GetPuppetByID(evt.UserID)
|
||||||
|
if puppet.Name == "" {
|
||||||
|
// Puppet hasn't been synced yet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
intent := puppet.IntentFor(portal)
|
||||||
|
err := intent.EnsureJoined(portal.MXID)
|
||||||
|
if err != nil {
|
||||||
|
portal.log.Warnfln("Failed to ensure %s is joined for typing notification: %v", puppet.MXID, portal.MXID, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = intent.UserTyping(portal.MXID, true, 12*time.Second)
|
||||||
|
if err != nil {
|
||||||
|
portal.log.Warnfln("Failed to mark %s as typing: %v", puppet.MXID, portal.MXID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (portal *Portal) syncParticipants(source *User, participants []*discordgo.User) {
|
func (portal *Portal) syncParticipants(source *User, participants []*discordgo.User) {
|
||||||
for _, participant := range participants {
|
for _, participant := range participants {
|
||||||
puppet := portal.bridge.GetPuppetByID(participant.ID)
|
puppet := portal.bridge.GetPuppetByID(participant.ID)
|
||||||
|
|||||||
6
user.go
6
user.go
@@ -995,11 +995,7 @@ func (user *User) typingStartHandler(_ *discordgo.Session, t *discordgo.TypingSt
|
|||||||
if portal == nil || portal.MXID == "" {
|
if portal == nil || portal.MXID == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
puppet := user.bridge.GetPuppetByID(t.UserID)
|
portal.handleDiscordTyping(t)
|
||||||
_, err := puppet.IntentFor(portal).UserTyping(portal.MXID, true, 12*time.Second)
|
|
||||||
if err != nil {
|
|
||||||
user.log.Warnfln("Failed to mark %s as typing in %s: %v", puppet.MXID, portal.MXID, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) interactionSuccessHandler(_ *discordgo.Session, s *discordgo.InteractionSuccess) {
|
func (user *User) interactionSuccessHandler(_ *discordgo.Session, s *discordgo.InteractionSuccess) {
|
||||||
|
|||||||
Reference in New Issue
Block a user