func Trace(channel string, sender string, arg string) { lg, err := net.Dial("tcp", bot.GetLGServer()) if err != nil { bot.Notice(sender, "Error: Please try again later") return } fmt.Fprintf(lg, "traceroute %s\n", arg) reader := bufio.NewReader(lg) for { line, err := reader.ReadString('\n') if err == io.EOF { lg.Close() break } bot.Notice(sender, line) } }
func Route6(channel string, sender string, arg string) { lg, err := net.Dial("tcp", bot.GetLGServer()) if err != nil { bot.Notice(sender, "Error: Please try again later") return } fmt.Fprintf(lg, "route6 %s\n", arg) reader := bufio.NewReader(lg) for i := 0; ; i++ { line, err := reader.ReadString('\n') if err == io.EOF || (strings.Contains(line, "via") && i > 0) { lg.Close() break } bot.Notice(sender, line) } }
func Whois(channel string, sender string, arg string) { lg, err := net.Dial("tcp", bot.GetLGServer()) if err != nil { bot.Notice(sender, "Error: Please try again later") return } fmt.Fprintf(lg, "whois %s\n", arg) buf := make([]byte, 3072) n, err := io.ReadFull(lg, buf) if err == io.EOF { lg.Close() return } strbuf := string(buf[:n]) ilb := strings.LastIndex(strbuf, "% Information") if ilb == -1 { ilb = 0 } for _, line := range strings.Split(strbuf[ilb:], "\n") { bot.Notice(sender, line) time.Sleep(1 * time.Second) } }