Add support for games, among other updates.

This commit is contained in:
Syfaro 2016-10-03 10:47:19 -05:00
parent a7f48eb2dd
commit f3a33ae6f1
3 changed files with 216 additions and 18 deletions

View file

@ -275,6 +275,7 @@ func (config PhotoConfig) method() string {
// AudioConfig contains information about a SendAudio request.
type AudioConfig struct {
BaseFile
Caption string
Duration int
Performer string
Title string
@ -431,6 +432,7 @@ func (config VideoConfig) method() string {
// VoiceConfig contains information about a SendVoice request.
type VoiceConfig struct {
BaseFile
Caption string
Duration int
}
@ -539,6 +541,90 @@ func (config ContactConfig) method() string {
return "sendContact"
}
// GameConfig allows you to send a game.
type GameConfig struct {
BaseChat
GameShortName string
}
func (config GameConfig) values() (url.Values, error) {
v, _ := config.BaseChat.values()
v.Add("game_short_name", config.GameShortName)
return v, nil
}
func (config GameConfig) method() string {
return "sendGame"
}
// SetGameScoreConfig allows you to update the game score in a chat.
type SetGameScoreConfig struct {
UserID int
Score int
ChatID int
ChannelUsername string
MessageID int
InlineMessageID string
EditMessage bool
}
func (config SetGameScoreConfig) values() (url.Values, error) {
v := url.Values{}
v.Add("user_id", strconv.Itoa(config.UserID))
v.Add("score", strconv.Itoa(config.Score))
if config.InlineMessageID == "" {
if config.ChannelUsername == "" {
v.Add("chat_id", strconv.Itoa(config.ChatID))
} else {
v.Add("chat_id", config.ChannelUsername)
}
v.Add("message_id", strconv.Itoa(config.MessageID))
} else {
v.Add("inline_message_id", config.InlineMessageID)
}
v.Add("edit_message", strconv.FormatBool(config.EditMessage))
return v, nil
}
func (config SetGameScoreConfig) method() string {
return "setGameScore"
}
// GetGameHighScoresConfig allows you to fetch the high scores for a game.
type GetGameHighScoresConfig struct {
UserID int
ChatID int
ChannelUsername string
MessageID int
InlineMessageID string
}
func (config GetGameHighScoresConfig) values() (url.Values, error) {
v := url.Values{}
v.Add("user_id", strconv.Itoa(config.UserID))
if config.InlineMessageID == "" {
if config.ChannelUsername == "" {
v.Add("chat_id", strconv.Itoa(config.ChatID))
} else {
v.Add("chat_id", config.ChannelUsername)
}
v.Add("message_id", strconv.Itoa(config.MessageID))
} else {
v.Add("inline_message_id", config.InlineMessageID)
}
return v, nil
}
func (config GetGameHighScoresConfig) method() string {
return "getGameHighScores"
}
// ChatActionConfig contains information about a SendChatAction request.
type ChatActionConfig struct {
BaseChat
@ -669,6 +755,7 @@ type CallbackConfig struct {
CallbackQueryID string `json:"callback_query_id"`
Text string `json:"text"`
ShowAlert bool `json:"show_alert"`
URL string `json:"url"`
}
// ChatMemberConfig contains information about a user in a chat for use