forked from chteufleur/go-xmpp4steam
Finalize steam user subscribtion
This commit is contained in:
parent
387a0b7e5a
commit
abfe6de004
5
main.go
5
main.go
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "go-xmpp4steam v0.1.5"
|
Version = "go-xmpp4steam v0.1.6"
|
||||||
configurationFilePath = "xmpp4steam.cfg"
|
configurationFilePath = "xmpp4steam.cfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -95,6 +95,8 @@ func gatewayXmppSteamAction() {
|
||||||
func gatewayXmppSteamPresence() {
|
func gatewayXmppSteamPresence() {
|
||||||
for {
|
for {
|
||||||
status := <-xmpp.ChanPresence
|
status := <-xmpp.ChanPresence
|
||||||
|
tpye := <-xmpp.ChanPresence
|
||||||
|
|
||||||
var steamStatus steamlang.EPersonaState
|
var steamStatus steamlang.EPersonaState
|
||||||
|
|
||||||
switch status {
|
switch status {
|
||||||
|
|
@ -114,6 +116,7 @@ func gatewayXmppSteamPresence() {
|
||||||
}
|
}
|
||||||
|
|
||||||
steam.SendPresence(steamStatus)
|
steam.SendPresence(steamStatus)
|
||||||
|
xmpp.SendPresence(status, tpye, Version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
25
xmpp/xmpp.go
25
xmpp/xmpp.go
|
|
@ -70,8 +70,8 @@ func mainXMPP() {
|
||||||
for x := range comp.In {
|
for x := range comp.In {
|
||||||
switch v := x.(type) {
|
switch v := x.(type) {
|
||||||
case *xmpp.Presence:
|
case *xmpp.Presence:
|
||||||
if strings.SplitN(v.From, "/", 2)[0] == PreferedJID && v.To == JidStr && v.Type != Type_probe {
|
if strings.SplitN(v.From, "/", 2)[0] == PreferedJID && v.Type != Type_probe {
|
||||||
if v.Type == Type_unavailable {
|
if v.Type == Type_unavailable && v.To == JidStr {
|
||||||
delete(setJIDconnected, v.From)
|
delete(setJIDconnected, v.From)
|
||||||
log.Printf("%sPresence reçut unavailable", LogDebug)
|
log.Printf("%sPresence reçut unavailable", LogDebug)
|
||||||
if len(setJIDconnected) <= 0 {
|
if len(setJIDconnected) <= 0 {
|
||||||
|
|
@ -79,6 +79,8 @@ func mainXMPP() {
|
||||||
Disconnect()
|
Disconnect()
|
||||||
ChanAction <- ActionDeconnexion
|
ChanAction <- ActionDeconnexion
|
||||||
}
|
}
|
||||||
|
} else if v.Type == Type_subscribe {
|
||||||
|
SendPresenceFrom("", Type_subscribed, v.To, "", "")
|
||||||
} else {
|
} else {
|
||||||
setJIDconnected[v.From] = true
|
setJIDconnected[v.From] = true
|
||||||
log.Printf("%sPresence reçut", LogDebug)
|
log.Printf("%sPresence reçut", LogDebug)
|
||||||
|
|
@ -87,6 +89,7 @@ func mainXMPP() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChanPresence <- v.Show
|
ChanPresence <- v.Show
|
||||||
|
ChanPresence <- v.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
case *xmpp.Message:
|
case *xmpp.Message:
|
||||||
|
|
@ -129,6 +132,7 @@ func SendPresence(status, tpye, message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendPresenceFrom(status, tpye, from, message, nick string) {
|
func SendPresenceFrom(status, tpye, from, message, nick string) {
|
||||||
|
/*
|
||||||
if message == "" {
|
if message == "" {
|
||||||
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Nick: nick}
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Nick: nick}
|
||||||
} else if nick == "" {
|
} else if nick == "" {
|
||||||
|
|
@ -138,6 +142,23 @@ func SendPresenceFrom(status, tpye, from, message, nick string) {
|
||||||
} else {
|
} else {
|
||||||
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Status: message, Nick: nick}
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: from, Show: status, Type: tpye, Status: message, Nick: nick}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
p := xmpp.Presence{To: PreferedJID, From: from}
|
||||||
|
|
||||||
|
if status != "" {
|
||||||
|
p.Show = status
|
||||||
|
}
|
||||||
|
if tpye != "" {
|
||||||
|
p.Type = tpye
|
||||||
|
}
|
||||||
|
if message != "" {
|
||||||
|
p.Status = message
|
||||||
|
}
|
||||||
|
if nick != "" {
|
||||||
|
p.Nick = nick
|
||||||
|
}
|
||||||
|
|
||||||
|
comp.Out <- p
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendMessage(from, message string) {
|
func SendMessage(from, message string) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue