mirror of
https://github.com/idanoo/NZCovidBot
synced 2025-07-03 04:02:14 +00:00
Use discord embeds
This commit is contained in:
parent
3fc389f1d6
commit
df3c0b9ed4
2 changed files with 11 additions and 20 deletions
|
@ -45,7 +45,8 @@ func formatCsvDiscordRow(data string) string {
|
||||||
|
|
||||||
c := make([]string, 0)
|
c := make([]string, 0)
|
||||||
c = append(c, fields...)
|
c = append(c, fields...)
|
||||||
return fmt.Sprintf("**%s** %s on _%s_ - _%s_", c[1], c[2], c[4], c[5])
|
endtime := strings.Split(c[5], ", ")
|
||||||
|
return fmt.Sprintf("**%s** %s on _%s_ - _%s_", c[1], c[2], c[4], endtime[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
// formatCsvTwitterRow Format the string to a tidy string for the interwebs
|
// formatCsvTwitterRow Format the string to a tidy string for the interwebs
|
||||||
|
@ -61,7 +62,8 @@ func formatCsvTwitterRow(data string) string {
|
||||||
|
|
||||||
c := make([]string, 0)
|
c := make([]string, 0)
|
||||||
c = append(c, fields...)
|
c = append(c, fields...)
|
||||||
return fmt.Sprintf("**%s** - %s\n_%s_ - _%s_", c[1], c[2], c[4], c[5])
|
endtime := strings.Split(c[5], ", ")
|
||||||
|
return fmt.Sprintf("**%s** - %s _%s_ - _%s_", c[1], c[2], c[4], endtime[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPostableDiscordData() string {
|
func getPostableDiscordData() string {
|
||||||
|
@ -78,7 +80,7 @@ func getPostableDiscordData() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(rows, "\n\n")
|
return strings.Join(rows, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPostableTwitterData() string {
|
func getPostableTwitterData() string {
|
||||||
|
|
|
@ -22,25 +22,14 @@ func postToDiscord(webhookString string, msg string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// message, err := webhook.SendContent(msg)
|
_, err = webhook.SendEmbeds(api.NewEmbedBuilder().
|
||||||
// if err != nil {
|
SetDescription(msg).
|
||||||
// log.Print(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // message, err = webhook.SendEmbeds(api.NewEmbedBuilder().
|
|
||||||
// // SetDescription(msg).
|
|
||||||
// // Build(),
|
|
||||||
// // )
|
|
||||||
// if err != nil {
|
|
||||||
// log.Print(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
_, err = webhook.SendMessage(api.NewWebhookMessageCreateBuilder().
|
|
||||||
SetContent(msg).
|
|
||||||
Build(),
|
Build(),
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.Print(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue