Skip to content

Commit ee1d537

Browse files
author
Syfaro
committed
Add more helpers, update README for v4 release.
1 parent 1ceb22b commit ee1d537

File tree

3 files changed

+47
-10
lines changed

3 files changed

+47
-10
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ something with plugins and command handlers without having to design
1717
all that yourself.
1818

1919
Use `github.com/go-telegram-bot-api/telegram-bot-api` for the latest
20-
version, or use `gopkg.in/telegram-bot-api.v3` for the stable build.
20+
version, or use `gopkg.in/telegram-bot-api.v4` for the stable build.
21+
22+
Join [the development group](https://telegram.me/go_telegram_bot_api) if
23+
you want to ask questions or discuss development.
2124

2225
## Example
2326

@@ -29,7 +32,7 @@ package main
2932

3033
import (
3134
"log"
32-
"gopkg.in/telegram-bot-api.v3"
35+
"gopkg.in/telegram-bot-api.v4"
3336
)
3437

3538
func main() {
@@ -65,7 +68,7 @@ you may use a slightly different method.
6568
package main
6669

6770
import (
68-
"gopkg.in/telegram-bot-api.v3"
71+
"gopkg.in/telegram-bot-api.v4"
6972
"log"
7073
"net/http"
7174
)

configs.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ type EditMessageTextConfig struct {
559559
Text string
560560
ParseMode string
561561
DisableWebPagePreview bool
562-
ReplyMarkup InlineKeyboardMarkup
562+
ReplyMarkup *InlineKeyboardMarkup
563563
}
564564

565565
func (config EditMessageTextConfig) values() (url.Values, error) {
@@ -580,7 +580,7 @@ func (config EditMessageTextConfig) method() string {
580580
type EditMessageCaptionConfig struct {
581581
BaseEdit
582582
Caption string
583-
ReplyMarkup InlineKeyboardMarkup
583+
ReplyMarkup *InlineKeyboardMarkup
584584
}
585585

586586
func (config EditMessageCaptionConfig) values() (url.Values, error) {
@@ -595,18 +595,18 @@ func (config EditMessageCaptionConfig) method() string {
595595
return "editMessageCaption"
596596
}
597597

598-
// EditMessageReplyMarkup allows you to modify the reply markup
598+
// EditMessageReplyMarkupConfig allows you to modify the reply markup
599599
// of a message.
600-
type EditMessageReplyMarkup struct {
600+
type EditMessageReplyMarkupConfig struct {
601601
BaseEdit
602-
ReplyMarkup InlineKeyboardMarkup
602+
ReplyMarkup *InlineKeyboardMarkup
603603
}
604604

605-
func (config EditMessageReplyMarkup) values() (url.Values, error) {
605+
func (config EditMessageReplyMarkupConfig) values() (url.Values, error) {
606606
return config.BaseEdit.values()
607607
}
608608

609-
func (config EditMessageReplyMarkup) method() string {
609+
func (config EditMessageReplyMarkupConfig) method() string {
610610
return "editMessageReplyMarkup"
611611
}
612612

helpers.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,37 @@ func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
351351
URL: url,
352352
}
353353
}
354+
355+
// NewEditMessageText allows you to edit the text of a message.
356+
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
357+
return EditMessageTextConfig{
358+
BaseEdit: BaseEdit{
359+
ChatID: chatID,
360+
MessageID: messageID,
361+
},
362+
Text: text,
363+
}
364+
}
365+
366+
// NewEditMessageCaption allows you to edit the caption of a message.
367+
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
368+
return EditMessageCaptionConfig{
369+
BaseEdit: BaseEdit{
370+
ChatID: chatID,
371+
MessageID: messageID,
372+
},
373+
Caption: caption,
374+
}
375+
}
376+
377+
// NewEditMessageReplyMarkup allows you to edit the inline
378+
// keyboard markup.
379+
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
380+
return EditMessageReplyMarkupConfig{
381+
BaseEdit: BaseEdit{
382+
ChatID: chatID,
383+
MessageID: messageID,
384+
},
385+
ReplyMarkup: &replyMarkup,
386+
}
387+
}

0 commit comments

Comments
 (0)