From c8c4c1a9986ebafa48b66830a4f6f20f9529ff03 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Fri, 10 Jul 2015 20:50:39 +0000 Subject: Update for new goctl API. Move handlers to their own package. --- handlers/bind.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 handlers/bind.go (limited to 'handlers/bind.go') diff --git a/handlers/bind.go b/handlers/bind.go new file mode 100644 index 0000000..cdacf06 --- /dev/null +++ b/handlers/bind.go @@ -0,0 +1,28 @@ +package handlers + +import ( + "fmt" + + "github.com/bjc/goctl" +) + +type Bind struct{} + +func (bh Bind) Name() string { + return "bind" +} + +func (bh Bind) Help() string { + return "binds XMPP resource" +} + +func (bh Bind) Run(_ *goctl.Goctl, args []string) string { + if xb == nil { + return "ERROR: bot is not connected." + } + + if err := xb.Bind(); err != nil { + return fmt.Sprintf("ERROR: couldn't bind resource: %s.", err) + } + return "ok" +} -- cgit v1.2.3