mirror of https://github.com/fluffle/goirc
Merge pull request #26 from iopred/cfgmessages
Moved QUIT and VERSION responses into the config.
This commit is contained in:
commit
7bb84985ee
|
@ -49,7 +49,7 @@ func (conn *Conn) Kick(channel, nick string, message ...string) {
|
||||||
func (conn *Conn) Quit(message ...string) {
|
func (conn *Conn) Quit(message ...string) {
|
||||||
msg := strings.Join(message, " ")
|
msg := strings.Join(message, " ")
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
msg = "GoBye!"
|
msg = conn.cfg.QuitMessage
|
||||||
}
|
}
|
||||||
conn.out <- "QUIT :" + msg
|
conn.out <- "QUIT :" + msg
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,12 @@ type Config struct {
|
||||||
|
|
||||||
// Set this to true to disable flood protection and false to re-enable
|
// Set this to true to disable flood protection and false to re-enable
|
||||||
Flood bool
|
Flood bool
|
||||||
|
|
||||||
|
// Sent as the reply to a CTCP VERSION message
|
||||||
|
Version string
|
||||||
|
|
||||||
|
// Sent as the QUIT message.
|
||||||
|
QuitMessage string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(nick string, args ...string) *Config {
|
func NewConfig(nick string, args ...string) *Config {
|
||||||
|
@ -82,6 +88,8 @@ func NewConfig(nick string, args ...string) *Config {
|
||||||
if len(args) > 1 && args[1] != "" {
|
if len(args) > 1 && args[1] != "" {
|
||||||
cfg.Me.Name = args[1]
|
cfg.Me.Name = args[1]
|
||||||
}
|
}
|
||||||
|
cfg.Version = "Powered by GoIRC"
|
||||||
|
cfg.QuitMessage = "GoBye!"
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (conn *Conn) h_433(line *Line) {
|
||||||
// Handle VERSION requests and CTCP PING
|
// Handle VERSION requests and CTCP PING
|
||||||
func (conn *Conn) h_CTCP(line *Line) {
|
func (conn *Conn) h_CTCP(line *Line) {
|
||||||
if line.Args[0] == "VERSION" {
|
if line.Args[0] == "VERSION" {
|
||||||
conn.CtcpReply(line.Nick, "VERSION", "powered by goirc...")
|
conn.CtcpReply(line.Nick, "VERSION", conn.cfg.Version)
|
||||||
} else if line.Args[0] == "PING" {
|
} else if line.Args[0] == "PING" {
|
||||||
conn.CtcpReply(line.Nick, "PING", line.Args[2])
|
conn.CtcpReply(line.Nick, "PING", line.Args[2])
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ func TestCTCP(t *testing.T) {
|
||||||
c.h_CTCP(parseLine(":blah!moo@cows.com PRIVMSG test :\001VERSION\001"))
|
c.h_CTCP(parseLine(":blah!moo@cows.com PRIVMSG test :\001VERSION\001"))
|
||||||
|
|
||||||
// Expect a version reply
|
// Expect a version reply
|
||||||
s.nc.Expect("NOTICE blah :\001VERSION powered by goirc...\001")
|
s.nc.Expect("NOTICE blah :\001VERSION Powered by GoIRC\001")
|
||||||
|
|
||||||
// Call handler with CTCP PING
|
// Call handler with CTCP PING
|
||||||
c.h_CTCP(parseLine(":blah!moo@cows.com PRIVMSG test :\001PING 1234567890\001"))
|
c.h_CTCP(parseLine(":blah!moo@cows.com PRIVMSG test :\001PING 1234567890\001"))
|
||||||
|
|
Loading…
Reference in New Issue