Пример #1
0
    def _show_tweets(self, data, error, watched_field='last_tweet'):
        """Function called after we receive the list of tweets."""

        if error == 401:
            # authentication fail
            print 'Request authorization failed. Please, check your details:'
            console_utils.authorization(self._save, namespace, self._prefs,
                                        self._username, self._password,
                                        self._https, self._twitter)

            # this is a little bit icky
            # (just call the same thing that called ths function)
            if watched_field == 'last_tweet':
                self._twitter.friends_timeline(self._show_tweets)
                return

        if error:
            print 'Sorry, couldn\'t download your friends timeline.'
            return

        last_seen_tweet = self._prefs[watched_field]

        self._tweets = console_utils.print_tweets(data,
                                                  last_seen_tweet,
                                                  show_numbers=True)
        if self._tweets:
            self._prefs[watched_field] = self._tweets[-1]
            self._save(self._username, self._password, self._https, namespace,
                       self._prefs)

        if watched_field == 'last_tweet':
            self._last_update = datetime.datetime.now()

        self._refresh_rate_limit()
        return
Пример #2
0
    def _show_tweets(self, data, error, watched_field='last_tweet'):
        """Function called after we receive the list of tweets."""

        if error == 401:
            # authentication fail
            print 'Request authorization failed. Please, check your details:'
            console_utils.authorization(self._save, namespace, self._prefs,
                    self._username, self._password, self._https, self._twitter)

            # this is a little bit icky
            # (just call the same thing that called ths function)
            if watched_field == 'last_tweet':
                self._twitter.friends_timeline(self._show_tweets)
                return

        if error:
            print 'Sorry, couldn\'t download your friends timeline.'
            return

        last_seen_tweet = self._prefs[watched_field]

        self._tweets = console_utils.print_tweets(data, last_seen_tweet,
                show_numbers=True)
        if self._tweets:
            self._prefs[watched_field] = self._tweets[-1]
            self._save(self._username, self._password, self._https,
                    namespace, self._prefs)

        if watched_field == 'last_tweet':
            self._last_update = datetime.datetime.now()

        self._refresh_rate_limit()
        return
Пример #3
0
    def __call__(self):
        """Make the object callable; that's the only requirement for
        Mitter."""
        if not self._username:
            console_utils.authorization(self._save, namespace, self._prefs,
                    connection=self._twitter)

        self.cmdloop()
        return
Пример #4
0
    def __call__(self):
        """Make the object callable; that's the only requirement for
        Mitter."""
        if not self._username:
            console_utils.authorization(self._save,
                                        namespace,
                                        self._prefs,
                                        connection=self._twitter)

        self.cmdloop()
        return
Пример #5
0
    def _list_tweets(self, data, error, watch_field='last_id'):
        """Function called by the twitter interface when it have all the
        friends timeline."""

        if error == 401:
            # Not authenticated
            print 'Authorization fail. Check your details:'
            console_utils.authorization(self.save, namespace, self.prefs,
                self.username, self.password, self.https)
            print 'Your configuration was saved. Call mitter again.'
            return

        if error:
            print 'Sorry, couldn\'t download your friends timeline.'
            return

        tweets = console_utils.print_tweets(data, self.prefs[watch_field])
        if tweets:
            self.prefs[watch_field] = tweets[-1]
            self.save(self.username, self.password, self.https, namespace, \
                self.prefs)

        return
Пример #6
0
    def _list_tweets(self, data, error, watch_field='last_id'):
        """Function called by the twitter interface when it have all the
        friends timeline."""

        if error == 401:
            # Not authenticated
            print 'Authorization fail. Check your details:'
            console_utils.authorization(self.save, namespace, self.prefs,
                                        self.username, self.password,
                                        self.https)
            print 'Your configuration was saved. Call mitter again.'
            return

        if error:
            print 'Sorry, couldn\'t download your friends timeline.'
            return

        tweets = console_utils.print_tweets(data, self.prefs[watch_field])
        if tweets:
            self.prefs[watch_field] = tweets[-1]
            self.save(self.username, self.password, self.https, namespace, \
                self.prefs)

        return