Compare commits

...

3 Commits

Author SHA1 Message Date
daru
fa765859e4 ☮️ 2022-07-31 19:00:48 +02:00
daru
1f59f13bfc Get your codebase togehter 2022-07-31 14:55:31 +02:00
daru
92660df667 💣🩹 2022-07-31 14:50:56 +02:00
6 changed files with 28 additions and 12 deletions

2
go.mod
View File

@@ -26,5 +26,5 @@ require (
github.com/xujiajun/mmap-go v1.0.1 // indirect
github.com/xujiajun/utils v0.0.0-20190123093513-8bf096c4f53b // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 // indirect
)

2
go.sum
View File

@@ -76,6 +76,8 @@ golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 h1:dyU22nBWzrmTQxtNrr4dzVOva
golang.org/x/sys v0.0.0-20220727055044-e65921a090b8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 h1:aNCnH+Fiqs7ZDTFH6oEFjIfbX2HvgQXJ6uQuUbTobjk=
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

View File

@@ -76,7 +76,7 @@ func main() {
sc := make(chan os.Signal, 1)
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("Last git commit: %s\n", buildCommit)

View File

@@ -55,9 +55,10 @@ type AnimeStudio struct {
}
type Appointment struct {
Anime int64 `json:"anime"`
Time time.Time `json:"date"`
Users []string `json:"users"`
Anime int64 `json:"anime"`
Time time.Time `json:"date"`
Users []string `json:"users"`
Announced bool `json:"announced"`
}
type WatchUser struct {

View File

@@ -432,9 +432,10 @@ func ReadAppointments() ([]Appointment, error) {
return err
}
appointment := Appointment{
Anime: animeId,
Time: date,
Users: appointmentUsers,
Anime: animeId,
Time: date,
Users: appointmentUsers,
Announced: false,
}
appoints = append(appoints, appointment)
}

View File

@@ -27,8 +27,17 @@ func Arbeit() {
}
} else {
cleared := 0
checkDate := time.Now().Add(-1 * time.Hour)
newCheckDate := time.Now()
data, err := animeListCache.Get(bucketAppoint)
if err == nil {
nanora, err := BytesToInt64(data)
if err == nil {
checkDate = time.Unix(0, nanora)
}
}
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
keyBytes := Int64AndDateToBytes(a.Anime, a.Time)
err = DbDelete(bucketAppoint, string(keyBytes))
@@ -38,11 +47,14 @@ func Arbeit() {
} else {
cleared++
}
} else if time.Now().Add(40*time.Minute).Before(a.Time) && time.Now().Add(60*time.Minute).After(a.Time) {
// This has not happened and is happening soon
go AnnounceBomb(a.Anime, a.Time.Unix(), time.Until(a.Time.Add(-25*time.Minute)))
} else {
if checkDate.Add(time.Hour).Before(a.Time) && newCheckDate.Add(time.Hour).After(a.Time) {
// This has not happened and is happening soon
go AnnounceBomb(a.Anime, a.Time.Unix(), time.Until(a.Time.Add(-25*time.Minute)))
}
}
}
animeListCache.Set(bucketAppoint, Int64ToByte(newCheckDate.UnixNano()))
if cleared > 0 {
color.Infof("Cleared %d expired appointments\n", cleared)
logOut.WriteLine(fmt.Sprintf("♻️ Cleared %d expired appointments", cleared))