summaryrefslogtreecommitdiffstats
path: root/handlers/raw.go
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2015-07-10 20:50:39 +0000
committerBrian Cully <bjc@kublai.com>2015-07-10 20:50:39 +0000
commitc8c4c1a9986ebafa48b66830a4f6f20f9529ff03 (patch)
treecf651e5233daa50e681dc58193d366f9691a9769 /handlers/raw.go
parent204f830396f84f2583d081221b5e253bed85bcf1 (diff)
downloadxmppbot-c8c4c1a9986ebafa48b66830a4f6f20f9529ff03.tar.gz
xmppbot-c8c4c1a9986ebafa48b66830a4f6f20f9529ff03.zip
Update for new goctl API.
Move handlers to their own package.
Diffstat (limited to 'handlers/raw.go')
-rw-r--r--handlers/raw.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/handlers/raw.go b/handlers/raw.go
new file mode 100644
index 0000000..3a93947
--- /dev/null
+++ b/handlers/raw.go
@@ -0,0 +1,32 @@
+package handlers
+
+import (
+ "fmt"
+
+ "github.com/ThomsonReutersEikon/open-nitro/src/bots/xmppclient"
+ "github.com/bjc/goctl"
+)
+
+type Raw struct{}
+
+func (rh Raw) Name() string {
+ return "raw"
+}
+
+func (rh Raw) Help() string {
+ return "send raw data"
+}
+
+func (rh Raw) Run(_ *goctl.Goctl, args []string) string {
+ if xb == nil {
+ return "ERROR: bot is not connected."
+ }
+
+ if b, ok := xb.(*xmppclient.Bot); !ok {
+ return "ERROR: can only send raw data on XMPP bot."
+ } else if err := b.Sendf(args[0]); err != nil {
+ return fmt.Sprintf("ERROR: sending raw data: %s", err)
+ }
+
+ return "ok"
+}