Merge branch 'master' of https://git.kingpenguin.tk/chteufleur/go-xmpp4steam
This commit is contained in:
commit
a69cfb7629
37
main.go
37
main.go
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"go-xmpp4steam/steam"
|
"go-xmpp4steam/steam"
|
||||||
"go-xmpp4steam/xmpp"
|
"go-xmpp4steam/xmpp"
|
||||||
|
|
||||||
"github.com/jimlawless/cfg"
|
|
||||||
"github.com/Philipp15b/go-steam/internal/steamlang"
|
"github.com/Philipp15b/go-steam/internal/steamlang"
|
||||||
|
"github.com/jimlawless/cfg"
|
||||||
|
|
||||||
"bufio"
|
"bufio"
|
||||||
"log"
|
"log"
|
||||||
|
|
@ -30,7 +30,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// XMPP config
|
// XMPP config
|
||||||
xmpp.Addr = mapConfig["xmpp_server_address"]+":"+mapConfig["xmpp_server_port"]
|
xmpp.Addr = mapConfig["xmpp_server_address"] + ":" + mapConfig["xmpp_server_port"]
|
||||||
xmpp.JidStr = mapConfig["xmpp_hostname"]
|
xmpp.JidStr = mapConfig["xmpp_hostname"]
|
||||||
xmpp.Secret = mapConfig["xmpp_secret"]
|
xmpp.Secret = mapConfig["xmpp_secret"]
|
||||||
xmpp.PreferedJID = mapConfig["xmpp_authorized_jid"]
|
xmpp.PreferedJID = mapConfig["xmpp_authorized_jid"]
|
||||||
|
|
@ -39,6 +39,8 @@ func init() {
|
||||||
steam.Username = mapConfig["steam_login"]
|
steam.Username = mapConfig["steam_login"]
|
||||||
steam.Password = mapConfig["steam_password"]
|
steam.Password = mapConfig["steam_password"]
|
||||||
steam.AuthCode = mapConfig["steam_auth_code"]
|
steam.AuthCode = mapConfig["steam_auth_code"]
|
||||||
|
|
||||||
|
xmpp.Version = "0.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -52,20 +54,19 @@ func main() {
|
||||||
go gatewaySteamXmppPresence()
|
go gatewaySteamXmppPresence()
|
||||||
|
|
||||||
go steam.Run()
|
go steam.Run()
|
||||||
go xmpp.Run()
|
xmpp.Run()
|
||||||
|
|
||||||
inputStop()
|
// inputStop()
|
||||||
|
|
||||||
steam.Disconnect()
|
steam.Disconnect()
|
||||||
xmpp.Disconnect()
|
xmpp.Disconnect()
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// XMPP -> Steam gateways
|
// XMPP -> Steam gateways
|
||||||
func gatewayXmppSteamAction() {
|
func gatewayXmppSteamAction() {
|
||||||
for {
|
for {
|
||||||
action := <- xmpp.ChanAction
|
action := <-xmpp.ChanAction
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case xmpp.ActionConnexion:
|
case xmpp.ActionConnexion:
|
||||||
|
|
@ -83,7 +84,7 @@ func gatewayXmppSteamAction() {
|
||||||
|
|
||||||
func gatewayXmppSteamPresence() {
|
func gatewayXmppSteamPresence() {
|
||||||
for {
|
for {
|
||||||
status := <- xmpp.ChanPresence
|
status := <-xmpp.ChanPresence
|
||||||
var steamStatus steamlang.EPersonaState
|
var steamStatus steamlang.EPersonaState
|
||||||
|
|
||||||
switch status {
|
switch status {
|
||||||
|
|
@ -108,20 +109,19 @@ func gatewayXmppSteamPresence() {
|
||||||
|
|
||||||
func gatewayXmppSteamMessage() {
|
func gatewayXmppSteamMessage() {
|
||||||
for {
|
for {
|
||||||
steamId := <- xmpp.ChanMessage
|
steamId := <-xmpp.ChanMessage
|
||||||
message := <- xmpp.ChanMessage
|
message := <-xmpp.ChanMessage
|
||||||
|
|
||||||
steam.SendMessage(steamId, message)
|
steam.SendMessage(steamId, message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /XMPP -> Steam gateways
|
// /XMPP -> Steam gateways
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Steam -> XMPP gateways
|
// Steam -> XMPP gateways
|
||||||
func gatewaySteamXmppAction() {
|
func gatewaySteamXmppAction() {
|
||||||
for {
|
for {
|
||||||
action := <- steam.ChanAction
|
action := <-steam.ChanAction
|
||||||
switch action {
|
switch action {
|
||||||
case steam.ActionConnected:
|
case steam.ActionConnected:
|
||||||
xmpp.SendPresence(xmpp.CurrentStatus, xmpp.Type_available)
|
xmpp.SendPresence(xmpp.CurrentStatus, xmpp.Type_available)
|
||||||
|
|
@ -138,8 +138,8 @@ func gatewaySteamXmppAction() {
|
||||||
|
|
||||||
func gatewaySteamXmppMessage() {
|
func gatewaySteamXmppMessage() {
|
||||||
for {
|
for {
|
||||||
steamId := <- steam.ChanMessage
|
steamId := <-steam.ChanMessage
|
||||||
message := <- steam.ChanMessage
|
message := <-steam.ChanMessage
|
||||||
xmpp.SendMessage(steamId+"@"+xmpp.JidStr, message)
|
xmpp.SendMessage(steamId+"@"+xmpp.JidStr, message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,8 +147,8 @@ func gatewaySteamXmppMessage() {
|
||||||
func gatewaySteamXmppPresence() {
|
func gatewaySteamXmppPresence() {
|
||||||
for {
|
for {
|
||||||
// name := steam.ChanPresence
|
// name := steam.ChanPresence
|
||||||
steamId := <- steam.ChanPresence
|
steamId := <-steam.ChanPresence
|
||||||
stat := <- steam.ChanPresenceSteam
|
stat := <-steam.ChanPresenceSteam
|
||||||
|
|
||||||
SetSteamId[steamId] = struct{}{}
|
SetSteamId[steamId] = struct{}{}
|
||||||
|
|
||||||
|
|
@ -179,12 +179,9 @@ func gatewaySteamXmppPresence() {
|
||||||
xmpp.SendPresenceFrom(status, tpye, steamId+"@"+xmpp.JidStr)
|
xmpp.SendPresenceFrom(status, tpye, steamId+"@"+xmpp.JidStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /Steam -> XMPP gateways
|
// /Steam -> XMPP gateways
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func inputStop() {
|
func inputStop() {
|
||||||
for {
|
for {
|
||||||
in := bufio.NewReader(os.Stdin)
|
in := bufio.NewReader(os.Stdin)
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ import (
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -47,7 +47,6 @@ var (
|
||||||
ChanAction = make(chan string)
|
ChanAction = make(chan string)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
log.Printf("%sRunning", LogInfo)
|
log.Printf("%sRunning", LogInfo)
|
||||||
setLoginInfos()
|
setLoginInfos()
|
||||||
|
|
@ -106,7 +105,6 @@ func mainSteam() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func setLoginInfos() {
|
func setLoginInfos() {
|
||||||
var sentryHash steam.SentryHash
|
var sentryHash steam.SentryHash
|
||||||
sentryHash, err := ioutil.ReadFile(sentryFile)
|
sentryHash, err := ioutil.ReadFile(sentryFile)
|
||||||
|
|
@ -126,7 +124,6 @@ func setLoginInfos() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func IsConnected() bool {
|
func IsConnected() bool {
|
||||||
return client.Connected()
|
return client.Connected()
|
||||||
}
|
}
|
||||||
|
|
@ -155,7 +152,6 @@ func Disconnect() {
|
||||||
go client.Disconnect()
|
go client.Disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func SendMessage(steamId, message string) {
|
func SendMessage(steamId, message string) {
|
||||||
steamIdUint64, err := strconv.ParseUint(steamId, 10, 64)
|
steamIdUint64, err := strconv.ParseUint(steamId, 10, 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
@ -169,8 +165,6 @@ func SendPresence(status steamlang.EPersonaState) {
|
||||||
client.Social.SetPersonaState(status)
|
client.Social.SetPersonaState(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// First authentification error
|
// First authentification error
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package xmpp
|
package xmpp
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "github.com/emgee/go-xmpp"
|
// "github.com/emgee/go-xmpp"
|
||||||
"go-xmpp"
|
"go-xmpp"
|
||||||
|
|
@ -44,8 +43,9 @@ var (
|
||||||
ChanAction = make(chan string)
|
ChanAction = make(chan string)
|
||||||
|
|
||||||
CurrentStatus = Status_offline
|
CurrentStatus = Status_offline
|
||||||
)
|
|
||||||
|
|
||||||
|
Version = ""
|
||||||
|
)
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
log.Printf("%sRunning", LogInfo)
|
log.Printf("%sRunning", LogInfo)
|
||||||
|
|
@ -102,7 +102,7 @@ func Disconnect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendPresence(status, tpye string) {
|
func SendPresence(status, tpye string) {
|
||||||
comp.Out <- xmpp.Presence{To: PreferedJID, From: jid.Domain, Show: status, Type: tpye}
|
comp.Out <- xmpp.Presence{To: PreferedJID, From: jid.Domain, Show: status, Type: tpye, Status: "go-xmpp4steam v" + Version}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendPresenceFrom(status, tpye, from string) {
|
func SendPresenceFrom(status, tpye, from string) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# XMPP informations
|
# XMPP informations
|
||||||
xmpp_server_address=192.168.1.2
|
xmpp_server_address=192.168.1.2
|
||||||
xmpp_server_port=5347
|
xmpp_server_port=5347
|
||||||
xmpp_hostname=steam.kingpenguin.tk
|
xmpp_hostname=xmppsteam.kingpenguin.tk
|
||||||
xmpp_secret=steam_gateway_password
|
xmpp_secret=xmpp4steam_password
|
||||||
xmpp_authorized_jid=chteufleur@kingpenguin.tk
|
xmpp_authorized_jid=chteufleur@kingpenguin.tk
|
||||||
|
|
||||||
# Steam informations
|
# Steam informations
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue