aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cheetah-bot.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/cheetah-bot.go b/cheetah-bot.go
index 8c26608..e605a68 100644
--- a/cheetah-bot.go
+++ b/cheetah-bot.go
@@ -3,10 +3,12 @@
package main
import (
+ "bufio"
"fmt"
"io"
"io/ioutil"
"os"
+ "time"
/*
// imgur stuff
@@ -100,7 +102,35 @@ func main() {
titleReddit := fmt.Sprintf("Posting cheetah pics every day until I run out — Day %d — %s", day, description)
titleMasto := fmt.Sprintf("Day %d: %s\n#cheetah\n", day, description)
+ curYear, curMonth, curDay := time.Now().Date()
+ titleGemini := "# Cheetah a Day\n\n"
+ linkGemini := fmt.Sprintf("=> D%03d.jpg %04d-%02d-%02d - Day %[4]d: %s\n", curYear, curMonth, curDay, day, description)
+
// do the final culminating posts
+ geminiOrig, err := os.Open("/var/local/cheetahs/cheetahs.gmi")
+ if err != nil {
+ fmt.Println("Failed to open file: ", err)
+ os.Exit(1)
+ }
+ defer geminiOrig.Close()
+ geminiNew, err := os.OpenFile("/var/local/cheetahs/cheetahs.gmi.new", os.O_RDWR|os.O_CREATE, 0666)
+ if err != nil {
+ fmt.Println("Failed to open file: ", err)
+ os.Exit(1)
+ }
+ defer geminiNew.Close()
+ reader := bufio.NewReader(geminiOrig)
+ writer := bufio.NewWriter(geminiNew)
+ io.WriteString(geminiNew, titleGemini)
+ io.WriteString(geminiNew, linkGemini)
+ _, _ = reader.ReadString('\n')
+ _, _ = reader.ReadString('\n')
+ _, err = io.Copy(writer, reader)
+ if err != nil {
+ fmt.Println("Failed to update gemini file: ", err)
+ os.Exit(1)
+ }
+
//reddit.PostLink("nytpu", titleReddit, imgurImage)
reddit.PostLink("Cheetahs", titleReddit, mastoImage.URL)
masto.PostStatus(titleMasto, 0, []int64{mastoImage.ID}, false, "", "public")