From c9bbe151b21c1a79482fab80715655b322f14dea Mon Sep 17 00:00:00 2001 From: crackcomm Date: Sat, 4 Oct 2014 18:22:05 +0200 Subject: [PATCH 1/2] Status message option --- _example/example.go | 5 ++++- xmpp.go | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/_example/example.go b/_example/example.go index e4834aa..6e5daff 100644 --- a/_example/example.go +++ b/_example/example.go @@ -14,6 +14,7 @@ import ( var server = flag.String("server", "talk.google.com:443", "server") var username = flag.String("username", "", "username") var password = flag.String("password", "", "password") +var status = flag.String("status", "", "status") var notls = flag.Bool("notls", false, "No TLS") var debug = flag.Bool("debug", false, "debug output") var session = flag.Bool("session", false, "use server session") @@ -47,7 +48,9 @@ func main() { Password: *password, NoTLS: *notls, Debug: *debug, - Session: *session} + Session: *session, + Status: *status, + } talk, err = options.NewClient() diff --git a/xmpp.go b/xmpp.go index 08749e1..b5d15cb 100644 --- a/xmpp.go +++ b/xmpp.go @@ -133,8 +133,11 @@ type Options struct { // Debug output Debug bool - //Use server sessions + // Use server sessions Session bool + + // Status message + Status string } // NewClient establishes a new Client connection based on a set of Options. @@ -407,7 +410,7 @@ func (c *Client) init(o *Options) error { } // We're connected and can now receive and send messages. - fmt.Fprintf(c.conn, "xaI for one welcome our new codebot overlords.") + fmt.Fprintf(c.conn, "xa%s", o.Status) return nil } From aa9390a115618d8ef110769036e07938eff21c69 Mon Sep 17 00:00:00 2001 From: crackcomm Date: Sat, 4 Oct 2014 18:29:19 +0200 Subject: [PATCH 2/2] Status and status message --- _example/example-gui.go | 4 ++-- _example/example.go | 20 +++++++++++--------- xmpp.go | 8 ++++++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/_example/example-gui.go b/_example/example-gui.go index 70c250b..f8d3dbc 100644 --- a/_example/example-gui.go +++ b/_example/example-gui.go @@ -68,8 +68,8 @@ func main() { os.Exit(0) } - xmpp.DefaultConfig = tls.Config { - ServerName: "talk.google.com", + xmpp.DefaultConfig = tls.Config{ + ServerName: "talk.google.com", InsecureSkipVerify: false, } diff --git a/_example/example.go b/_example/example.go index 6e5daff..9c01d45 100644 --- a/_example/example.go +++ b/_example/example.go @@ -14,7 +14,8 @@ import ( var server = flag.String("server", "talk.google.com:443", "server") var username = flag.String("username", "", "username") var password = flag.String("password", "", "password") -var status = flag.String("status", "", "status") +var status = flag.String("status", "xa", "status") +var statusMessage = flag.String("status-msg", "I for one welcome our new codebot overlords.", "status message") var notls = flag.Bool("notls", false, "No TLS") var debug = flag.Bool("debug", false, "debug output") var session = flag.Bool("session", false, "use server session") @@ -35,8 +36,8 @@ func main() { } if !*notls { - xmpp.DefaultConfig = tls.Config { - ServerName: serverName(*server), + xmpp.DefaultConfig = tls.Config{ + ServerName: serverName(*server), InsecureSkipVerify: false, } } @@ -44,12 +45,13 @@ func main() { var talk *xmpp.Client var err error options := xmpp.Options{Host: *server, - User: *username, - Password: *password, - NoTLS: *notls, - Debug: *debug, - Session: *session, - Status: *status, + User: *username, + Password: *password, + NoTLS: *notls, + Debug: *debug, + Session: *session, + Status: *status, + StatusMessage: *statusMessage, } talk, err = options.NewClient() diff --git a/xmpp.go b/xmpp.go index b5d15cb..2b8a298 100644 --- a/xmpp.go +++ b/xmpp.go @@ -136,8 +136,11 @@ type Options struct { // Use server sessions Session bool - // Status message + // Presence Status Status string + + // Status message + StatusMessage string } // NewClient establishes a new Client connection based on a set of Options. @@ -410,7 +413,8 @@ func (c *Client) init(o *Options) error { } // We're connected and can now receive and send messages. - fmt.Fprintf(c.conn, "xa%s", o.Status) + fmt.Fprintf(c.conn, "%s%s", o.Status, o.StatusMessage) + return nil }