Add kick and unban methods, update some inline query result responses.
parent
18510df3c9
commit
db12d94016
35
bot.go
35
bot.go
|
@ -502,3 +502,38 @@ func (bot *BotAPI) AnswerCallbackQuery(config CallbackConfig) (APIResponse, erro
|
||||||
|
|
||||||
return bot.MakeRequest("answerCallbackQuery", v)
|
return bot.MakeRequest("answerCallbackQuery", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KickChatMember kicks a user from a chat. Note that this only will work
|
||||||
|
// in supergroups, and requires the bot to be an admin. Also note they
|
||||||
|
// will be unable to rejoin until they are unbanned.
|
||||||
|
func (bot *BotAPI) KickChatMember(config ChatMemberConfig) (APIResponse, error) {
|
||||||
|
v := url.Values{}
|
||||||
|
|
||||||
|
if config.SuperGroupUsername == "" {
|
||||||
|
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
|
||||||
|
} else {
|
||||||
|
v.Add("chat_id", config.SuperGroupUsername)
|
||||||
|
}
|
||||||
|
v.Add("user_id", strconv.Itoa(config.UserID))
|
||||||
|
|
||||||
|
bot.debugLog("kickChatMember", v, nil)
|
||||||
|
|
||||||
|
return bot.MakeRequest("kickChatMember", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnbanChatMember unbans a user from a chat. Note that this only will work
|
||||||
|
// in supergroups, and requires the bot to be an admin.
|
||||||
|
func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error) {
|
||||||
|
v := url.Values{}
|
||||||
|
|
||||||
|
if config.SuperGroupUsername == "" {
|
||||||
|
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
|
||||||
|
} else {
|
||||||
|
v.Add("chat_id", config.SuperGroupUsername)
|
||||||
|
}
|
||||||
|
v.Add("user_id", strconv.Itoa(config.UserID))
|
||||||
|
|
||||||
|
bot.debugLog("unbanChatMember", v, nil)
|
||||||
|
|
||||||
|
return bot.MakeRequest("unbanChatMember", v)
|
||||||
|
}
|
||||||
|
|
|
@ -559,3 +559,9 @@ type CallbackConfig struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
ShowAlert bool `json:"show_alert"`
|
ShowAlert bool `json:"show_alert"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatMemberConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
SuperGroupUsername string
|
||||||
|
UserID int
|
||||||
|
}
|
||||||
|
|
10
helpers.go
10
helpers.go
|
@ -285,10 +285,12 @@ func NewWebhookWithCert(link string, file interface{}) WebhookConfig {
|
||||||
// NewInlineQueryResultArticle creates a new inline query article.
|
// NewInlineQueryResultArticle creates a new inline query article.
|
||||||
func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle {
|
func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle {
|
||||||
return InlineQueryResultArticle{
|
return InlineQueryResultArticle{
|
||||||
Type: "article",
|
Type: "article",
|
||||||
ID: id,
|
ID: id,
|
||||||
Title: title,
|
Title: title,
|
||||||
MessageText: messageText,
|
InputMessageContent: InputTextMessageContent{
|
||||||
|
Text: messageText,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
140
types.go
140
types.go
|
@ -344,81 +344,78 @@ type InlineQuery struct {
|
||||||
|
|
||||||
// InlineQueryResultArticle is an inline query response article.
|
// InlineQueryResultArticle is an inline query response article.
|
||||||
type InlineQueryResultArticle struct {
|
type InlineQueryResultArticle struct {
|
||||||
Type string `json:"type"` // required
|
Type string `json:"type"` // required
|
||||||
ID string `json:"id"` // required
|
ID string `json:"id"` // required
|
||||||
Title string `json:"title"` // required
|
Title string `json:"title"` // required
|
||||||
MessageText string `json:"message_text"` // required
|
InputMessageContent interface{} `json:"input_message_content"` // required
|
||||||
ParseMode string `json:"parse_mode"`
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
DisableWebPagePreview bool `json:"disable_web_page_preview"`
|
URL string `json:"url"`
|
||||||
URL string `json:"url"`
|
HideURL bool `json:"hide_url"`
|
||||||
HideURL bool `json:"hide_url"`
|
Description string `json:"description"`
|
||||||
Description string `json:"description"`
|
ThumbURL string `json:"thumb_url"`
|
||||||
ThumbURL string `json:"thumb_url"`
|
ThumbWidth int `json:"thumb_width"`
|
||||||
ThumbWidth int `json:"thumb_width"`
|
ThumbHeight int `json:"thumb_height"`
|
||||||
ThumbHeight int `json:"thumb_height"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InlineQueryResultPhoto is an inline query response photo.
|
// InlineQueryResultPhoto is an inline query response photo.
|
||||||
type InlineQueryResultPhoto struct {
|
type InlineQueryResultPhoto struct {
|
||||||
Type string `json:"type"` // required
|
Type string `json:"type"` // required
|
||||||
ID string `json:"id"` // required
|
ID string `json:"id"` // required
|
||||||
URL string `json:"photo_url"` // required
|
URL string `json:"photo_url"` // required
|
||||||
MimeType string `json:"mime_type"`
|
MimeType string `json:"mime_type"`
|
||||||
Width int `json:"photo_width"`
|
Width int `json:"photo_width"`
|
||||||
Height int `json:"photo_height"`
|
Height int `json:"photo_height"`
|
||||||
ThumbURL string `json:"thumb_url"`
|
ThumbURL string `json:"thumb_url"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Caption string `json:"caption"`
|
Caption string `json:"caption"`
|
||||||
MessageText string `json:"message_text"`
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
ParseMode string `json:"parse_mode"`
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
DisableWebPagePreview bool `json:"disable_web_page_preview"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InlineQueryResultGIF is an inline query response GIF.
|
// InlineQueryResultGIF is an inline query response GIF.
|
||||||
type InlineQueryResultGIF struct {
|
type InlineQueryResultGIF struct {
|
||||||
Type string `json:"type"` // required
|
Type string `json:"type"` // required
|
||||||
ID string `json:"id"` // required
|
ID string `json:"id"` // required
|
||||||
URL string `json:"gif_url"` // required
|
URL string `json:"gif_url"` // required
|
||||||
Width int `json:"gif_width"`
|
Width int `json:"gif_width"`
|
||||||
Height int `json:"gif_height"`
|
Height int `json:"gif_height"`
|
||||||
ThumbURL string `json:"thumb_url"`
|
ThumbURL string `json:"thumb_url"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Caption string `json:"caption"`
|
Caption string `json:"caption"`
|
||||||
MessageText string `json:"message_text"`
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
ParseMode string `json:"parse_mode"`
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
DisableWebPagePreview bool `json:"disable_web_page_preview"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
|
// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
|
||||||
type InlineQueryResultMPEG4GIF struct {
|
type InlineQueryResultMPEG4GIF struct {
|
||||||
Type string `json:"type"` // required
|
Type string `json:"type"` // required
|
||||||
ID string `json:"id"` // required
|
ID string `json:"id"` // required
|
||||||
URL string `json:"mpeg4_url"` // required
|
URL string `json:"mpeg4_url"` // required
|
||||||
Width int `json:"mpeg4_width"`
|
Width int `json:"mpeg4_width"`
|
||||||
Height int `json:"mpeg4_height"`
|
Height int `json:"mpeg4_height"`
|
||||||
ThumbURL string `json:"thumb_url"`
|
ThumbURL string `json:"thumb_url"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Caption string `json:"caption"`
|
Caption string `json:"caption"`
|
||||||
MessageText string `json:"message_text"`
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
ParseMode string `json:"parse_mode"`
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
DisableWebPagePreview bool `json:"disable_web_page_preview"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InlineQueryResultVideo is an inline query response video.
|
// InlineQueryResultVideo is an inline query response video.
|
||||||
type InlineQueryResultVideo struct {
|
type InlineQueryResultVideo struct {
|
||||||
Type string `json:"type"` // required
|
Type string `json:"type"` // required
|
||||||
ID string `json:"id"` // required
|
ID string `json:"id"` // required
|
||||||
URL string `json:"video_url"` // required
|
URL string `json:"video_url"` // required
|
||||||
MimeType string `json:"mime_type"` // required
|
MimeType string `json:"mime_type"` // required
|
||||||
MessageText string `json:"message_text"` // required
|
ThumbURL string `json:"thumb_url"`
|
||||||
ParseMode string `json:"parse_mode"`
|
Title string `json:"title"`
|
||||||
DisableWebPagePreview bool `json:"disable_web_page_preview"`
|
Caption string `json:"caption"`
|
||||||
Width int `json:"video_width"`
|
Width int `json:"video_width"`
|
||||||
Height int `json:"video_height"`
|
Height int `json:"video_height"`
|
||||||
ThumbURL string `json:"thumb_url"`
|
Duration int `json:"video_duration"`
|
||||||
Title string `json:"title"`
|
Description string `json:"description"`
|
||||||
Description string `json:"description"`
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChosenInlineResult is an inline query result chosen by a User
|
// ChosenInlineResult is an inline query result chosen by a User
|
||||||
|
@ -427,3 +424,28 @@ type ChosenInlineResult struct {
|
||||||
From User `json:"from"`
|
From User `json:"from"`
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InputTextMessageContent struct {
|
||||||
|
Text string `json:"message_text"`
|
||||||
|
ParseMode string `json:"parse_mode"`
|
||||||
|
DisableWebPagePreview bool `json:"disable_web_page_preview"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type InputLocationMessageContent struct {
|
||||||
|
Latitude float64 `json:"latitude"`
|
||||||
|
Longitude float64 `json:"longitude"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type InputVenueMessageContent struct {
|
||||||
|
Latitude float64 `json:"latitude"`
|
||||||
|
Longitude float64 `json:"longitude"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Address string `json:"address"`
|
||||||
|
FoursquareID string `json:"foursquare_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type InputContactMessageContent struct {
|
||||||
|
PhoneNumber string `json:"phone_number"`
|
||||||
|
FirstName string `json:"first_name"`
|
||||||
|
LastName string `json:"last_name"`
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue