func nick(conn *irc.Conn, nick *irc.Nick, args, target string) { if len(args) == 0 { return } owner, _ := auth.String(conn.Network, "owner") if owner == user(nick) { conn.Nick(args) } }
func ui(con *irc.Conn, in chan string) { curr_chan := "" for input := range in { if input[0] == '/' { // is a command var cmd string cmdend := strings.Index(input, " ") if cmdend > 0 { cmd = input[:cmdend] } else { cmd = input } switch cmd { case "/join": if len(input) > cmdend { channel := input[cmdend+1:] if channel[0] != '#' { channel = "#" + channel } curr_chan = channel con.Join(channel) } else { fmt.Println("Please specify the channel") } case "/quit": fmt.Println("Bye!") con.Quit() case "/goto": curr_chan = input[cmdend+1:] case "/list": break case "/nick": if cmdend > 0 { con.Nick(input[cmdend+1:]) } else { fmt.Println("Too few arguments") } default: fmt.Println("Unknown command") } fmt.Printf("\n%s: ", curr_chan) } else { con.Privmsg(curr_chan, input) fmt.Printf("%s: ", curr_chan) } } fmt.Println("Closing connection. kthxbai!") con.Quit() }