Skip to content

Commit

Permalink
Account.banUser
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorkytaka committed Apr 24, 2017
1 parent 7dadf3f commit f58f7f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ if err != nil {

#### List of finished methods:
* [Account](https://vk.com/dev/account)
* [BanUser](https://vk.com/dev/account.banUser)
* [GetAppPermissions](https://vk.com/dev/account.getAppPermissions)
* [GetBanned](https://vk.com/dev/account.getBanned)
* [GetCounters](https://vk.com/dev/account.getCounters)
Expand Down
22 changes: 19 additions & 3 deletions easyvk/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
notifyBit = 1 << iota
notifyBit = 1 << iota
friendsBit
photosBit
audioBit
Expand Down Expand Up @@ -129,7 +129,7 @@ func (a *Account) GetAppPermissions(userID uint) (Permissions, error) {
func (a *Account) GetBanned(offset, count uint) (Blacklist, error) {
params := map[string]string{
"offset": fmt.Sprint(offset),
"count": fmt.Sprint(count),
"count": fmt.Sprint(count),
}
resp, err := a.vk.Request("account.getBanned", params)
if err != nil {
Expand All @@ -141,4 +141,20 @@ func (a *Account) GetBanned(offset, count uint) (Blacklist, error) {
return Blacklist{}, err
}
return list, nil
}
}

// BanUser adds user to the banlist.
func (a *Account) BanUser(userID uint) (bool, error) {
params := map[string]string{
"user_id": fmt.Sprint(userID),
}
resp, err := a.vk.Request("account.banUser", params)
if err != nil {
return false, err
}
ok, err := strconv.ParseUint(string(resp), 10, 8)
if err != nil {
return false, err
}
return ok == 1, nil
}

0 comments on commit f58f7f9

Please sign in to comment.