~nytpu/snep-bot

f9e40edbc4385478f701a95df52ba4f2f6e8d86a — nytpu 5 months ago 1243d75 master
update
1 files changed, 5 insertions(+), 12 deletions(-)

M snep-bot.go
M snep-bot.go => snep-bot.go +5 -12
@@ 16,7 16,7 @@ import (

func main() {
	// prepare day file
	df, err := os.OpenFile("/var/local/sneps/day.txt", os.O_RDWR|os.O_CREATE, 0644)
	df, err := os.OpenFile("/var/local/animals/sneps/day.txt", os.O_RDWR|os.O_CREATE, 0644)
	if err != nil {
		fmt.Println("Failed to open file: ", err)
		os.Exit(1)


@@ 36,7 36,7 @@ func main() {
		}
	}

	filename := fmt.Sprintf("/var/local/sneps/D%03d.jpg", day)
	filename := fmt.Sprintf("/var/local/animals/sneps/D%03d.jpg", day)

	reddit, err := reddit.NewBotFromAgentFile("/home/alex/.animal-bots/sneps/reddit.agent", 0)
	if err != nil {


@@ 85,13 85,13 @@ Snow leopards are one of the best animals, and I'm here to share them with you. 

	// do the final culminating posts
	// open old and new indexes
	geminiOrig, err := os.Open("/var/local/sneps/index.gmi")
	geminiOrig, err := os.Open("/var/local/animals/sneps/index.gmi")
	if err != nil {
		fmt.Println("Failed to open file: ", err)
		os.Exit(1)
	}
	defer geminiOrig.Close()
	geminiNew, err := os.OpenFile("/var/local/sneps/index.gmi.new", os.O_RDWR|os.O_CREATE, 0666)
	geminiNew, err := os.OpenFile("/var/local/animals/sneps/index.gmi.new", os.O_RDWR|os.O_CREATE, 0666)
	if err != nil {
		fmt.Println("Failed to open file: ", err)
		os.Exit(1)


@@ 125,7 125,7 @@ Snow leopards are one of the best animals, and I'm here to share them with you. 
		os.Exit(1)
	}
	// move new to old once writing is confirmed to have been successful
	err = os.Rename("/var/local/sneps/index.gmi.new", "/var/local/sneps/index.gmi")
	err = os.Rename("/var/local/animals/sneps/index.gmi.new", "/var/local/animals/sneps/index.gmi")
	if err != nil {
		fmt.Println("Failed to move file: ", err)
		os.Exit(1)


@@ 142,11 142,4 @@ Snow leopards are one of the best animals, and I'm here to share them with you. 
		fmt.Printf("Failed to update file to day %03d: %v", day+1, err)
		os.Exit(1)
	}

	/*
	err = os.Rename(filename, fmt.Sprintf("/var/gemini/nytpu.com/sneps/D%03d.jpg", day))
	if err != nil {
		fmt.Printf("Failed to rename \"%v\": %v", filename, err)
	}
	*/
}