Add more helpers, update README for v4 release.

bot-api-6.1
Syfaro 2016-04-13 09:01:46 -05:00
parent 1ceb22b273
commit ee1d537565
3 changed files with 47 additions and 10 deletions

View File

@ -17,7 +17,10 @@ something with plugins and command handlers without having to design
all that yourself. all that yourself.
Use `github.com/go-telegram-bot-api/telegram-bot-api` for the latest Use `github.com/go-telegram-bot-api/telegram-bot-api` for the latest
version, or use `gopkg.in/telegram-bot-api.v3` for the stable build. version, or use `gopkg.in/telegram-bot-api.v4` for the stable build.
Join [the development group](https://telegram.me/go_telegram_bot_api) if
you want to ask questions or discuss development.
## Example ## Example
@ -29,7 +32,7 @@ package main
import ( import (
"log" "log"
"gopkg.in/telegram-bot-api.v3" "gopkg.in/telegram-bot-api.v4"
) )
func main() { func main() {
@ -65,7 +68,7 @@ you may use a slightly different method.
package main package main
import ( import (
"gopkg.in/telegram-bot-api.v3" "gopkg.in/telegram-bot-api.v4"
"log" "log"
"net/http" "net/http"
) )

View File

@ -559,7 +559,7 @@ type EditMessageTextConfig struct {
Text string Text string
ParseMode string ParseMode string
DisableWebPagePreview bool DisableWebPagePreview bool
ReplyMarkup InlineKeyboardMarkup ReplyMarkup *InlineKeyboardMarkup
} }
func (config EditMessageTextConfig) values() (url.Values, error) { func (config EditMessageTextConfig) values() (url.Values, error) {
@ -580,7 +580,7 @@ func (config EditMessageTextConfig) method() string {
type EditMessageCaptionConfig struct { type EditMessageCaptionConfig struct {
BaseEdit BaseEdit
Caption string Caption string
ReplyMarkup InlineKeyboardMarkup ReplyMarkup *InlineKeyboardMarkup
} }
func (config EditMessageCaptionConfig) values() (url.Values, error) { func (config EditMessageCaptionConfig) values() (url.Values, error) {
@ -595,18 +595,18 @@ func (config EditMessageCaptionConfig) method() string {
return "editMessageCaption" return "editMessageCaption"
} }
// EditMessageReplyMarkup allows you to modify the reply markup // EditMessageReplyMarkupConfig allows you to modify the reply markup
// of a message. // of a message.
type EditMessageReplyMarkup struct { type EditMessageReplyMarkupConfig struct {
BaseEdit BaseEdit
ReplyMarkup InlineKeyboardMarkup ReplyMarkup *InlineKeyboardMarkup
} }
func (config EditMessageReplyMarkup) values() (url.Values, error) { func (config EditMessageReplyMarkupConfig) values() (url.Values, error) {
return config.BaseEdit.values() return config.BaseEdit.values()
} }
func (config EditMessageReplyMarkup) method() string { func (config EditMessageReplyMarkupConfig) method() string {
return "editMessageReplyMarkup" return "editMessageReplyMarkup"
} }

View File

@ -351,3 +351,37 @@ func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
URL: url, URL: url,
} }
} }
// NewEditMessageText allows you to edit the text of a message.
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
return EditMessageTextConfig{
BaseEdit: BaseEdit{
ChatID: chatID,
MessageID: messageID,
},
Text: text,
}
}
// NewEditMessageCaption allows you to edit the caption of a message.
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
return EditMessageCaptionConfig{
BaseEdit: BaseEdit{
ChatID: chatID,
MessageID: messageID,
},
Caption: caption,
}
}
// NewEditMessageReplyMarkup allows you to edit the inline
// keyboard markup.
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
return EditMessageReplyMarkupConfig{
BaseEdit: BaseEdit{
ChatID: chatID,
MessageID: messageID,
},
ReplyMarkup: &replyMarkup,
}
}