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

Commit

Permalink
Merge pull request #31 from KeisukeToyota/feature/change-lang
Browse files Browse the repository at this point in the history
change lang
  • Loading branch information
ksk001100 authored Jan 30, 2019
2 parents 703b9ed + 9bc0ee8 commit bd72a1f
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion commands/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/urfave/cli"
)

// BlockCommand ブロックコマンド
// BlockCommand block command function
func BlockCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/favorite.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli"
)

// FavoriteCommand いいねコマンド
// FavoriteCommand favorite command function
func FavoriteCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/follow.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/urfave/cli"
)

// FollowCommand フォローコマンド
// FollowCommand follow command function
func FollowCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/mention.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/urfave/cli"
)

// MentionCommand メンションコマンド
// MentionCommand mention command function
func MentionCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/mute.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/urfave/cli"
)

// MuteCommand ミュートコマンド
// MuteCommand mute command function
func MuteCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/retweet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli"
)

// RetweetCommand リツイートコマンド
// RetweetCommand retweet command function
func RetweetCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/urfave/cli"
)

// SearchCommand 検索コマンド
// SearchCommand search command function
func SearchCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/urfave/cli"
)

// TimelineCommand タイムラインコマンド
// TimelineCommand timeline command function
func TimelineCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion commands/tweet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli"
)

// TweetCommand ツイートコマンド
// TweetCommand tweet command function
func TweetCommand(a *anaconda.TwitterApi, val url.Values) cli.Command {
api = a
v = val
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func loadEnv() {

err = godotenv.Load(user.HomeDir + "/.env.toyotter")
if err != nil {
modules.ErrorMessage(".env.toyotterが見つからないよ")
modules.ErrorMessage("Not found ~/.env.toyotter")
}
}

Expand Down
18 changes: 9 additions & 9 deletions modules/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/logrusorgru/aurora"
)

// GetFormatTweet ツイートの整形
// GetFormatTweet format tweet function
func GetFormatTweet(tweet anaconda.Tweet) string {
t, _ := tweet.CreatedAtTime()
return fmt.Sprintf(getFormatTweetTemplate(),
Expand All @@ -24,7 +24,7 @@ func GetFormatTweet(tweet anaconda.Tweet) string {
)
}

// GetFormatUser ユーザー情報整形
// GetFormatUser format user information function
func GetFormatUser(user anaconda.User) string {
return fmt.Sprintf(getFormatUserTemplate(),
aurora.Green(user.Name).String(), aurora.Green(user.ScreenName).String(),
Expand All @@ -34,12 +34,12 @@ func GetFormatUser(user anaconda.User) string {
)
}

// ErrorMessage エラーメッセージ
// ErrorMessage error message function
func ErrorMessage(text string) {
log.Fatal(aurora.Red(text))
}

// SeparatorString セパレーター文字列
// SeparatorString separator function
func SeparatorString() string {
width, _, _ := terminal.GetSize(0)
return strings.Repeat("-", width)
Expand All @@ -57,20 +57,20 @@ func getJapanDateTimeString(t time.Time) string {
func getFormatTweetTemplate() string {
return `
[%s]
[%s @%s | ユーザーID : %s]
[いいね数 : %s | リツイート数 : %s]
[%s @%s | UserID : %s]
[Favorite : %s | Retweet : %s]
%s
[ツイートID : %s]
[TweetID : %s]
%s`
}

func getFormatUserTemplate() string {
return `
[%s @%s | ユーザーID : %s]
[フォロー数 : %s | フォロワー数 : %s]
[%s @%s | UserID : %s]
[Followed : %s | Follower : %s]
%s
Expand Down
12 changes: 6 additions & 6 deletions twitter/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

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

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

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

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

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

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

// BlockUser ブロックユーザー一覧
// BlockUser block user list function
func BlockUser(api *anaconda.TwitterApi, v url.Values) {
userCursor, err := api.GetBlocksList(v)

if err != nil {
modules.ErrorMessage("ブロックユーザー一覧の取得に失敗したよ")
modules.ErrorMessage("Get block user list failed")
}

for _, user := range userCursor.Users {
Expand Down
8 changes: 4 additions & 4 deletions twitter/favorite.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

// Favorite いいね
// Favorite favorite function
func Favorite(api *anaconda.TwitterApi, tweetID int64) {
tweet, err := api.Favorite(tweetID)

if err != nil {
modules.ErrorMessage("いいねに失敗したよ")
modules.ErrorMessage("Favorite failed")
}

fmt.Println(modules.GetFormatTweet(tweet))
}

// UnFavorite いいね解除
// UnFavorite unfavorite function
func UnFavorite(api *anaconda.TwitterApi, tweetID int64) {
tweet, err := api.Unfavorite(tweetID)

if err != nil {
modules.ErrorMessage("いいね解除に失敗したよ")
modules.ErrorMessage("UnFavorite failed")
}

fmt.Println(modules.GetFormatTweet(tweet))
Expand Down
8 changes: 4 additions & 4 deletions twitter/follow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

// Follow フォロー
// Follow follow function
func Follow(api *anaconda.TwitterApi, screenName string) {
user, err := api.FollowUser(screenName)

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

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

// UnFollow フォロー解除
// UnFollow unfollow function
func UnFollow(api *anaconda.TwitterApi, screenName string) {
user, err := api.UnfollowUser(screenName)

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

fmt.Println(modules.GetFormatUser(user))
Expand Down
4 changes: 2 additions & 2 deletions twitter/mention.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

// Mention メンション
// Mention mention function
func Mention(api *anaconda.TwitterApi, v url.Values) {
tweets, err := api.GetMentionsTimeline(v)

if err != nil {
modules.ErrorMessage("メンション取得に失敗したよ")
modules.ErrorMessage("Get mentions failed")
}

for _, tweet := range tweets {
Expand Down
8 changes: 4 additions & 4 deletions twitter/mute.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

// Mute ミュート
// Mute mute function
func Mute(api *anaconda.TwitterApi, screenName string, v url.Values) {
user, err := api.MuteUser(screenName, v)

if err != nil {
modules.ErrorMessage("ミュートに失敗したよ")
modules.ErrorMessage("Mute failed")
}

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

// UnMute ミュート解除
// UnMute unmute function
func UnMute(api *anaconda.TwitterApi, screenName string, v url.Values) {
user, err := api.UnmuteUser(screenName, v)

if err != nil {
modules.ErrorMessage("ミュート解除に失敗したよ")
modules.ErrorMessage("UnMute failed")
}

fmt.Println(modules.GetFormatUser(user))
Expand Down
8 changes: 4 additions & 4 deletions twitter/retweet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

// Retweet リツイート
// Retweet retweet function
func Retweet(api *anaconda.TwitterApi, tweetID int64) {
tweet, err := api.Retweet(tweetID, false)

if err != nil {
modules.ErrorMessage("リツイートに失敗したよ")
modules.ErrorMessage("Retweet failed")
}

fmt.Println(modules.GetFormatTweet(tweet))
}

// UnRetweet リツイート解除
// UnRetweet unretweet function
func UnRetweet(api *anaconda.TwitterApi, tweetID int64) {
tweet, err := api.UnRetweet(tweetID, false)

if err != nil {
modules.ErrorMessage("リツイート解除に失敗したよ")
modules.ErrorMessage("UnRetweet failed")
}

fmt.Println(modules.GetFormatTweet(tweet))
Expand Down
8 changes: 4 additions & 4 deletions twitter/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

// SearchTweet ツイート検索
// SearchTweet search tweet function
func SearchTweet(api *anaconda.TwitterApi, text string, v url.Values) {
searchResult, err := api.GetSearch(text, v)

if err != nil {
modules.ErrorMessage("ツイート検索に失敗したよ")
modules.ErrorMessage("Search tweet failed")
}

for _, tweet := range searchResult.Statuses {
fmt.Println(modules.GetFormatTweet(tweet))
}
}

// SearchUser ユーザー検索
// SearchUser search user function
func SearchUser(api *anaconda.TwitterApi, text string, v url.Values) {
searchResult, err := api.GetUserSearch(text, v)

if err != nil {
modules.ErrorMessage("ツイート検索に失敗したよ")
modules.ErrorMessage("Search user failedf")
}

for _, user := range searchResult {
Expand Down
4 changes: 2 additions & 2 deletions twitter/timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/KeisukeToyota/toyotter2/modules"
)

// HomeTimeline タイムライン出力
// HomeTimeline hometimeline function
func HomeTimeline(api *anaconda.TwitterApi, v url.Values) {
tweets, err := api.GetHomeTimeline(v)

if err != nil {
modules.ErrorMessage("ツイート取得に失敗したよ")
modules.ErrorMessage("Get home timeline failed")
}

for _, tweet := range tweets {
Expand Down
Loading

0 comments on commit bd72a1f

Please sign in to comment.