Skip to content

Commit

Permalink
feat: add start message and buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisin0 committed Jul 19, 2024
1 parent c78cae0 commit 8f44196
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions config/buttons.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package config
import "github.com/PaulSonOfLars/gotgbot/v2"

var Buttons map[string][][]gotgbot.InlineKeyboardButton = map[string][][]gotgbot.InlineKeyboardButton{
"START": {{aboutButton, helpButton}, {{Text: "ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ ᴏᴡɴ ʙᴏᴛ", Url: "https://tg-message-store.vercel.app"}}},
"ABOUT": {{homeButton, helpButton}, {{Text: "Source 🔗", Url: "https://github.com/Jisin0/TGMessageStore"}}},
"HELP": {{aboutButton, homeButton}},
}
Expand Down
6 changes: 4 additions & 2 deletions config/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
// Standard command replies. Add a new entry to create new command no extra configs needed.
var Commands map[string]string = map[string]string{
"START": `
Hey there partner !
<i>👋 Hi <b>{mention}</b> I'm a bot that can create <b>links</b> to <b>store</b> your <b>files and messages</b> in a single click 🔗
<b>Learn</b> how to use me 👉 /help to easily <b>share</b> content with anyone 👣 </i>
`,
"ABOUT": `
○ <b>Language</b>: <a href='https://go.dev'>GO</a>
Expand All @@ -23,6 +24,7 @@ Hey there partner !

"HELP": `
<i>👋 Hey {mention} I'm a bot that can create <b>permanent</b> links to a single or a <b>batch</b> of messages.</i>
<i><b>Add</b> me to your <b>channel</b> where you'll posting all the content before using me 😉</i>
<i>Here's a list of my available commands 👉</i>
Expand All @@ -31,7 +33,7 @@ Hey there partner !
/genlink : Create link for a single post.
/about : Get some data about the bot.
/help : Display this help message.
/privacy: Leran how this bot uses your data.
/privacy: Learn how this bot uses your data.
`,

"PRIVACY": `<i>This bot does not connect to any datbase and hence <b>does not store any user data</b> in any form.</i>`,
Expand Down
13 changes: 2 additions & 11 deletions plugins/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,11 @@ func CommandHandler(bot *gotgbot.Bot, ctx *ext.Context) error {

cmd := strings.ToUpper(strings.Split(strings.ToLower(strings.Fields(update.GetText())[0]), "@")[0][1:])

var text string
if s, k := config.Commands[cmd]; k {
text = s
} else {
if update.Chat.Type != gotgbot.ChatTypePrivate {
return nil
}

text = config.CommandNotFound
}
text, buttons := config.GetCommand(cmd)

text = format.BasicFormat(text, user)

_, err := bot.SendMessage(update.Chat.Id, text, &gotgbot.SendMessageOpts{ParseMode: gotgbot.ParseModeHTML, LinkPreviewOptions: &gotgbot.LinkPreviewOptions{IsDisabled: true}, ReplyMarkup: gotgbot.InlineKeyboardMarkup{InlineKeyboard: config.Buttons[cmd]}})
_, err := bot.SendMessage(update.Chat.Id, text, &gotgbot.SendMessageOpts{ParseMode: gotgbot.ParseModeHTML, LinkPreviewOptions: &gotgbot.LinkPreviewOptions{IsDisabled: true}, ReplyMarkup: gotgbot.InlineKeyboardMarkup{InlineKeyboard: buttons}})
if err != nil {
fmt.Println(err)
}
Expand Down

0 comments on commit 8f44196

Please sign in to comment.