Init
This commit is contained in:
parent
264c97183e
commit
3faede7b1c
74 changed files with 6228 additions and 1 deletions
88
bot/handlers/start.go
Normal file
88
bot/handlers/start.go
Normal file
|
@ -0,0 +1,88 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/PaulSonOfLars/gotgbot/v2"
|
||||
"github.com/PaulSonOfLars/gotgbot/v2/ext"
|
||||
)
|
||||
|
||||
var startMessage = "govd is an open-source telegram bot " +
|
||||
"that allows you to download medias from " +
|
||||
"various platforms. the project born after " +
|
||||
"the discontinuation of an " +
|
||||
"highly popular bot, known as UVD."
|
||||
|
||||
func getStartKeyboard(bot *gotgbot.Bot) gotgbot.InlineKeyboardMarkup {
|
||||
return gotgbot.InlineKeyboardMarkup{
|
||||
InlineKeyboard: [][]gotgbot.InlineKeyboardButton{
|
||||
{
|
||||
{
|
||||
Text: "add to group",
|
||||
Url: fmt.Sprintf(
|
||||
"https://t.me/%s?startgroup=true",
|
||||
bot.Username,
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
Text: "usage",
|
||||
CallbackData: "help",
|
||||
},
|
||||
{
|
||||
Text: "stats",
|
||||
CallbackData: "stats",
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
Text: "extractors",
|
||||
CallbackData: "extractors",
|
||||
},
|
||||
{
|
||||
Text: "support",
|
||||
Url: "https://t.me/govdsupport",
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
Text: "instances",
|
||||
CallbackData: "instances",
|
||||
},
|
||||
{
|
||||
Text: "github",
|
||||
Url: os.Getenv("REPO_URL"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func StartHandler(bot *gotgbot.Bot, ctx *ext.Context) error {
|
||||
if ctx.EffectiveMessage.Chat.Type != "private" {
|
||||
return nil
|
||||
}
|
||||
keyboard := getStartKeyboard(bot)
|
||||
if ctx.Update.Message != nil {
|
||||
ctx.EffectiveMessage.Reply(
|
||||
bot,
|
||||
startMessage,
|
||||
&gotgbot.SendMessageOpts{
|
||||
ReplyMarkup: &keyboard,
|
||||
},
|
||||
)
|
||||
} else if ctx.Update.CallbackQuery != nil {
|
||||
ctx.CallbackQuery.Answer(bot, nil)
|
||||
ctx.EffectiveMessage.EditText(
|
||||
bot,
|
||||
startMessage,
|
||||
&gotgbot.EditMessageTextOpts{
|
||||
ReplyMarkup: keyboard,
|
||||
},
|
||||
)
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue