mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Fixed an error when parsing a DM sent from an deleted account
This commit is contained in:
parent
b10aeb046d
commit
2a791d43bf
@ -77,8 +77,6 @@ def compose_tweet(tweet, db, relative_times, show_screen_names=False, session=No
|
|||||||
return [user+", ", text, ts+", ", source]
|
return [user+", ", text, ts+", ", source]
|
||||||
|
|
||||||
def compose_direct_message(item, db, relative_times, show_screen_names=False, session=None):
|
def compose_direct_message(item, db, relative_times, show_screen_names=False, session=None):
|
||||||
# for a while this function will be together with compose_dm.
|
|
||||||
# this one composes direct messages based on events (new API Endpoints).
|
|
||||||
if system == "Windows":
|
if system == "Windows":
|
||||||
# Let's remove the last 3 digits in the timestamp string.
|
# Let's remove the last 3 digits in the timestamp string.
|
||||||
# Twitter sends their "epoch" timestamp with 3 digits for milliseconds and arrow doesn't like it.
|
# Twitter sends their "epoch" timestamp with 3 digits for milliseconds and arrow doesn't like it.
|
||||||
|
@ -11,6 +11,7 @@ import application
|
|||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
import tweepy
|
import tweepy
|
||||||
from tweepy.error import TweepError
|
from tweepy.error import TweepError
|
||||||
|
from tweepy.models import User as UserModel
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
from keys import keyring
|
from keys import keyring
|
||||||
from sessions import base
|
from sessions import base
|
||||||
@ -404,13 +405,16 @@ class Session(base.baseSession):
|
|||||||
def get_user(self, id):
|
def get_user(self, id):
|
||||||
""" Returns an user object associated with an ID.
|
""" Returns an user object associated with an ID.
|
||||||
id str: User identifier, provided by Twitter.
|
id str: User identifier, provided by Twitter.
|
||||||
returns an user dict."""
|
returns a tweepy user object."""
|
||||||
if ("users" in self.db) == False or (id in self.db["users"]) == False:
|
if ("users" in self.db) == False or (id in self.db["users"]) == False:
|
||||||
try:
|
try:
|
||||||
user = self.twitter.get_user(id=id)
|
user = self.twitter.get_user(id=id)
|
||||||
except TweepError as err:
|
except TweepError as err:
|
||||||
user = dict(screen_name="deleted_account", name="Deleted account")
|
user = UserModel(None)
|
||||||
return user
|
user.screen_name = "deleted_user"
|
||||||
|
user.id = id
|
||||||
|
user.name = _("Deleted account")
|
||||||
|
user.id_str = id
|
||||||
self.db["users"][user.id_str] = user
|
self.db["users"][user.id_str] = user
|
||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user