mirror of https://github.com/fluffle/goirc
Join channels that the owner invites us to
This commit is contained in:
parent
319e776c34
commit
c97201c671
16
handler.go
16
handler.go
|
@ -64,6 +64,22 @@ func handleMode(conn *irc.Conn, line *irc.Line) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleInvite(conn *irc.Conn, line *irc.Line) {
|
||||||
|
if line.Args[0] != conn.Me.Nick {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
user := line.Src[strings.Index(line.Src, "!")+1:]
|
||||||
|
if user[0] == '~' {
|
||||||
|
user = user[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
owner, _ := auth.String(conn.Network, "owner")
|
||||||
|
if user == owner {
|
||||||
|
conn.Join(line.Text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func isChannel(target string) bool {
|
func isChannel(target string) bool {
|
||||||
return target[0] == '#' || target[0] == '&'
|
return target[0] == '#' || target[0] == '&'
|
||||||
}
|
}
|
||||||
|
|
7
rbot.go
7
rbot.go
|
@ -53,6 +53,7 @@ func connect(network string) {
|
||||||
})
|
})
|
||||||
c.AddHandler("privmsg", handlePrivmsg)
|
c.AddHandler("privmsg", handlePrivmsg)
|
||||||
c.AddHandler("mode", handleMode)
|
c.AddHandler("mode", handleMode)
|
||||||
|
c.AddHandler("invite", handleInvite)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
fmt.Printf("Connecting to %s...\n", server)
|
fmt.Printf("Connecting to %s...\n", server)
|
||||||
|
@ -80,7 +81,7 @@ func autojoin(conn *irc.Conn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readConf() {
|
func readConf() {
|
||||||
var err os.Error;
|
var err os.Error
|
||||||
conf, err = config.ReadDefault("rbot.conf")
|
conf, err = config.ReadDefault("rbot.conf")
|
||||||
if (err != nil) {
|
if (err != nil) {
|
||||||
fmt.Printf("Config error: %s\n", err)
|
fmt.Printf("Config error: %s\n", err)
|
||||||
|
@ -90,14 +91,14 @@ func readConf() {
|
||||||
func readConfString(section, option string) string {
|
func readConfString(section, option string) string {
|
||||||
value, err := conf.String(section, option)
|
value, err := conf.String(section, option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Config error: %s", err));
|
panic(fmt.Sprintf("Config error: %s", err))
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
func readConfBool(section, option string) bool {
|
func readConfBool(section, option string) bool {
|
||||||
value, err := conf.Bool(section, option)
|
value, err := conf.Bool(section, option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Config error: %s", err));
|
panic(fmt.Sprintf("Config error: %s", err))
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue