# Path: responsebot/listeners/tweepy_wrapper_listener.py
# class TweepyWrapperListener(StreamListener):
#     def __init__(self, listener, *args, **kwargs):
#         super(TweepyWrapperListener, self).__init__(*args, **kwargs)
# 
#         self.listener = listener
# 
#     def on_status(self, status):
#         self.listener.on_tweet(Tweet(status._json))
# 
#     def on_event(self, event):
#         self.listener.on_event(Event(event._json))


import logging
import tweepy
from tweepy.error import TweepError
from responsebot.listeners.tweepy_wrapper_listener import TweepyWrapperListener
from __future__ import absolute_import





class ResponseBotStream(object):
    """
    Connect to Twitter's streaming API and handle any error that occurs.
    """
    def __init__(self, client, listener):
        """
        :param client: Some Twitter API client for authentication. E.g. :class:`~responsebot.tweet_client.TweetClient`
        :param listener: A central listener that will receive tweets from the stream and forward them to user's
        handlers. E.g. :class:`~responsebot.listeners.responsebot_listener.ResponseBotListener`
        """
        self.client = client
        self.listener = listener
        self.filter = listener.get_merged_filter()

    def start(self, retry_limit=None):
        """
        Try to connect to Twitter's streaming API.

        :param retry_limit: The maximum number of retries in case of failures. Default is None (unlimited)
        :raises :class:`~tweepy.error.TweepyError`: If there's some critical API error
        """
        # Run tweepy stream

# Path: responsebot/listeners/tweepy_wrapper_listener.py
# class TweepyWrapperListener(StreamListener):
#     def __init__(self, listener, *args, **kwargs):
#         super(TweepyWrapperListener, self).__init__(*args, **kwargs)
# 
#         self.listener = listener
# 
#     def on_status(self, status):
#         self.listener.on_tweet(Tweet(status._json))
# 
#     def on_event(self, event):
#         self.listener.on_event(Event(event._json))


# Path: responsebot/responsebot_stream.py
import logging
import tweepy
from tweepy.error import TweepError
from responsebot.listeners.tweepy_wrapper_listener import TweepyWrapperListener

from __future__ import absolute_import





class ResponseBotStream(object):
    """
    Connect to Twitter's streaming API and handle any error that occurs.
    """
    def __init__(self, client, listener):
        """
        :param client: Some Twitter API client for authentication. E.g. :class:`~responsebot.tweet_client.TweetClient`
        :param listener: A central listener that will receive tweets from the stream and forward them to user's
        handlers. E.g. :class:`~responsebot.listeners.responsebot_listener.ResponseBotListener`
        """
        self.client = client
        self.listener = listener
        self.filter = listener.get_merged_filter()

    def start(self, retry_limit=None):
        """
        Try to connect to Twitter's streaming API.

        :param retry_limit: The maximum number of retries in case of failures. Default is None (unlimited)
        :raises :class:`~tweepy.error.TweepyError`: If there's some critical API error
        """
        # Run tweepy stream

        wrapper_listener = TweepyWrapperListener(listener=self.listener)