add retweet and fav count

This commit is contained in:
gutmet 2020-10-21 09:03:22 +02:00
parent 50440290b8
commit f40cc15af7
1 changed files with 11 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"fmt"
"html"
"strings"
"time"
@ -50,6 +51,10 @@ type Status struct {
Quoted_status *Status
Retweeted_status *Status
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 {
@ -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 {
if t.Retweeted_status != nil {
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 != "" {
s += " in reply to " + replyTo
}
s += ":\n" + html.UnescapeString(t.Full_text)
s += ":\n" + t.Text()
allMedia := t.Extended_entities.Media
if len(allMedia) > 0 {
s += "\n\nMedia:"