-
-
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
Twitter retweet agent #1181
Twitter retweet agent #1181
Conversation
@@ -36,7 +36,7 @@ def twitter_oauth_token_secret | |||
end | |||
|
|||
def twitter | |||
Twitter::REST::Client.new do |config| | |||
@twitter ||= Twitter::REST::Client.new do |config| |
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 wanted to mock a method on twitter
in my spec and generating a new one every time was not allowing that. I could use any_instance_of(Twitter::REST::Client)
but I didn't see a reason not to cache this.
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 think this should be fine-- we'd be making a new one for any instance of a new Agent anyway.
Thanks @jackvnimble! :) |
'success' => false, | ||
'error' => e.message, | ||
'tweets' => Hash[tweets_to_retweet.map { |t| [t.id, t.text] }], | ||
'agent_id' => incoming_events.first.agent_id, |
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.
Maybe do agent_ids instead, or make an event per event?
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.
Yep, and event_ids. This should be fixed now.
Let me know when this is ready. No rush! |
Just an idea, but what about merging TwitterPublishAgent and this into TwitterActionAgent? There are some other possible actions like follow and like, and adding one agent for each action may look messy. |
@knu That's a good suggestion and I actually mentioned this to @cantino and we decided that separate agents would be ok (at least for now). I can see what you mean about having one action for each being messy, but I think trying to have one agent responsible for publishing tweets, following, favoriting and retweeting may be a bit hard to use for someone just trying to use Huginn (and not understand the code underneath). To me, |
OK, it makes much sense in that it would be user-friendlier to have separate agents. I agree actions like follow/like/mute/unfollow should be separated from publishing actions. I thought about the idea of merging with TwitterPublishAgent because I had the "retweet with comment" feature in mind, but it seems to be just a tweet with a reference to another tweet, so TwitterPublishAgent will be able to do that without modification. |
Let us know when this is ready. As always, no rush-- it's just hard to tell when people consider a PR to be finished. Happy holidays! |
@cantino Just speaking to retweet, I think this is good to go. However, I'd like to incorporate If that assumption is correct, maybe it's best to wait until I can add the other actions, or go ahead and change the name and then add the actions in another PR. What do you think? Happy Holidays!! |
Agreed, let's rename before we merge it in. |
HI @cantino / @jackvnimble: any idea when this one will be merged with master ? |
@jackvnimble, other than our conversation about separating Agents, was this ready? |
@cantino and all, sorry for the delay on this. I actually have a branch that does the rename and adds a favoriting option. Just need to touch it up and push it up. Should be able to do that tomorrow morning.
|
142d16f
to
1698809
Compare
@cantino this should be ready (pending a code review and passing build). I've added the ability to favorite tweets and renamed to |
63885cc
to
756b1d4
Compare
end | ||
end | ||
|
||
def build_agent(options) |
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 should be scoped inside of the top describe
so as to not be global.
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.
Oof, good catch! Fixed.
Looks great! Just one minor comment. Thanks @jackvnimble :) |
This restructures the Agent slightly to allow for retweeting and favoriting. It is possible to do both at the same time. - Renames the Agent from TwitterRetweetAgent to TwitterActionAgent. - Specs refactored
756b1d4
to
0bf692d
Compare
Great addition, thanks @jackvnimble! |
@cantino Thought I'd take a crack at this one.
This agent is meant to only consume events (tweet events at that). Whats the convention of generating success/failure events? I saw they were used in the publish agent. Have a couple questions that I'll add as comments in the code.
Still learning my way around and happy to make any necessary changes, or add obvious functionality that I may have overlooked. I did run this successfully locally.