This commit is contained in:
parent
bd8a437f43
commit
1690279d5c
2 changed files with 15 additions and 7 deletions
|
@ -127,7 +127,7 @@ func (bluesky *Bluesky) CheckSessionValid() {
|
||||||
|
|
||||||
type TelegramRecord struct {
|
type TelegramRecord struct {
|
||||||
ChannelID int64 `json:"channel_id"`
|
ChannelID int64 `json:"channel_id"`
|
||||||
MessageID int `json:"message_id"`
|
MessageID []int `json:"message_id"`
|
||||||
Link *Link `json:"link"`
|
Link *Link `json:"link"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
20
main.go
20
main.go
|
@ -92,8 +92,10 @@ func main() {
|
||||||
r, e := h.bsky.Bluesky.GetTelegramData(s[2])
|
r, e := h.bsky.Bluesky.GetTelegramData(s[2])
|
||||||
if e == "" {
|
if e == "" {
|
||||||
log.Printf("Found post %s in channel %d, deleting", s[2], r.ChannelID)
|
log.Printf("Found post %s in channel %d, deleting", s[2], r.ChannelID)
|
||||||
m := tgbotapi.NewDeleteMessage(r.ChannelID, r.MessageID)
|
for _, msgID := range r.MessageID {
|
||||||
h.tg.Send(m)
|
m := tgbotapi.NewDeleteMessage(r.ChannelID, msgID)
|
||||||
|
h.tg.Send(m)
|
||||||
|
}
|
||||||
h.bsky.Bluesky.DeleteRecord([]string{s[2], s[1], "blue.zio.bsky2tg.post"})
|
h.bsky.Bluesky.DeleteRecord([]string{s[2], s[1], "blue.zio.bsky2tg.post"})
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Unable to find post %s on PDS", s[2])
|
log.Printf("Unable to find post %s on PDS", s[2])
|
||||||
|
@ -169,8 +171,10 @@ func (h *handler) HandleEvent(ctx context.Context, event *models.Event) error {
|
||||||
bsky.PersistAuthSession(h.bsky.Bluesky.Cfg)
|
bsky.PersistAuthSession(h.bsky.Bluesky.Cfg)
|
||||||
r, e := h.bsky.Bluesky.GetTelegramData(event.Commit.RKey)
|
r, e := h.bsky.Bluesky.GetTelegramData(event.Commit.RKey)
|
||||||
if e == "" {
|
if e == "" {
|
||||||
m := tgbotapi.NewDeleteMessage(r.ChannelID, r.MessageID)
|
for _, msgID := range r.MessageID {
|
||||||
h.tg.Send(m)
|
m := tgbotapi.NewDeleteMessage(r.ChannelID, msgID)
|
||||||
|
h.tg.Send(m)
|
||||||
|
}
|
||||||
h.bsky.Bluesky.DeleteRecord([]string{event.Commit.RKey, event.Did, "blue.zio.bsky2tg.post"})
|
h.bsky.Bluesky.DeleteRecord([]string{event.Commit.RKey, event.Did, "blue.zio.bsky2tg.post"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,9 +282,13 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
||||||
} else {
|
} else {
|
||||||
resp, _ := h.tg.SendMediaGroup(tgbotapi.NewMediaGroup(cid, mediaGroup))
|
resp, _ := h.tg.SendMediaGroup(tgbotapi.NewMediaGroup(cid, mediaGroup))
|
||||||
uri, cid := getLink(event)
|
uri, cid := getLink(event)
|
||||||
|
var messageIDs []int
|
||||||
|
for _, msgID := range resp {
|
||||||
|
messageIDs = append(messageIDs, msgID.MessageID)
|
||||||
|
}
|
||||||
h.bsky.Bluesky.CommitTelegramResponse(&bsky.TelegramRecord{
|
h.bsky.Bluesky.CommitTelegramResponse(&bsky.TelegramRecord{
|
||||||
ChannelID: resp[0].Chat.ID,
|
ChannelID: resp[0].Chat.ID,
|
||||||
MessageID: resp[0].MessageID,
|
MessageID: messageIDs,
|
||||||
Link: &bsky.Link{
|
Link: &bsky.Link{
|
||||||
Cid: cid,
|
Cid: cid,
|
||||||
URI: uri,
|
URI: uri,
|
||||||
|
@ -312,7 +320,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
||||||
uri, cid := getLink(event)
|
uri, cid := getLink(event)
|
||||||
h.bsky.Bluesky.CommitTelegramResponse(&bsky.TelegramRecord{
|
h.bsky.Bluesky.CommitTelegramResponse(&bsky.TelegramRecord{
|
||||||
ChannelID: resp.Chat.ID,
|
ChannelID: resp.Chat.ID,
|
||||||
MessageID: resp.MessageID,
|
MessageID: []int{resp.MessageID},
|
||||||
Link: &bsky.Link{
|
Link: &bsky.Link{
|
||||||
Cid: cid,
|
Cid: cid,
|
||||||
URI: uri,
|
URI: uri,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue