mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-15 19:39:52 +01:00
💣🩹
This commit is contained in:
2
huso.go
2
huso.go
@@ -76,7 +76,7 @@ func main() {
|
|||||||
sc := make(chan os.Signal, 1)
|
sc := make(chan os.Signal, 1)
|
||||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
||||||
|
|
||||||
logOut = NewRingBuf(10101)
|
logOut = NewRingBuf(101010)
|
||||||
|
|
||||||
color.Notice.Printf("huso %s built on %s with %s\n", husoVersion, buildTime, runtime.Version())
|
color.Notice.Printf("huso %s built on %s with %s\n", husoVersion, buildTime, runtime.Version())
|
||||||
color.Notice.Printf("Last git commit: %s\n", buildCommit)
|
color.Notice.Printf("Last git commit: %s\n", buildCommit)
|
||||||
|
|||||||
1
klotz.go
1
klotz.go
@@ -58,6 +58,7 @@ type Appointment struct {
|
|||||||
Anime int64 `json:"anime"`
|
Anime int64 `json:"anime"`
|
||||||
Time time.Time `json:"date"`
|
Time time.Time `json:"date"`
|
||||||
Users []string `json:"users"`
|
Users []string `json:"users"`
|
||||||
|
Announced bool `json:"announced"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WatchUser struct {
|
type WatchUser struct {
|
||||||
|
|||||||
1
nuss.go
1
nuss.go
@@ -435,6 +435,7 @@ func ReadAppointments() ([]Appointment, error) {
|
|||||||
Anime: animeId,
|
Anime: animeId,
|
||||||
Time: date,
|
Time: date,
|
||||||
Users: appointmentUsers,
|
Users: appointmentUsers,
|
||||||
|
Announced: false,
|
||||||
}
|
}
|
||||||
appoints = append(appoints, appointment)
|
appoints = append(appoints, appointment)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,18 @@ func Arbeit() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cleared := 0
|
cleared := 0
|
||||||
|
checkDate := time.Now()
|
||||||
|
data, err := animeListCache.Get(bucketAppoint)
|
||||||
|
if err == nil {
|
||||||
|
err = nil
|
||||||
|
nanora, err := BytesToInt64(data)
|
||||||
|
if err == nil {
|
||||||
|
checkDate = time.Unix(0, nanora)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newCheckDate := time.Now()
|
||||||
for _, a := range appoints {
|
for _, a := range appoints {
|
||||||
if a.Time.Add(22 * time.Hour).Before(time.Now()) {
|
if a.Time.Add(22 * time.Hour).Before(newCheckDate) {
|
||||||
// appointment expired
|
// appointment expired
|
||||||
keyBytes := Int64AndDateToBytes(a.Anime, a.Time)
|
keyBytes := Int64AndDateToBytes(a.Anime, a.Time)
|
||||||
err = DbDelete(bucketAppoint, string(keyBytes))
|
err = DbDelete(bucketAppoint, string(keyBytes))
|
||||||
@@ -38,11 +48,14 @@ func Arbeit() {
|
|||||||
} else {
|
} else {
|
||||||
cleared++
|
cleared++
|
||||||
}
|
}
|
||||||
} else if time.Now().Add(40*time.Minute).Before(a.Time) && time.Now().Add(60*time.Minute).After(a.Time) {
|
} else {
|
||||||
|
if checkDate.Add(40*time.Minute).Before(a.Time) && newCheckDate.Add(60*time.Minute).After(a.Time) {
|
||||||
// This has not happened and is happening soon
|
// This has not happened and is happening soon
|
||||||
go AnnounceBomb(a.Anime, a.Time.Unix(), time.Until(a.Time.Add(-25*time.Minute)))
|
go AnnounceBomb(a.Anime, a.Time.Unix(), time.Until(a.Time.Add(-25*time.Minute)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
animeListCache.Set(bucketAppoint, Int64ToByte(newCheckDate.UnixNano()))
|
||||||
if cleared > 0 {
|
if cleared > 0 {
|
||||||
color.Infof("Cleared %d expired appointments\n", cleared)
|
color.Infof("Cleared %d expired appointments\n", cleared)
|
||||||
logOut.WriteLine(fmt.Sprintf("♻️ Cleared %d expired appointments", cleared))
|
logOut.WriteLine(fmt.Sprintf("♻️ Cleared %d expired appointments", cleared))
|
||||||
|
|||||||
Reference in New Issue
Block a user