peony-twitter icon indicating copy to clipboard operation
peony-twitter copied to clipboard

How would I do stuff if a specific user tweeted?

Open ShadiestGoat opened this issue 4 years ago • 7 comments

Heya! Its just as the title says.. I saw stuff like track.py in the examples, but I can't find more documention on the filter() and how to use that for users ://

ShadiestGoat avatar Aug 31 '20 18:08 ShadiestGoat

Hello there! To do that you have to take a look at Twitter's API documentation. Peony was designed to be able to use any endpoint without needing to create specific methods for each of them. In this case I'm using this API endpoint: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/api-reference/post-statuses-filter It has a follow parameter that takes a list of user ids, you should be able to use the same parameter in peony:

stream = client.stream.statuses.filter.post(follow=user_id)

odrling avatar Aug 31 '20 18:08 odrling

Heya thanks for responding! Thats really cool, ill give it a try :D

ShadiestGoat avatar Sep 01 '20 00:09 ShadiestGoat

Heya! Sorry for the slow response. This does work, obviusly, but is kinda slow. In my bot, it takes the majority of the time (~6 seconds), just to get the tweet. Is there a way to make it faster, or is this the max possible?

ShadiestGoat avatar Sep 08 '20 00:09 ShadiestGoat

I'm not using this library as much as I did before, I would assume that the 6 seconds are just latency introduced by Twitter somehow. Internally it's reading the responses from a stream and I remember it being pretty straightforward so I would find it weird if this latency would come from this lib. If this is 6 seconds after the tweet is sent that sounds fine to me, if this is 6 seconds after your regular twitter client would get it that would be weird.

odrling avatar Sep 09 '20 05:09 odrling

yeah 6 seconds is really not much and its really weird that twitter introduced this ;-; I don't think the lib does it either, lemme google further

ShadiestGoat avatar Sep 09 '20 07:09 ShadiestGoat

I only remember reading about that in this article http://highscalability.com/blog/2013/7/8/the-architecture-twitter-uses-to-deal-with-150m-active-users.html. This is old but I think this is still what Twitter has to deal with today. They have to deliver a lot of tweets all the time to many more users so it takes some time.

EDIT: I hit Ctrl+Enter too quickly :/

odrling avatar Sep 09 '20 18:09 odrling

Dam aa. Yeah, I'm guessing its because of that, and since my twitter dev account is relatively new, I think it may have lower priority..

ShadiestGoat avatar Sep 09 '20 22:09 ShadiestGoat