twitterbot.crawl() returns reports now, not statuses

remotes/1705286528371406548/stable1
b3yond 2018-01-18 13:54:32 +01:00
parent 048bad181b
commit b174db3cfe
1 changed files with 6 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import requests
import pytoml as toml import pytoml as toml
import trigger import trigger
from time import sleep from time import sleep
import report
import logging import logging
import sendmail import sendmail
@ -100,15 +101,18 @@ class RetweetBot(object):
""" """
crawls all Tweets which mention the bot from the twitter rest API. crawls all Tweets which mention the bot from the twitter rest API.
:return: list of Status objects :return: reports: (list of report.Report objects)
""" """
reports = []
try: try:
if not self.waiting(): if not self.waiting():
if self.last_mention == 0: if self.last_mention == 0:
mentions = self.api.mentions_timeline() mentions = self.api.mentions_timeline()
else: else:
mentions = self.api.mentions_timeline(since_id=self.last_mention) mentions = self.api.mentions_timeline(since_id=self.last_mention)
return mentions for status in mentions:
reports.append(report.Report(status.author, "twitter", status.text, status.id, status.created_at))
return reports
except tweepy.RateLimitError: except tweepy.RateLimitError:
logger.error("Twitter API Error: Rate Limit Exceeded", exc_info=True) logger.error("Twitter API Error: Rate Limit Exceeded", exc_info=True)
self.waitcounter += 60*15 + 1 self.waitcounter += 60*15 + 1