History

don't post all entries on the first fetch

Sigrid Solveig Haflínudóttir committed 3 months ago

Commit 50fdc581 parent 6f185841 file · +9 −2Browse files

Unified · Split

main.go+9−2
@@ -23,6 +23,7 @@ var ( · 22 unmodified lines
2323 nick = flag.String("nick", "feed2irc", "IRC nickname")
2424 period = flag.String("period", "10m", "Update period")
2525 seenPath = flag.String("seen", "", "\"Seen\" entries store")
26+ postOld = flag.Bool("post-old", false, "Post all entries on the first fetch ever")
2627 )
2728
2829 func main() {
@@ -58,6 +59,10 @@ func main() { · 29 unmodified lines
5859 seen[md5.Sum(url)] = struct{}{}
5960 }
6061 }
62+ var skip bool
63+ if len(seen) == 0 && !*postOld {
64+ skip = true
65+ }
6166
6267 cfg := irc.NewConfig(*nick, "feed2ircbot", "feed2irc bot")
6368 c := irc.Client(cfg)
@@ -99,9 +104,11 @@ func main() { · 35 unmodified lines
99104 os.Exit(1)
100105 }
101106 seenFile.Sync()
102− s := fmt.Sprintf("%s | %s\n", item.Title, item.Link)
103− c.Privmsgln(*channel, s)
104107 seen[sum] = struct{}{}
108+ if !skip {
109+ s := fmt.Sprintf("%s | %s\n", item.Title, item.Link)
110+ c.Privmsgln(*channel, s)
111+ }
105112 }
106113 }
107114 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t