From: Bernhard Tittelbach Date: Sat, 24 Aug 2013 17:30:28 +0000 (+0000) Subject: cmdline arguments X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=6f78aae1eac804c1049def612920f9ddf9e189c8;p=svn42.git cmdline arguments --- diff --git a/r3-netstatus/main.go b/r3-netstatus/main.go index 77dd32a..9fb1253 100644 --- a/r3-netstatus/main.go +++ b/r3-netstatus/main.go @@ -3,6 +3,8 @@ package main import ( "./spaceapi" "./r3xmppbot" + //pubsub "github.com/tuxychandru/pubsub" + "flag" "bufio" "fmt" "net" @@ -29,9 +31,23 @@ var ( re_querystresc_ *regexp.Regexp = regexp.MustCompile("[^\x30-\x39\x41-\x7E]") spaceapidata spaceapi.SpaceInfo = spaceapi.NewSpaceInfo("realraum", "http://realraum.at", "http://realraum.at/logo-red_250x250.png", "http://realraum.at/logo-re_open_100x100.png", "http://realraum.at/logo-re_empty_100x100.png",47.065779129, 15.442322614).AddSpaceAddress("Jakoministr. 16 ground level left, 8010 Graz, Austria") statusstate *SpaceState = new(SpaceState) + presence_socket_path_ string xmpp_presence_events_chan_ chan interface{} + xmpp_login_ struct {jid string; pass string} + xmpp_bot_authstring_ string ) + +var flagvar int +func init() { + flag.StringVar(&xmpp_login_.jid, "xjid", "realrauminfo@realraum.at/Tuer", "XMPP Bot Login JID") + flag.StringVar(&xmpp_login_.pass, "xpass", "", "XMPP Bot Login Password") + flag.StringVar(&xmpp_bot_authstring_, "xbotauth", "", "String that user use to authenticate themselves to the bot") + flag.StringVar(&presence_socket_path_,"presencesocket", "/var/run/tuer/presence.socket", "Path to presence socket") + flag.Parse() +} + + //------- func updateStatusString() { @@ -140,7 +156,7 @@ func main() { var err error var bot *r3xmppbot.XmppBot - bot, xmpp_presence_events_chan_, err = r3xmppbot.NewStartedBot("realrauminfo@realraum.at/Tuer", "d7ynC6Dg", "r3alraumOLGAXMPPInfos", true) + bot, xmpp_presence_events_chan_, err = r3xmppbot.NewStartedBot(xmpp_login_.jid, xmpp_login_.pass, xmpp_bot_authstring_, true) if err != nil { fmt.Println(err) return @@ -156,7 +172,7 @@ func main() { defer close(eventqueue) ticker := time.NewTicker(time.Duration(7) * time.Minute) - go readFromUSocket("/var/run/tuer/presence.socket", eventqueue) + go readFromUSocket(presence_socket_path_, eventqueue) for { select { case e := <-eventqueue: