mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-15 19:49:53 +01:00
Compare commits
3 Commits
beed95eed9
...
17a754b918
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17a754b918 | ||
|
|
730f91e74e | ||
|
|
dbd34abea1 |
4
go.mod
4
go.mod
@@ -25,6 +25,6 @@ require (
|
|||||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||||
github.com/xujiajun/mmap-go v1.0.1 // indirect
|
github.com/xujiajun/mmap-go v1.0.1 // indirect
|
||||||
github.com/xujiajun/utils v0.0.0-20190123093513-8bf096c4f53b // indirect
|
github.com/xujiajun/utils v0.0.0-20190123093513-8bf096c4f53b // indirect
|
||||||
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
|
golang.org/x/crypto v0.0.0-20220824171710-5757bc0c5503 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
|
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -58,8 +58,8 @@ github.com/xujiajun/utils v0.0.0-20190123093513-8bf096c4f53b/go.mod h1:AZd87GYJl
|
|||||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
|
golang.org/x/crypto v0.0.0-20220824171710-5757bc0c5503 h1:vJ2V3lFLg+bBhgroYuRfyN583UzVveQmIXjc8T/y3to=
|
||||||
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220824171710-5757bc0c5503/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
@@ -73,8 +73,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 h1:Sx/u41w+OwrInGdEckYmEuU5gHoGSL4QbDz3S9s6j4U=
|
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 h1:TyKJRhyo17yWxOMCTHKWrc5rddHORMlnZ/j57umaUd8=
|
||||||
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24/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-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
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=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
|||||||
9
huso.go
9
huso.go
@@ -20,7 +20,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
husoVersion = "1.7"
|
husoVersion = "1.7.1"
|
||||||
registerSecret = "綾波レイ"
|
registerSecret = "綾波レイ"
|
||||||
seasonStrJikan = "seasons/"
|
seasonStrJikan = "seasons/"
|
||||||
userApiJikan = "users/"
|
userApiJikan = "users/"
|
||||||
@@ -67,6 +67,7 @@ var (
|
|||||||
logOut *RingBuf
|
logOut *RingBuf
|
||||||
buildTime string
|
buildTime string
|
||||||
buildCommit string
|
buildCommit string
|
||||||
|
lastAnnounce *SomewhatThreadSafeTime
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -107,7 +108,7 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer searchCache.Close()
|
defer searchCache.Close()
|
||||||
animeListCache, err = bigcache.NewBigCache(bigcache.DefaultConfig(42 * time.Minute))
|
animeListCache, err = bigcache.NewBigCache(bigcache.DefaultConfig(15 * time.Minute))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -126,6 +127,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
lastAnnounce = &SomewhatThreadSafeTime{
|
||||||
|
stamp: time.Now().Add(-1 * time.Hour),
|
||||||
|
}
|
||||||
|
|
||||||
color.Infoln("NutsDB connected")
|
color.Infoln("NutsDB connected")
|
||||||
logOut.WriteLine("🗃️ NutsDB connected")
|
logOut.WriteLine("🗃️ NutsDB connected")
|
||||||
|
|
||||||
|
|||||||
10
klotz.go
10
klotz.go
@@ -1,6 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type AnimeUser struct {
|
type AnimeUser struct {
|
||||||
Anime int64 `json:"anime"`
|
Anime int64 `json:"anime"`
|
||||||
@@ -328,3 +331,8 @@ type MovieChart struct {
|
|||||||
AvgScore float64 `json:"avgScore"`
|
AvgScore float64 `json:"avgScore"`
|
||||||
UserCount int `json:"userCount"`
|
UserCount int `json:"userCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SomewhatThreadSafeTime struct {
|
||||||
|
sync.Mutex
|
||||||
|
stamp time.Time
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Arbeiten() {
|
func Arbeiten() {
|
||||||
for range time.Tick(20 * time.Minute) {
|
for range time.Tick(10 * time.Minute) {
|
||||||
Arbeit()
|
Arbeit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,15 +27,9 @@ func Arbeit() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cleared := 0
|
cleared := 0
|
||||||
checkDate := time.Now().Add(-1 * time.Hour)
|
lastAnnounce.Lock()
|
||||||
|
defer lastAnnounce.Unlock()
|
||||||
newCheckDate := time.Now()
|
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 {
|
for _, a := range appoints {
|
||||||
if a.Time.Add(22 * time.Hour).Before(newCheckDate) {
|
if a.Time.Add(22 * time.Hour).Before(newCheckDate) {
|
||||||
// appointment expired
|
// appointment expired
|
||||||
@@ -48,13 +42,13 @@ func Arbeit() {
|
|||||||
cleared++
|
cleared++
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if checkDate.Add(time.Hour).Before(a.Time) && newCheckDate.Add(time.Hour).After(a.Time) {
|
if lastAnnounce.stamp.Add(time.Hour).Before(a.Time) && newCheckDate.Add(time.Hour).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()))
|
lastAnnounce.stamp = newCheckDate
|
||||||
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))
|
||||||
@@ -70,8 +64,13 @@ func Arbeit() {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ACTUALLY STUPID ENOUGH TO FIX A LOT OF PROBLEMS
|
||||||
|
animeListCache.Reset()
|
||||||
|
|
||||||
color.Infoln("Animelisten abfragen...")
|
color.Infoln("Animelisten abfragen...")
|
||||||
logOut.WriteLine("📜 Animelisten abfragen...")
|
//logOut.WriteLine("📜 Animelisten abfragen...")
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
// iterate anime
|
// iterate anime
|
||||||
for _, a := range animesUsers {
|
for _, a := range animesUsers {
|
||||||
@@ -123,8 +122,11 @@ func Arbeit() {
|
|||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
color.Infof("%d Sachen aktualisiert\n", count)
|
|
||||||
logOut.WriteLine(fmt.Sprintf("📜 %d Sachen aktualisiert", count))
|
if count > 0 {
|
||||||
|
color.Infof("%d Sachen aktualisiert\n", count)
|
||||||
|
logOut.WriteLine(fmt.Sprintf("📜 %d Sachen aktualisiert", count))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BissleArbeiten() {
|
func BissleArbeiten() {
|
||||||
|
|||||||
Reference in New Issue
Block a user