Discovered ephemeral replies are, in fact, possible.
This commit is contained in:
parent
a0c3103d27
commit
0b163faf32
1 changed files with 59 additions and 47 deletions
|
|
@ -69,6 +69,22 @@ func (b *bot) init() {
|
|||
b.SetCommands(b.ctx)
|
||||
}
|
||||
|
||||
func (b *bot) SendEphemeralMarkdown(ctx *th.Context, message telego.Message, markdown string) error {
|
||||
_, err := ctx.Bot().SendRichMessage(ctx, &telego.SendRichMessageParams{
|
||||
ChatID: tu.ID(message.Chat.ID),
|
||||
EphemeralMessageParameters: &telego.EphemeralMessageParameters{
|
||||
ReceiverUserID: int(message.Message().From.ID),
|
||||
},
|
||||
ReplyParameters: &telego.ReplyParameters{
|
||||
EphemeralMessageID: message.Message().EphemeralMessageID,
|
||||
},
|
||||
RichMessage: telego.InputRichMessage{
|
||||
Markdown: markdown,
|
||||
},
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *bot) AttachHandlers() {
|
||||
fmt.Println("add handlers", b.handler)
|
||||
b.handler.HandleMessage(func(ctx *th.Context, message telego.Message) error {
|
||||
|
|
@ -90,22 +106,33 @@ func (b *bot) AttachHandlers() {
|
|||
}, th.CommandEqual("start"))
|
||||
|
||||
b.handler.HandleMessage(func(ctx *th.Context, message telego.Message) error {
|
||||
fmt.Println("received help command:", message.Text)
|
||||
// Send a message with inline keyboard
|
||||
/*_, _ = ctx.Bot().SendMessage(ctx, tu.Message(
|
||||
tu.ID(message.Chat.ID),
|
||||
fmt.Sprintf("Hello %s!", message.From.FirstName),
|
||||
).WithReplyMarkup(tu.InlineKeyboard(
|
||||
tu.InlineKeyboardRow(
|
||||
tu.InlineKeyboardButton("Go!").WithCallbackData("go"),
|
||||
)),
|
||||
))*/
|
||||
_, err := ctx.Bot().SendMessage(ctx, tu.Message(
|
||||
tu.ID(message.Chat.ID),
|
||||
"This is a help message"))
|
||||
err := b.SendEphemeralMarkdown(ctx, message,
|
||||
`# BibleBot Command Help
|
||||
|
||||
**/help** this dialog.
|
||||
|
||||
**/add [what] [arguments]**
|
||||
|
||||
Adds an announcement, birthday, or verse where **[what]** is one of **announcement**, **birthday**, or **verse**. Both **announcement** and **birthday** do not accept arguments and will initialize a transactional prompt. **verse** will accept a Bible verse as its sole argument or, absent a verse, will prompt the user for the book, chapter, and verse(s). Acceptable verse formats are "book chapter:verse" where **book* may be a standardized book abbreviation or full name, and verse spans may be indicated with a hyphen ("-").
|
||||
|
||||
**Examples**
|
||||
|
||||
**/add birthday** will add a birthday after the user answers the bot's prompts.
|
||||
|
||||
**/add verse rom 5:12** will add Romans 5:12.
|
||||
|
||||
**Note:** Announcements, birthdays, or verses added to the bot may be subject to admin review.
|
||||
`)
|
||||
return err
|
||||
}, th.CommandEqual("help"))
|
||||
|
||||
b.handler.HandleMessage(func(ctx *th.Context, message telego.Message) error {
|
||||
fmt.Println("received verse command")
|
||||
fmt.Println(tu.ParseCommand(message.Text))
|
||||
|
||||
return nil
|
||||
}, th.CommandEqual("verse"))
|
||||
|
||||
}
|
||||
|
||||
func (b *bot) SendMarkdownMessage(chatid int64, message string) error {
|
||||
|
|
@ -165,24 +192,13 @@ func (b *bot) SetCommands(ctx context.Context) (err error) {
|
|||
},
|
||||
{
|
||||
Command: "add",
|
||||
Description: "Submits a passage to the bot's daily passage rotation.",
|
||||
Description: "Adds a verse, announcement, or birthday.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
{
|
||||
Command: "announce",
|
||||
Description: "Adds an announcement to the bot.",
|
||||
},
|
||||
{
|
||||
Command: "announcements",
|
||||
Description: "Lists the current announcements for the week.",
|
||||
},
|
||||
{
|
||||
Command: "birthday",
|
||||
Description: "Add, remove, or list birthdays.",
|
||||
},
|
||||
{
|
||||
Command: "random",
|
||||
Description: "Submits a random Bible passage to the current chat.",
|
||||
Command: "list",
|
||||
Description: "List announcements or birthdays.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
{
|
||||
Command: "settings",
|
||||
|
|
@ -194,9 +210,15 @@ func (b *bot) SetCommands(ctx context.Context) (err error) {
|
|||
Description: "Starts the bot and links it to the current user's channel.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
{
|
||||
Command: "stop",
|
||||
Description: "Stops the bot from participating in the current channel.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
{
|
||||
Command: "verse",
|
||||
Description: "Looks up a Bible passage. Optionally accepts a translation identifier as its second argument.",
|
||||
Description: "Looks up a Bible passage.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
@ -205,35 +227,25 @@ func (b *bot) SetCommands(ctx context.Context) (err error) {
|
|||
Type: "all_group_chats",
|
||||
},
|
||||
Commands: []telego.BotCommand{
|
||||
{
|
||||
/*{
|
||||
Command: "help",
|
||||
Description: "Displays bot usage and help.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
{
|
||||
Command: "add",
|
||||
Description: "Submits a passage to the bot's daily passage rotation.",
|
||||
Description: "Adds a verse, announcement, or birthday.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
{
|
||||
Command: "announce",
|
||||
Description: "Adds an announcement to the bot.",
|
||||
},
|
||||
{
|
||||
Command: "announcements",
|
||||
Description: "Lists the current announcements for the week.",
|
||||
},
|
||||
{
|
||||
Command: "birthday",
|
||||
Description: "Add, remove, or list birthdays.",
|
||||
},
|
||||
{
|
||||
Command: "random",
|
||||
Description: "Submits a random Bible passage to the current chat.",
|
||||
},
|
||||
Command: "list",
|
||||
Description: "List announcements or birthdays.",
|
||||
IsEphemeral: true,
|
||||
},*/
|
||||
{
|
||||
Command: "verse",
|
||||
Description: "Looks up a Bible passage. Optionally accepts a translation identifier as its second argument.",
|
||||
Description: "Looks up a Bible passage.",
|
||||
IsEphemeral: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue