Compare commits

..

No commits in common. "231a8acb5ffcb5605c2048ffd73fafe5343b1bbb" and "cb49e1fbe936705bb2fad46d682774a25b7dd88b" have entirely different histories.

2 changed files with 16 additions and 28 deletions

View File

@ -127,8 +127,8 @@ func (g *GatewayInfo) ReceivedXMPP_Message(message *xmpp.Message) {
} else if message.Gone != nil { } else if message.Gone != nil {
g.SendSteamMessageLeaveConversation(steamID) g.SendSteamMessageLeaveConversation(steamID)
} else { } else {
if message.Body != nil && len(message.Body) != 0 { if message.Body != "" {
g.SendSteamMessage(steamID, message.Body[0].Value) g.SendSteamMessage(steamID, message.Body)
} }
} }
} }
@ -284,30 +284,24 @@ func (g *GatewayInfo) chatstatesNotification() {
switch chatstate { switch chatstate {
case "stop": case "stop":
if okInactive { if okInactive {
if timerInactive != nil { if !timerInactive.Stop() {
if !timerInactive.Stop() { <-timerInactive.C
<-timerInactive.C
}
delete(inactiveTimers, jid)
} }
delete(inactiveTimers, jid)
} }
if okPaused { if okPaused {
if timerPaused != nil { if !timerPaused.Stop() {
if !timerPaused.Stop() { <-timerPaused.C
<-timerPaused.C
}
delete(pausedTimers, jid)
} }
delete(pausedTimers, jid)
} }
case "paused": case "paused":
if okInactive { if okInactive {
if timerPaused != nil { if !timerPaused.Stop() {
if !timerPaused.Stop() { <-timerPaused.C
<-timerPaused.C
}
timerPaused.Reset(20 * time.Second)
} }
timerPaused.Reset(20 * time.Second)
} else { } else {
timerPaused = time.AfterFunc(20*time.Second, func() { timerPaused = time.AfterFunc(20*time.Second, func() {
g.sendXmppMessage(jid, "", "", &xmpp.Paused{}) g.sendXmppMessage(jid, "", "", &xmpp.Paused{})
@ -318,12 +312,10 @@ func (g *GatewayInfo) chatstatesNotification() {
case "inactive": case "inactive":
if okInactive { if okInactive {
if timerInactive != nil { if !timerInactive.Stop() {
if !timerInactive.Stop() { <-timerInactive.C
<-timerInactive.C
}
timerInactive.Reset(120 * time.Second)
} }
timerInactive.Reset(120 * time.Second)
} else { } else {
timerInactive = time.AfterFunc(120*time.Second, func() { timerInactive = time.AfterFunc(120*time.Second, func() {
g.sendXmppMessage(jid, "", "", &xmpp.Inactive{}) g.sendXmppMessage(jid, "", "", &xmpp.Inactive{})
@ -338,9 +330,7 @@ func (g *GatewayInfo) chatstatesNotification() {
func (g *GatewayInfo) sendXmppMessage(from, subject, message string, chatState interface{}) { func (g *GatewayInfo) sendXmppMessage(from, subject, message string, chatState interface{}) {
if from != XmppJidComponent || from == XmppJidComponent && g.DebugMessage { if from != XmppJidComponent || from == XmppJidComponent && g.DebugMessage {
m := xmpp.Message{To: g.XMPP_JID_Client, From: from, Type: "chat"} m := xmpp.Message{To: g.XMPP_JID_Client, From: from, Body: message, Type: "chat"}
mBody := xmpp.MessageBody{Value: message}
m.Body = append(m.Body, mBody)
if subject != "" { if subject != "" {
m.Subject = subject m.Subject = subject

View File

@ -257,9 +257,7 @@ func SendPresence(status, tpye, from, to, message, nick string) {
} }
func SendMessage(to, subject, message string) { func SendMessage(to, subject, message string) {
m := xmpp.Message{From: jid.Domain, To: to, Type: "chat"} m := xmpp.Message{From: jid.Domain, To: to, Body: message, Type: "chat"}
mBody := xmpp.MessageBody{Value: message}
m.Body = append(m.Body, mBody)
if subject != "" { if subject != "" {
m.Subject = subject m.Subject = subject