Streams and filters¶
Streams¶
Twitter has three stream APIs to listen to. ResponseBot currently implement the public stream and user stream listening methods. By default the bot listen to public stream, you can tell the bot to listen to user stream by setting it in the config file:
[stream]
user_stream=true
or pass in a flag in the start command:
$ start_responsebot --user-stream
Filters¶
The public stream utilize two parameters: track and follow, to filter global streams (you cannot listen
to every tweets in the world, you must have either 1 keyword to track or 1 user to follow). You provide these parameters
in your handlers’ get_filter method as follow:
def get_filter(self):
return TweetFilter(track=['keyword'], follow=['user_id'])
By default the BaseTweetHandler
returns a filter with the follow parameter set as the bot’s authenticated user and an empty track
parameter.
The follow parameter will not be used if you use user_stream. See more about
TweetFilter