Skip to content

Instantly share code, notes, and snippets.

@iamkat

iamkat/README.md Secret

Created September 20, 2014 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamkat/c06f772a9bab705656ec to your computer and use it in GitHub Desktop.
Save iamkat/c06f772a9bab705656ec to your computer and use it in GitHub Desktop.
Twitter scrape and count triggers signal

This flow searches Twitter for certain hashtags (in this case water and fail), pushes the Tweet to an output and counts the number of Tweets retrieved. After 5 Tweets, it triggers a signal and resets the counter. It's part of a project that will grow, which will interact with an RPi to control a valve to release water on an accumulation of Tweets.

[{"id":"188722c.7e1afdd","type":"function","name":"Process Tweet","func":"// is it possible to set this to a variable that is then\n// counted by the other function and then fed back in\n// iteratively??\n// initialise the counter to 0 if it doesn't exist already\ncontext.count = context.count || 0; \ncontext.count += 1;\n// make it part of the outgoing msg object\nmsg.count = context.count;\nif (msg.count >= 5) {\n msg.pour = true\n context.count = 0\n} else {\n msg.pour = false\n}\nreturn msg;","outputs":"1","x":294,"y":200,"z":"70a58b06.45bd64","wires":[["ad7f9f55.8be2f8"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment