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

View File

@ -257,7 +257,9 @@ func SendPresence(status, tpye, from, to, message, nick 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 != "" {
m.Subject = subject