check 140 digits for twitter
This commit is contained in:
9
main.go
9
main.go
@@ -5,10 +5,13 @@ import (
|
||||
"os"
|
||||
"tweetdistributor/discord"
|
||||
"tweetdistributor/output"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
const maxTweetLength = 140
|
||||
|
||||
func main() {
|
||||
d := discord.Discord(os.Getenv("DISCORD_TOKEN"), os.Getenv("DISCORD_CHANNEL"))
|
||||
|
||||
@@ -23,6 +26,12 @@ func main() {
|
||||
outputs = append(outputs, output.BlueskyOutput(os.Getenv("BSKY_IDENTIFIER"), os.Getenv("BSKY_PASSWORD")))
|
||||
|
||||
for tweet := range tweetchannel {
|
||||
if length := utf8.RuneCountInString(tweet.Content); length > maxTweetLength {
|
||||
errstr := fmt.Sprintf("Error: message is %d characters, exceeding the %d character limit; not posted", length, maxTweetLength)
|
||||
fmt.Fprintln(os.Stderr, errstr)
|
||||
d.Write(errstr)
|
||||
continue
|
||||
}
|
||||
for _, output := range outputs {
|
||||
err := output.Write(tweet.Content)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user