Skip to content

Commit

Permalink
fix: inline mode
Browse files Browse the repository at this point in the history
It still had some bugs
  • Loading branch information
TheTipo01 committed Feb 13, 2024
1 parent fc379cb commit 8c5519d
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ func inlineQuery(c tele.Context) error {
if filename != "" {
if media == Video {
if !hit {
// Upload video to channel, so we can send it even in inline mode
_, err := c.Bot().Send(tele.ChatID(cfg.Channel), cacheVideo[filename])
if err != nil {
return err
// Upload videos to channel, so we can send it even in inline mode
for _, v := range *cacheVideo[filename] {
_, err := c.Bot().Send(tele.ChatID(cfg.Channel), v)
if err != nil {
return err
}
}

go saveVideo(cacheVideo[filename])
Expand All @@ -128,6 +130,8 @@ func inlineQuery(c tele.Context) error {
photos := *cacheAlbum[filename]

for i, p := range photos {
_, _ = c.Bot().Send(tele.ChatID(cfg.Channel), p)

results = append(results, &tele.PhotoResult{
URL: p.FileURL,
ThumbURL: p.FileURL,
Expand All @@ -141,22 +145,16 @@ func inlineQuery(c tele.Context) error {
}
}
}

return c.Answer(&tele.QueryResponse{
Results: results,
CacheTime: 86400, // one day
})
} else {
results = append(results, &tele.ArticleResult{
Title: "Not a valid URL!",
})

results[0].SetResultID(text)

// Send error
return c.Answer(&tele.QueryResponse{
Results: results,
CacheTime: 86400, // one day
})
}

return c.Answer(&tele.QueryResponse{
Results: results,
CacheTime: 86400, // one day
})
}

0 comments on commit 8c5519d

Please sign in to comment.