Skip to content

Commit a880604

Browse files
feat(bot): add stream and download buttons
1 parent 59085d4 commit a880604

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

internal/commands/stream.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package commands
22

33
import (
44
"fmt"
5+
"strings"
56

67
"EverythingSuckz/fsb/config"
78
"EverythingSuckz/fsb/internal/utils"
@@ -58,6 +59,34 @@ func sendLink(ctx *ext.Context, u *ext.Update) error {
5859
)
5960
hash := utils.GetShortHash(fullHash)
6061
link := fmt.Sprintf("%s/stream/%d?hash=%s", config.ValueOf.Host, messageID, hash)
61-
ctx.Reply(u, link, nil)
62+
row := tg.KeyboardButtonRow{
63+
Buttons: []tg.KeyboardButtonClass{
64+
&tg.KeyboardButtonURL{
65+
Text: "Download",
66+
URL: link + "&d=true",
67+
},
68+
},
69+
}
70+
if strings.Contains(file.MimeType, "video") || strings.Contains(file.MimeType, "audio") || strings.Contains(file.MimeType, "pdf") {
71+
row.Buttons = append(row.Buttons, &tg.KeyboardButtonURL{
72+
Text: "Stream",
73+
URL: link,
74+
})
75+
}
76+
markup := &tg.ReplyInlineMarkup{
77+
Rows: []tg.KeyboardButtonRow{row},
78+
}
79+
if strings.Contains(link, "http://localhost") {
80+
markup = nil
81+
}
82+
_, err = ctx.Reply(u, link, &ext.ReplyOpts{
83+
Markup: markup,
84+
NoWebpage: false,
85+
ReplyToMessageId: u.EffectiveMessage.ID,
86+
})
87+
if err != nil {
88+
utils.Logger.Sugar().Error(err)
89+
ctx.Reply(u, fmt.Sprintf("Error - %s", err.Error()), nil)
90+
}
6291
return dispatcher.EndGroups
6392
}

0 commit comments

Comments
 (0)