Compare commits

...

2 Commits

2 changed files with 28 additions and 16 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 != "" { if message.Body != nil && len(message.Body) != 0 {
g.SendSteamMessage(steamID, message.Body) g.SendSteamMessage(steamID, message.Body[0].Value)
} }
} }
} }
@ -284,24 +284,30 @@ func (g *GatewayInfo) chatstatesNotification() {
switch chatstate { switch chatstate {
case "stop": case "stop":
if okInactive { if okInactive {
if !timerInactive.Stop() { if timerInactive != nil {
<-timerInactive.C if !timerInactive.Stop() {
<-timerInactive.C
}
delete(inactiveTimers, jid)
} }
delete(inactiveTimers, jid)
} }
if okPaused { if okPaused {
if !timerPaused.Stop() { if timerPaused != nil {
<-timerPaused.C if !timerPaused.Stop() {
<-timerPaused.C
}
delete(pausedTimers, jid)
} }
delete(pausedTimers, jid)
} }
case "paused": case "paused":
if okInactive { if okInactive {
if !timerPaused.Stop() { if timerPaused != nil {
<-timerPaused.C if !timerPaused.Stop() {
<-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{})
@ -312,10 +318,12 @@ func (g *GatewayInfo) chatstatesNotification() {
case "inactive": case "inactive":
if okInactive { if okInactive {
if !timerInactive.Stop() { if timerInactive != nil {
<-timerInactive.C if !timerInactive.Stop() {
<-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{})
@ -330,7 +338,9 @@ 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, Body: message, Type: "chat"} m := xmpp.Message{To: g.XMPP_JID_Client, From: from, 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,7 +257,9 @@ 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, Body: message, Type: "chat"} m := xmpp.Message{From: jid.Domain, To: to, Type: "chat"}
mBody := xmpp.MessageBody{Value: message}
m.Body = append(m.Body, mBody)
if subject != "" { if subject != "" {
m.Subject = subject m.Subject = subject