Skip to content

Commit ed72067

Browse files
committed
update showUser method
1 parent 701a673 commit ed72067

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

cmd/list/users.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,20 @@ func UsersCmd(config lib.Config) *cobra.Command {
4141
}
4242

4343
for _, user := range members.Users {
44-
displayConsole.ShowUser(user.Name, user.ScreenName, user.URL, user.FriendsCount, user.FollowersCount)
44+
userTimelineParams := &twitter.UserTimelineParams{
45+
UserID: user.ID,
46+
}
47+
tweets, res, err := client.Timelines.UserTimeline(userTimelineParams)
48+
49+
if err != nil {
50+
return fmt.Errorf("cannot get user-timeline: %v: %v", err, res.Status)
51+
}
52+
53+
if len(tweets) > 0 {
54+
displayConsole.ShowUser(user.Name, user.ScreenName, user.URL, user.FriendsCount, user.FollowersCount, tweets[0].CreatedAt)
55+
} else {
56+
displayConsole.ShowUser(user.Name, user.ScreenName, user.URL, user.FriendsCount, user.FollowersCount, "none")
57+
}
4558
}
4659
cursor = members.NextCursor
4760
}

lib/display_console.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,16 @@ func (d *DisplayConsole) ShowList(title string, url string, id int64) {
101101
}
102102

103103
// ShowUser is display user
104-
func (d *DisplayConsole) ShowUser(name string, screenName string, url string, friendsCount int, followersCount int) {
104+
func (d *DisplayConsole) ShowUser(name string, screenName string, url string, friendsCount int, followersCount int, lastUpdatedAt string) {
105105
fmt.Fprintf(
106106
color.Output,
107-
"%s\t%s\t%s\t%s\t%s\n",
107+
"%s\t%s\t%s\t%s\t%s\t%s\n",
108108
d.URL("https://twitter.com/"+screenName),
109109
d.Name(name),
110110
d.Name("@"+screenName),
111111
strconv.Itoa(friendsCount),
112112
strconv.Itoa(followersCount),
113+
lastUpdatedAt,
113114
)
114115
}
115116

0 commit comments

Comments
 (0)