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

Commit

Permalink
Merge pull request #21 from KeisukeToyota/feature/fav-rt-count
Browse files Browse the repository at this point in the history
いいね数・リツイート数表示
  • Loading branch information
ksk001100 committed Jan 16, 2019
2 parents 3787402 + ba5ec84 commit c8e8328
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions modules/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package modules
import (
"fmt"
"log"
"time"

"github.com/ChimeraCoder/anaconda"
"github.com/logrusorgru/aurora"
Expand All @@ -20,20 +21,28 @@ func ContainsString(s []string, e string) bool {

// GetFormatTweet ツイートの整形
func GetFormatTweet(tweet anaconda.Tweet) string {
return fmt.Sprintf("\n[%s] (@%s) %s\n%s [Tweet ID : %s]",
aurora.Brown(tweet.CreatedAt).String(),
aurora.Magenta(tweet.User.ScreenName).String(),
aurora.Green(tweet.User.Name).String(),
aurora.Bold(tweet.FullText).String(),
aurora.Red(tweet.IdStr).String())
t, _ := tweet.CreatedAtTime()
japanTime, _ := time.LoadLocation("Asia/Tokyo")
createdAt := t.In(japanTime)
datetime := fmt.Sprintf("%d/%02d/%02d %02d:%02d:%02d",
createdAt.Year(), createdAt.Month(), createdAt.Day(),
createdAt.Hour(), createdAt.Minute(), createdAt.Second(),
)
return fmt.Sprintf("\n[%s] [アカウント名 : @%s | 名前 : %s | ユーザーID : %s]\n[いいね数 : %s | リツイート数 : %s]\n%s [ツイートID : %s]\n",
aurora.Brown(datetime).String(), aurora.Magenta(tweet.User.ScreenName).String(),
aurora.Green(tweet.User.Name).String(), aurora.Red(tweet.User.IdStr),
aurora.Cyan(tweet.FavoriteCount).String(), aurora.Cyan(tweet.RetweetCount).String(),
aurora.Bold(tweet.FullText).String(), aurora.Red(tweet.IdStr).String(),
)
}

// GetFormatUser ユーザー情報整形
func GetFormatUser(user anaconda.User) string {
return fmt.Sprintf("\n(@%s) %s [User ID : %s]",
return fmt.Sprintf("\n(@%s) %s [ユーザーID : %s]",
aurora.Magenta(user.ScreenName).String(),
aurora.Green(user.Name).String(),
aurora.Red(user.IdStr).String())
aurora.Red(user.IdStr).String(),
)
}

// ErrorMessage エラーメッセージ
Expand Down

0 comments on commit c8e8328

Please sign in to comment.