Merge pull request #102 from mamal72/unban-chat-member-in-channels

Implement unban chat member for channels
bot-api-6.1
Syfaro 2017-06-19 00:03:20 -05:00 committed by GitHub
commit b57800c534
2 changed files with 7 additions and 4 deletions

10
bot.go
View File

@ -674,14 +674,16 @@ func (bot *BotAPI) GetChatMember(config ChatConfigWithUser) (ChatMember, error)
} }
// UnbanChatMember unbans a user from a chat. Note that this only will work // UnbanChatMember unbans a user from a chat. Note that this only will work
// in supergroups, and requires the bot to be an admin. // in supergroups and channels, and requires the bot to be an admin.
func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error) { func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error) {
v := url.Values{} v := url.Values{}
if config.SuperGroupUsername == "" { if config.SuperGroupUsername != "" {
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
} else {
v.Add("chat_id", config.SuperGroupUsername) v.Add("chat_id", config.SuperGroupUsername)
} else if config.ChannelUsername != "" {
v.Add("chat_id", config.ChannelUsername)
} else {
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
} }
v.Add("user_id", strconv.Itoa(config.UserID)) v.Add("user_id", strconv.Itoa(config.UserID))

View File

@ -883,6 +883,7 @@ type CallbackConfig struct {
type ChatMemberConfig struct { type ChatMemberConfig struct {
ChatID int64 ChatID int64
SuperGroupUsername string SuperGroupUsername string
ChannelUsername string
UserID int UserID int
} }