mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 10:29:52 +01:00
Compare commits
3 Commits
ecba4d68e6
...
ec6ed3cc63
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec6ed3cc63 | ||
|
|
2e5b45a699 | ||
|
|
10a563bb23 |
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 time.Now().Before(a.Time) && time.Now().Add(time.Hour).After(a.Time) {
|
||||
// This has not happened and is happening soon
|
||||
AnnounceAppointmentSoon(&a)
|
||||
}
|
||||
}
|
||||
if cleared > 0 {
|
||||
|
||||
Reference in New Issue
Block a user