mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-15 19:49:53 +01:00
AnnounceAppointmentSoon
This commit is contained in:
47
labersack.go
47
labersack.go
@@ -30,7 +30,7 @@ func SendAppointBroadcast(creator string, app *Appointment) {
|
||||
msgStart.WriteString(fmt.Sprintf("<@%d>", uData.DiscordID))
|
||||
}
|
||||
|
||||
msgs := fmt.Sprintf("🗓️ New appointment for [%s](https://anime.hanami.family/anime/%d) at <t:%d:F> <t:%d:R>", anime.Title, app.Anime, app.Time.Unix(), app.Time.Unix())
|
||||
msgs := fmt.Sprintf("🗓️ New appointment for [%s](https://anime.hanami.family/anime/%d) at\n<t:%d:F>\n<t:%d:R>", anime.Title, app.Anime, app.Time.Unix(), app.Time.Unix())
|
||||
msge := discordgo.MessageEmbed{
|
||||
Description: msgs,
|
||||
URL: fmt.Sprintf("https://anime.hanami.family/anime/%d", app.Anime),
|
||||
@@ -61,3 +61,48 @@ func SendAppointBroadcast(creator string, app *Appointment) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func AnnounceAppointmentSoon(app *Appointment) {
|
||||
if app != nil && discc != nil {
|
||||
watchData, err := GetAnimeWatchFromDb(app.Anime)
|
||||
if err != nil {
|
||||
color.Errorln(err.Error())
|
||||
return
|
||||
}
|
||||
anime, err := SearchAnime(app.Anime)
|
||||
if err != nil {
|
||||
color.Errorln(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var msgStart strings.Builder
|
||||
for _, u := range watchData.Users {
|
||||
uData, err := ReadUser(u.Username)
|
||||
if err != nil || uData.DiscordID == 0 {
|
||||
continue
|
||||
}
|
||||
msgStart.WriteString(fmt.Sprintf("<@%d>", uData.DiscordID))
|
||||
}
|
||||
|
||||
msgs := fmt.Sprintf("⏰ Appointment starting in <t:%d:R>!\n[%s](https://anime.hanami.family/anime/%d) at\n<t:%d:F>", app.Time.Unix(), anime.Title, app.Anime, app.Time.Unix())
|
||||
msge := discordgo.MessageEmbed{
|
||||
Description: msgs,
|
||||
URL: fmt.Sprintf("https://anime.hanami.family/anime/%d", app.Anime),
|
||||
Thumbnail: &discordgo.MessageEmbedThumbnail{URL: anime.ImageLargeURL},
|
||||
Color: 7187428,
|
||||
Footer: &discordgo.MessageEmbedFooter{
|
||||
Text: "huso " + husoVersion,
|
||||
},
|
||||
}
|
||||
|
||||
msgc := discordgo.MessageSend{
|
||||
Content: msgStart.String(),
|
||||
Embeds: []*discordgo.MessageEmbed{&msge},
|
||||
}
|
||||
_, err = discc.ChannelMessageSendComplex("998277590609559632", &msgc)
|
||||
|
||||
if err != nil {
|
||||
color.Errorln(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@ func Arbeit() {
|
||||
} else {
|
||||
cleared++
|
||||
}
|
||||
} else if a.Time.Add(time.Hour).Before(time.Now()) {
|
||||
// This is happening soon
|
||||
AnnounceAppointmentSoon(&a)
|
||||
}
|
||||
}
|
||||
if cleared > 0 {
|
||||
|
||||
Reference in New Issue
Block a user