Join channels that the owner invites us to

This commit is contained in:
raylu 2010-10-25 15:10:09 -04:00
parent 319e776c34
commit c97201c671
2 changed files with 20 additions and 3 deletions

View File

@ -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] == '&'
} }

View File

@ -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
} }