36 lines
910 B
Go
36 lines
910 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"tweetdistributor/discord"
|
|
"tweetdistributor/output"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
func main() {
|
|
d := discord.Discord(os.Getenv("DISCORD_TOKEN"), os.Getenv("DISCORD_CHANNEL"))
|
|
|
|
tweetchannel := make(chan *discordgo.MessageCreate, 1)
|
|
d.BeginRead(tweetchannel)
|
|
|
|
d.Write("Tweetdistributor Started")
|
|
|
|
var outputs []output.OutputInterface
|
|
outputs = append(outputs, output.StdOutput())
|
|
outputs = append(outputs, output.TwitterOutput(os.Getenv("TW_ACCESS_TOKEN"), os.Getenv("TW_ACCESS_SECRET")))
|
|
outputs = append(outputs, output.BlueskyOutput(os.Getenv("BSKY_IDENTIFIER"), os.Getenv("BSKY_PASSWORD")))
|
|
|
|
for tweet := range tweetchannel {
|
|
for _, output := range outputs {
|
|
err := output.Write(tweet.Content)
|
|
if err != nil {
|
|
errstr := fmt.Sprintf("%s Error: %s", output.GetName(), err)
|
|
fmt.Fprintln(os.Stderr, errstr)
|
|
d.Write(errstr)
|
|
}
|
|
}
|
|
}
|
|
}
|