Skip to content

Commit

Permalink
feat(bot): add stream and download buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
EverythingSuckz committed Dec 14, 2023
1 parent 59085d4 commit a880604
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion internal/commands/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"fmt"
"strings"

"EverythingSuckz/fsb/config"
"EverythingSuckz/fsb/internal/utils"
Expand Down Expand Up @@ -58,6 +59,34 @@ func sendLink(ctx *ext.Context, u *ext.Update) error {
)
hash := utils.GetShortHash(fullHash)
link := fmt.Sprintf("%s/stream/%d?hash=%s", config.ValueOf.Host, messageID, hash)
ctx.Reply(u, link, nil)
row := tg.KeyboardButtonRow{
Buttons: []tg.KeyboardButtonClass{
&tg.KeyboardButtonURL{
Text: "Download",
URL: link + "&d=true",
},
},
}
if strings.Contains(file.MimeType, "video") || strings.Contains(file.MimeType, "audio") || strings.Contains(file.MimeType, "pdf") {
row.Buttons = append(row.Buttons, &tg.KeyboardButtonURL{
Text: "Stream",
URL: link,
})
}
markup := &tg.ReplyInlineMarkup{
Rows: []tg.KeyboardButtonRow{row},
}
if strings.Contains(link, "http://localhost") {
markup = nil
}
_, err = ctx.Reply(u, link, &ext.ReplyOpts{
Markup: markup,
NoWebpage: false,
ReplyToMessageId: u.EffectiveMessage.ID,
})
if err != nil {
utils.Logger.Sugar().Error(err)
ctx.Reply(u, fmt.Sprintf("Error - %s", err.Error()), nil)
}
return dispatcher.EndGroups
}

0 comments on commit a880604

Please sign in to comment.