Add Telegram bot listener with inline post management
All checks were successful
/ build (push) Successful in 1m34s
All checks were successful
/ build (push) Successful in 1m34s
This commit is contained in:
parent
46a33f2af7
commit
b3e37757a2
3 changed files with 339 additions and 8 deletions
26
main.go
26
main.go
|
|
@ -37,15 +37,17 @@ const (
|
|||
)
|
||||
|
||||
type handler struct {
|
||||
seenSeqs map[int64]struct{}
|
||||
tg *tgbotapi.BotAPI
|
||||
bsky *bsky.BSky
|
||||
seenSeqs map[int64]struct{}
|
||||
tg *tgbotapi.BotAPI
|
||||
bsky *bsky.BSky
|
||||
channelAdmins map[int64]bool
|
||||
}
|
||||
|
||||
var (
|
||||
post = flag.String("post", "", "URL to a BlueSky post")
|
||||
delete = flag.Bool("delete", false, "true/false to delete post")
|
||||
oldPosts = flag.Float64("oldposttime", 1, "Ignore posts if createdAt more than this many hours ago")
|
||||
post = flag.String("post", "", "URL to a BlueSky post")
|
||||
delete = flag.Bool("delete", false, "true/false to delete post")
|
||||
oldPosts = flag.Float64("oldposttime", 1, "Ignore posts if createdAt more than this many hours ago")
|
||||
botOnly = flag.Bool("bot", false, "Run only the Telegram bot listener, without Jetstream sync")
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -60,8 +62,9 @@ func main() {
|
|||
}
|
||||
|
||||
h := &handler{
|
||||
seenSeqs: make(map[int64]struct{}),
|
||||
bsky: bskyClient,
|
||||
seenSeqs: make(map[int64]struct{}),
|
||||
bsky: bskyClient,
|
||||
channelAdmins: make(map[int64]bool),
|
||||
}
|
||||
|
||||
endpoint := "https://api.telegram.org/bot%s/%s"
|
||||
|
|
@ -126,6 +129,13 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
if *botOnly {
|
||||
h.StartBotListener()
|
||||
return
|
||||
}
|
||||
|
||||
go h.StartBotListener()
|
||||
|
||||
ctx := context.Background()
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: slog.LevelDebug.Level(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue