replace go-mastodon with own fork

This commit is contained in:
Andriy Cherniy 2024-01-05 23:42:47 +02:00
parent 5d3bcb5c3d
commit ae764ce83a
3 changed files with 11 additions and 8 deletions

2
go.mod
View file

@ -3,7 +3,7 @@ module uabot
go 1.20 go 1.20
require ( require (
github.com/mattn/go-mastodon v0.0.6 github.com/UA-Fediland/go-mastodon v0.0.0-20240105213412-04581fbfe202
gorm.io/gorm v1.25.4 gorm.io/gorm v1.25.4
) )

2
go.sum
View file

@ -1,3 +1,5 @@
github.com/UA-Fediland/go-mastodon v0.0.0-20240105213412-04581fbfe202 h1:UOj1nI2Vn5xsIQWn9R9yotWzrkPXz3pZzCNEd3/olDU=
github.com/UA-Fediland/go-mastodon v0.0.0-20240105213412-04581fbfe202/go.mod h1:JXtz7aNX/EdsWXua/8R7KL881WWcfx3GTDgbf2bht7E=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

15
main.go
View file

@ -8,11 +8,12 @@ import (
"path" "path"
"regexp" "regexp"
"strings" "strings"
"time"
"github.com/joho/godotenv" "github.com/joho/godotenv"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/mattn/go-mastodon" "github.com/UA-Fediland/go-mastodon"
"gorm.io/driver/postgres" "gorm.io/driver/postgres"
"gorm.io/gorm" "gorm.io/gorm"
"maunium.net/go/mautrix" "maunium.net/go/mautrix"
@ -108,7 +109,6 @@ func main() {
var subscribers []*mastodon.Account var subscribers []*mastodon.Account
var pg mastodon.Pagination var pg mastodon.Pagination
log.Info("test")
log.Debug("get followers list") log.Debug("get followers list")
for { for {
fs, err := masto_client.GetAccountFollowers(context.Background(), masto_user.ID, &pg) fs, err := masto_client.GetAccountFollowers(context.Background(), masto_user.ID, &pg)
@ -116,15 +116,16 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
subscribers = append(subscribers, fs...) subscribers = append(subscribers, fs...)
log.Debug(pg) // log.Debug(pg)
log.Debug(pg.MaxID) // log.Debug(pg.MaxID)
if pg.MaxID == "" { if pg.MaxID == "" {
break break
} }
time.Sleep(200 * time.Millisecond)
} }
for subscriber := range subscribers { // for _, subscriber := range subscribers {
log.Debug(subscriber) // log.Debug(subscriber.Acct)
} // }
matrix_client, err := mautrix.NewClient(os.Getenv("MATRIX_HOMESERVER"), m_id.UserID(os.Getenv("MATRIX_USERNAME")), os.Getenv("MATRIX_ACCESS_TOKEN")) matrix_client, err := mautrix.NewClient(os.Getenv("MATRIX_HOMESERVER"), m_id.UserID(os.Getenv("MATRIX_USERNAME")), os.Getenv("MATRIX_ACCESS_TOKEN"))
matrix_client.Store = mautrix.NewAccountDataStore("ua.in.fediland.uabot", matrix_client) matrix_client.Store = mautrix.NewAccountDataStore("ua.in.fediland.uabot", matrix_client)