twitterbot.crawl() returns reports now, not statuses
This commit is contained in:
parent
048bad181b
commit
b174db3cfe
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue