Skip to content

Commit 56ad7ce

Browse files
committed
twitter: Fix missing user info
1 parent e98f20a commit 56ad7ce

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

plugin/twitter/api.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,17 @@ type (
165165
RestId string `json:"rest_id"`
166166
AffiliatesHighlightedLabel struct {
167167
} `json:"affiliates_highlighted_label"`
168-
HasNftAvatar bool `json:"has_nft_avatar"`
169-
Legacy struct {
170-
CreatedAt string `json:"created_at"`
168+
Avatar struct {
169+
ImageUrl string `json:"image_url"`
170+
} `json:"avatar"`
171+
Core struct {
172+
CreatedAt string `json:"created_at"`
173+
Name string `json:"name"`
174+
ScreenName string `json:"screen_name"`
175+
} `json:"core"`
176+
HasNftAvatar bool `json:"has_nft_avatar"`
177+
IsBlueVerified bool `json:"is_blue_verified"`
178+
Legacy struct {
171179
DefaultProfile bool `json:"default_profile"`
172180
DefaultProfileImage bool `json:"default_profile_image"`
173181
Description string `json:"description"`
@@ -196,24 +204,25 @@ type (
196204
HasCustomTimelines bool `json:"has_custom_timelines"`
197205
IsTranslator bool `json:"is_translator"`
198206
ListedCount int `json:"listed_count"`
199-
Location string `json:"location"`
200207
MediaCount int `json:"media_count"`
201-
Name string `json:"name"`
202208
NormalFollowersCount int `json:"normal_followers_count"`
203209
PinnedTweetIdsStr []string `json:"pinned_tweet_ids_str"`
204210
PossiblySensitive bool `json:"possibly_sensitive"`
205211
ProfileBannerUrl string `json:"profile_banner_url"`
206-
ProfileImageUrlHttps string `json:"profile_image_url_https"`
207212
ProfileInterstitialType string `json:"profile_interstitial_type"`
208213
Protected bool `json:"protected"`
209-
ScreenName string `json:"screen_name"`
210214
StatusesCount int `json:"statuses_count"`
211215
TranslatorType string `json:"translator_type"`
212216
Url string `json:"url"`
213-
Verified bool `json:"verified"`
214217
VerifiedType string `json:"verified_type"`
215218
WithheldInCountries []interface{} `json:"withheld_in_countries"`
216219
} `json:"legacy"`
220+
Location struct {
221+
Location string `json:"location"`
222+
} `json:"location"`
223+
Verification struct {
224+
Verified bool `json:"verified"`
225+
} `json:"verification"`
217226
} `json:"result"`
218227
}
219228

@@ -345,9 +354,9 @@ func (u *UserResult) Author() string {
345354
sb.WriteString(
346355
fmt.Sprintf(
347356
"<b>%s</b> (<a href=\"https://x.com/%s\">@%s</a>",
348-
utils.Escape(u.Result.Legacy.Name),
349-
u.Result.Legacy.ScreenName,
350-
u.Result.Legacy.ScreenName,
357+
utils.Escape(u.Result.Core.Name),
358+
u.Result.Core.ScreenName,
359+
u.Result.Core.ScreenName,
351360
),
352361
)
353362

plugin/twitter/twitter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (p *Plugin) OnStatus(b *gotgbot.Bot, c plugin.GobotContext) error {
241241
if len(tweet) > MaxNoteLength {
242242
tweet = fmt.Sprintf("%s...\n<a href=\"https://x.com/%s/status/%s\">Weiterlesen...</a>",
243243
utils.Escape(tweet[:MaxNoteLength]),
244-
result.Core.UserResults.Result.Legacy.ScreenName,
244+
result.Core.UserResults.Result.Core.ScreenName,
245245
result.RestId,
246246
)
247247
}
@@ -347,7 +347,7 @@ func (p *Plugin) OnStatus(b *gotgbot.Bot, c plugin.GobotContext) error {
347347
if len(tweet) > MaxNoteLength {
348348
tweet = fmt.Sprintf("%s...\n<a href=\"https://x.com/%s/status/%s\">Zitat weiterlesen...</a>",
349349
utils.Escape(tweet[:MaxNoteLength]),
350-
quoteResultSub.Core.UserResults.Result.Legacy.ScreenName,
350+
quoteResultSub.Core.UserResults.Result.Core.ScreenName,
351351
quoteResultSub.RestId,
352352
)
353353
}

0 commit comments

Comments
 (0)