all repos — paprika @ bb94c73d8044300715bfbb15bddc34634ef755ab

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}