func parseRSS(rss []byte, source string) (map[string]MangaEntry, error) { src := strings.Split(lib.Sanitise(string(rss[bytes.Index(rss, []byte("<item>")):])), "</item>") src = src[0 : len(src)-1] entries := map[string]MangaEntry{} var title, tmpDate string for _, line := range src { if line == "" { continue } title = line[strings.Index(line, "<title>")+7 : strings.Index(line, "</title>")] title = html.UnescapeString(title) if source == "mangafox" { title = html.UnescapeString(title) // one more time - mangafox double escape sometimes -.- } tmpDate = line[strings.Index(line, "<pubDate>")+9 : strings.Index(line, "</pubDate>")] date, err := time.Parse("Mon, 2 Jan 2006 15:04:05 -0700", tmpDate) if err != nil { logger.Error(err.Error()) return nil, errors.New("parseRSS failed to parse time : " + tmpDate) } entries[strings.ToLower(title)] = MangaEntry{ Title: title, Link: line[strings.Index(line, "<link>")+6 : strings.Index(line, "</link>")], Date: date.Unix(), Desc: line[strings.Index(line, "<description>")+13 : strings.Index(line, "</description>")], } } return entries, nil }
func (irc *IRC) Send(line string) { line = lib.Sanitise(line) logger.Sent(line) fmt.Fprint(irc.Conn, line+"\r\n") }
func (irc *IRC) SilentSend(line string) { fmt.Fprintf(irc.Conn, lib.Sanitise(line)+"\r\n") }