Skip to content
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 home timeline option to twitter user agent #1321

Merged

Conversation

Jngai
Copy link
Contributor

@Jngai Jngai commented Feb 25, 2016

Fixes #1249.

@@ -5,13 +5,19 @@ class TwitterUserAgent < Agent
cannot_receive_events!

description <<-MD
The Twitter User Agent follows the timeline of a specified Twitter user.
There are two options in using the Twitter User Agent.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line of the description is shown in the new agent dropdown. It would be nice if you could condense the second and third line into a short description explaining both options the agent has.

@dsander
Copy link
Collaborator

dsander commented Feb 25, 2016

Very nice addition @Jngai!

@Jngai
Copy link
Contributor Author

Jngai commented Feb 25, 2016

@dsander Will you take a look please?

@Jngai
Copy link
Contributor Author

Jngai commented Feb 26, 2016

@dsander I fixed my error and the test passed but I still need a quick look.

errors.add(:base, "expected_update_period_in_days is required") unless options['expected_update_period_in_days'].present?

errors.add(:base, "username is required") unless options['choose_home_time_line'] == 'true'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause the validation to fail even if a username is provided, i think you want

errors.add(:base, "username is required") if options['username'].blank? && !boolify(options['choose_home_time_line'])

@Jngai
Copy link
Contributor Author

Jngai commented Feb 26, 2016

@dsander I put in another commit to fix the rest of your suggestions. thank you.

@dsander
Copy link
Collaborator

dsander commented Feb 26, 2016

@Jngai Nice! I like it 😄

@cantino Would you mind giving it a quick look?

@Jngai
Copy link
Contributor Author

Jngai commented Feb 26, 2016

@dsander @cantino Thanks!

@@ -82,6 +84,10 @@ def starting_at
end
end

def choose_home_time_line?
interpolated[:choose_home_time_line] == "true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use boolify here too

boolify(interpolated['choose_home_time_line'])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line change actually sent the agent malfunctioning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did using boolify(interpolated['choose_home_time_line']) break?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry it was actually me I set it to equal == true. I just made a commit for this. I just tested it locally and everything is working.

else
tweets = twitter.user_timeline(interpolated['username'], opts)

tweets.each do |tweet|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this loop the same as the one above? If it is, maybe something like this would work?

if choose_home_time_line?
  tweets = twitter.home_timeline(opts)
else
  tweets = twitter.user_timeline(interpolated['username'], opts)
end

tweets.each do |tweet|
  ...

@Jngai
Copy link
Contributor Author

Jngai commented Feb 29, 2016

@cantino Hi I am done with the changes and the spec passed. The boolify change actually sent the agent malfunctioning. I just tested this locally and verified it. The agent worked now that I reverted that line change.

@Jngai
Copy link
Contributor Author

Jngai commented Mar 1, 2016

@cantino I added that boolify line change. I accidentally set it to true.

cantino added a commit that referenced this pull request Mar 2, 2016
…er_user_agent

Add home timeline option to twitter user agent
@cantino cantino merged commit 8bef0f4 into huginn:master Mar 2, 2016
@cantino
Copy link
Member

cantino commented Mar 2, 2016

Looks great, thanks @Jngai!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants