better backoff, use filters
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
6f7e56fd36
commit
5ad3582a85
7
main.go
7
main.go
@ -5,11 +5,13 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
mbl "git.saintnet.tech/stryan/matrixbotlib"
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/event"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
//GitTag is current git tag
|
||||
@ -42,12 +44,15 @@ func main() {
|
||||
}
|
||||
|
||||
store := mautrix.NewAccountDataStore("nun.batch", matrixClient)
|
||||
_, err = matrixClient.CreateFilter(dataFilter)
|
||||
fID, err := matrixClient.CreateFilter(dataFilter)
|
||||
if err != nil {
|
||||
//don't want to continue if we can't keep state
|
||||
panic(err)
|
||||
}
|
||||
var nun *nunWatch
|
||||
uid := id.NewUserID(strings.ToLower(conf.Username), strings.ToLower(conf.Domain))
|
||||
log.Println(uid)
|
||||
store.SaveFilterID(uid, fID.FilterID)
|
||||
matrixClient.Store = store
|
||||
syncer := matrixClient.Syncer.(*mautrix.DefaultSyncer)
|
||||
mbl.AcceptAllRoomInvites(matrixClient)
|
||||
|
6
nun.go
6
nun.go
@ -39,14 +39,14 @@ func (n *nunWatch) Main() {
|
||||
if n.fail > 3 {
|
||||
log.Println("over three failures, increasing tick time by 5x")
|
||||
ticker.Reset(5 * time.Duration(n.timer) * time.Minute)
|
||||
continue
|
||||
break
|
||||
}
|
||||
newPost, err := getNewestPost("LittleNuns")
|
||||
if err != nil {
|
||||
log.Printf("error getting newest post: %v", err)
|
||||
log.Println("skipping this cycle, incrementing fail count")
|
||||
n.fail++
|
||||
continue
|
||||
break
|
||||
}
|
||||
if n.fail != 0 {
|
||||
n.fail = 0
|
||||
@ -68,7 +68,7 @@ func (n *nunWatch) Main() {
|
||||
roomResp, err := n.client.JoinedRooms()
|
||||
if err != nil {
|
||||
log.Printf("error getting joined rooms: %v", err)
|
||||
continue
|
||||
break
|
||||
}
|
||||
rooms := roomResp.JoinedRooms
|
||||
for _, room := range rooms {
|
||||
|
Loading…
Reference in New Issue
Block a user