summaryrefslogtreecommitdiffstats
path: root/handlers/raw.go
blob: 3a93947e86b00a98f28c3c4e86835d3a5dbc0adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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"
}