-
Notifications
You must be signed in to change notification settings - Fork 17
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 commands #6
Conversation
@@ -0,0 +1,6 @@ | |||
module.exports = { |
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.
Obviously to get this to work you need to add your twitter api details here, and remove the .EXAMPLE
from this file. If there's a better way of doing this without creating this stuff just let me know and I'll change it :-)
bb8.randomColor(); | ||
setInterval(function () { | ||
bb8.randomColor(); | ||
}, 1000); |
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 feels a bit more betterer ;)
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.
👍
require(command)(bb8) | ||
}); | ||
} | ||
}; |
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 block from line 3-11 could probably be extracted into its own lib...
@@ -0,0 +1,6 @@ | |||
module.exports = { | |||
consumer_key: '', | |||
consumer_secret: '', |
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.
- do you need the consumer key and secret? back in the day you could get away with just the access_token_key and access_token_secret similar to what I wrote in the Github wrapper in libs?
- Might be good to do it like that to be consistent. I made it so it reads either a config passed in through the CLI or a ENV variable (
process.env.NAME_OF_VAR
)
@citypaul Few minor things but looks good otherwise 👍 Add yourself to the README as well ;) |
|
||
setInterval(function () { | ||
executeTwitterCommand(); | ||
}, 10000); |
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'll make this delay param configurable too...
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.
👍
… hashtag to search for + change interval delay
Ok, updated a few things this morning:
I tried querying twitter without the consumer key and consumer secret, but it didn't work, so for now I've left this in. If there is a way of removing these, please go ahead and remove them 👍 |
@citypaul I've done some tweaks to your code. It's working nicely now. Swapped some code for some lodash. |
@mintuz Nice! I hadn't thought about the fact the robot would keep getting the same command issued... One of the perils of not having an actual robot (and not writing tests I guess 😉). Looks good though. I need to read up on the lodash stuff. That |
|
Anyways going to merge. Good work 👍 now go buy one 😄 |
So I made a few changes here to make the twitter stuff a bit nicer.
I should say I'm doing this blind without a robot and without... tests! Shock horror! So I can't confirm it works unless you try it out for me.
I refactored some of the commands so they no longer create the bb8 instance. I figured they are just commands and should do nothing more than take an instance of bb8 that is already created and run commands against him. This meant I could then pass commands from twitter quite easily. I had a go at refactoring the index script accordingly.
There's a
config
folder with a place for you to store your twitter api details. I couldn't see a way of using twitter's api without these details. If there is a way please alter the code or let me know and I'll do it...The twitter command is pretty basic at the moment - it polls twitter every 10 seconds searching for the hashtag #bb8bbc, and then looks for the first hashtag it finds in that tweet. It then simply issues that as the command.
It doesn't check to see whether the command exists or deal with more than one command etc right now, but it's a start.
So to make BB8 roll you'd do:
#roll #bb8bbc
I think extracting the commands as functions that simply receive a bb8 instance is a nice improvement - removes duplication and means you could start combining the commands together in theory.
Dunno if it works though! Try it out :)