add retweet and fav count
This commit is contained in:
parent
50440290b8
commit
f40cc15af7
13
types.go
13
types.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -50,6 +51,10 @@ type Status struct {
|
||||||
Quoted_status *Status
|
Quoted_status *Status
|
||||||
Retweeted_status *Status
|
Retweeted_status *Status
|
||||||
Extended_entities Entities
|
Extended_entities Entities
|
||||||
|
//only available in premium API Quote_count int64
|
||||||
|
//only available in premium API Reply_count int64
|
||||||
|
Retweet_count int64
|
||||||
|
Favorite_count int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Status) Error() string {
|
func (t Status) Error() string {
|
||||||
|
@ -85,15 +90,19 @@ func (t Status) InReplyTo() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t Status) Text() string {
|
||||||
|
return html.UnescapeString(t.Full_text)
|
||||||
|
}
|
||||||
|
|
||||||
func (t Status) String() string {
|
func (t Status) String() string {
|
||||||
if t.Retweeted_status != nil {
|
if t.Retweeted_status != nil {
|
||||||
return t.User.Screen_name + " retweeted " + t.Retweeted_status.String()
|
return t.User.Screen_name + " retweeted " + t.Retweeted_status.String()
|
||||||
}
|
}
|
||||||
s := t.User.Screen_name + " " + "(" + t.Id_str + ")"
|
s := t.User.Screen_name + " " + "(" + t.Id_str + ")" + fmt.Sprintf(" (rt:%d,fav:%d)", t.Retweet_count, t.Favorite_count)
|
||||||
if replyTo := t.InReplyTo(); replyTo != "" {
|
if replyTo := t.InReplyTo(); replyTo != "" {
|
||||||
s += " in reply to " + replyTo
|
s += " in reply to " + replyTo
|
||||||
}
|
}
|
||||||
s += ":\n" + html.UnescapeString(t.Full_text)
|
s += ":\n" + t.Text()
|
||||||
allMedia := t.Extended_entities.Media
|
allMedia := t.Extended_entities.Media
|
||||||
if len(allMedia) > 0 {
|
if len(allMedia) > 0 {
|
||||||
s += "\n\nMedia:"
|
s += "\n\nMedia:"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user