Skip to content
This repository was archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
ブロック・ブロック解除機能の追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ksk001100 committed Jan 9, 2019
1 parent 8891cff commit 3ba26e6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,26 @@ func main() {
return nil
},
},
{
Name: "block",
Aliases: []string{"blk"},
Usage: "toyotter2 block [screenName]",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "delete, d",
Usage: "toyotter2 block [screenName] --delete",
},
},
Action: func(c *cli.Context) error {
screenName := c.Args().First()
if c.Bool("delete") {
twitter.UnBlock(api, screenName, v)
} else {
twitter.Block(api, screenName, v)
}
return nil
},
},
// {
// Name: "dm",
// Usage: "toyotter2 dm [screenName] [text]",
Expand Down
31 changes: 31 additions & 0 deletions twitter/block.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package twitter

import (
"fmt"
"net/url"

"github.com/ChimeraCoder/anaconda"
"github.com/KeisukeToyota/toyotter2/modules"
)

// Block ブロック
func Block(api *anaconda.TwitterApi, screenName string, v url.Values) {
user, err := api.BlockUser(screenName, v)

if err != nil {
modules.ErrorMessage("ブロックに失敗したよ")
}

fmt.Println(modules.GetFormatUser(user))
}

// UnBlock ブロック解除
func UnBlock(api *anaconda.TwitterApi, screenName string, v url.Values) {
user, err := api.UnblockUser(screenName, v)

if err != nil {
modules.ErrorMessage("ブロック解除に失敗したよ")
}

fmt.Println(modules.GetFormatUser(user))
}
2 changes: 1 addition & 1 deletion twitter/follow.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func UnFollow(api *anaconda.TwitterApi, screenName string) {
user, err := api.UnfollowUser(screenName)

if err != nil {
modules.ErrorMessage("フォローに失敗したよ")
modules.ErrorMessage("フォロー解除に失敗したよ")
}

fmt.Println(modules.GetFormatUser(user))
Expand Down

0 comments on commit 3ba26e6

Please sign in to comment.