Try/catch wrap on timeline fetching in TwitterCog
This commit is contained in:
commit
a48def517f
1 changed files with 4 additions and 1 deletions
|
@ -43,7 +43,10 @@ class TwitterCog(commands.Cog):
|
||||||
handles = Twitter.objects.distinct("handle")
|
handles = Twitter.objects.distinct("handle")
|
||||||
twitter_data = {}
|
twitter_data = {}
|
||||||
for handle in handles:
|
for handle in handles:
|
||||||
twitter_data[handle] = self.api.user_timeline(screen_name=handle)
|
try:
|
||||||
|
twitter_data[handle] = self.api.user_timeline(screen_name=handle)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error with fetching: {e}")
|
||||||
for twitter in twitters:
|
for twitter in twitters:
|
||||||
try:
|
try:
|
||||||
tweets = list(filter(lambda x: x.id > twitter.last_tweet, twitter_data[twitter.handle]))
|
tweets = list(filter(lambda x: x.id > twitter.last_tweet, twitter_data[twitter.handle]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue