all repos — paprika @ 1eda21165d7e41e8fcf7a6f86431972b7ab37a75

go rewrite of taigabot

plugins/ctcp.go (view raw)

 1package plugins
 2
 3import (
 4	"strings"
 5
 6	"gopkg.in/irc.v3"
 7)
 8
 9type Ctcp struct{}
10
11func init() {
12	Register(Ctcp{})
13}
14
15func (Ctcp) Triggers() []string {
16	return []string{"\x01VERSION\x01", "\x01PING"}
17}
18
19func (Ctcp) Execute(m *irc.Message) (string, error) {
20	msg := m.Trailing()
21	if msg == "\x01VERSION\x01" {
22		return "\x01VERSION git.icyphox.sh/paprika\x01", IsNotice
23	} else if strings.HasPrefix(msg, "\x01PING") {
24		return msg, IsNotice
25	}
26
27	panic("Unreachable!")
28}