From e0a2dfbbb0d53e816ea39220182a5ba6be5d7a54 Mon Sep 17 00:00:00 2001 From: Ben Bertka Date: Tue, 24 Mar 2015 11:00:49 -0700 Subject: [PATCH 1/2] Added dynamic filtering --- twython/streaming/types.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/twython/streaming/types.py b/twython/streaming/types.py index 39a9ccb..c69baa9 100644 --- a/twython/streaming/types.py +++ b/twython/streaming/types.py @@ -51,6 +51,7 @@ class TwythonStreamerTypesStatuses(object): """ def __init__(self, streamer): self.streamer = streamer + self.params = None def filter(self, **params): """Stream statuses/filter @@ -87,3 +88,20 @@ class TwythonStreamerTypesStatuses(object): url = 'https://stream.twitter.com/%s/statuses/firehose.json' \ % self.streamer.api_version self.streamer._request(url, params=params) + + def set_dynamic_filter(self, **params): + """Set/update statuses/filter + + :param \*\*params: Parameters to send with your stream request + + Accepted params found at: + https://dev.twitter.com/docs/api/1.1/post/statuses/filter + """ + self.params = params + + def dynamic_filter(self): + """Stream statuses/filter with dynamic parameters""" + + url = 'https://stream.twitter.com/%s/statuses/filter.json' \ + % self.streamer.api_version + self.streamer._request(url, 'POST', params=self.params) From 6d1c82b594256992cabff4bbc671c54b92d8ca4e Mon Sep 17 00:00:00 2001 From: Ben Bertka Date: Tue, 24 Mar 2015 11:36:08 -0700 Subject: [PATCH 2/2] Fixed indents for dynamic filtering in types.py --- twython/streaming/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/twython/streaming/types.py b/twython/streaming/types.py index c69baa9..aa6b9ad 100644 --- a/twython/streaming/types.py +++ b/twython/streaming/types.py @@ -51,7 +51,7 @@ class TwythonStreamerTypesStatuses(object): """ def __init__(self, streamer): self.streamer = streamer - self.params = None + self.params = None def filter(self, **params): """Stream statuses/filter @@ -97,7 +97,7 @@ class TwythonStreamerTypesStatuses(object): Accepted params found at: https://dev.twitter.com/docs/api/1.1/post/statuses/filter """ - self.params = params + self.params = params def dynamic_filter(self): """Stream statuses/filter with dynamic parameters"""