-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Twitter List agent #2229
base: master
Are you sure you want to change the base?
Add Twitter List agent #2229
Conversation
I just realised I omitted tests for this agent. If this contribution is otherwise acceptable, let me know and I’ll work up some unit tests to add to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realised I omitted tests for this agent. If this contribution is otherwise acceptable, let me know and I’ll work up some unit tests to add to this PR.
Yes, please add some specs. The Agent looks useful to me and simple enough to have it in Huginn itself.
An ideal implementation might instead fetch a list of users in the specified list (and refresh that list periodically), and then monitor a filtered stream containing only the tweets of those users with Twitter’s streaming API, using the same mechanism as Twitter Stream Agent. This would have the benefit of generating events in real time; however, I did not have the time necessary to invest in this more complex implementation.
Interesting idea, the only problem could be lists with a lot of members as the Stream API has some limitations on how many keywords/users can be tracked.
end | ||
|
||
def starting_at | ||
if interpolated[:starting_at].present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be
def starting_at
return created_at unless interpolated[:starting_at].present?
Time.parse(interpolated[:starting_at]) rescue created_at
end
|
||
def check | ||
since_id = memory['since_id'] || nil | ||
opts = {:count => 200, :include_rts => include_retweets?, :include_entities => true, tweet_mode: 'extended'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the "new" ruby Hash syntax like count: 200
.
def check | ||
since_id = memory['since_id'] || nil | ||
opts = {:count => 200, :include_rts => include_retweets?, :include_entities => true, tweet_mode: 'extended'} | ||
opts.merge! :since_id => since_id unless since_id.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
end | ||
|
||
tweets.each do |tweet| | ||
if tweet.created_at >= starting_at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could avoid the nesting by bailing out of the loop early:
next if tweet.created_at < starting_at
I don't know anything about how to build tests for these things, but this is a feature I'd love to use. @sentience is there any chance I can convince you to brush off the dust on this one? Or publish it has a third party module? |
@zoomequipd I'm afraid I have one too many things to do already to get around to adding the missing specs here in the very near future. You're welcome to grab the file from this pull request and drop it into your installation to add it if you want to use it for now. |
I also have some interest in this feature. Thought I would add my name to the hat. |
@zoomequipd @romans8 and anyone else who wants this feature: I've published my Twitter List Agent as a gem here: https://github.com/sentience/huginn_twitter_list_agent You can add this to your Huginn instance using the
Enjoy! |
The Twitter List Agent receives tweets from the users that belong to a Twitter list. I use this to receive push notifications from a subset of the users that I follow – my “I want to hear about it near-instantly when these users post something” list.
This uses the lists/statuses method of the Twitter API to fetch periodically a list of tweets with the specified criteria.
An ideal implementation might instead fetch a list of users in the specified list (and refresh that list periodically), and then monitor a filtered stream containing only the tweets of those users with Twitter’s streaming API, using the same mechanism as Twitter Stream Agent. This would have the benefit of generating events in real time; however, I did not have the time necessary to invest in this more complex implementation.