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]
|
||||
|
||||
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":
|
||||
# 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.
|
||||
|
@ -11,6 +11,7 @@ import application
|
||||
from pubsub import pub
|
||||
import tweepy
|
||||
from tweepy.error import TweepError
|
||||
from tweepy.models import User as UserModel
|
||||
from mysc.thread_utils import call_threaded
|
||||
from keys import keyring
|
||||
from sessions import base
|
||||
@ -404,13 +405,16 @@ class Session(base.baseSession):
|
||||
def get_user(self, id):
|
||||
""" Returns an user object associated with an ID.
|
||||
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:
|
||||
try:
|
||||
user = self.twitter.get_user(id=id)
|
||||
except TweepError as err:
|
||||
user = dict(screen_name="deleted_account", name="Deleted account")
|
||||
return user
|
||||
user = UserModel(None)
|
||||
user.screen_name = "deleted_user"
|
||||
user.id = id
|
||||
user.name = _("Deleted account")
|
||||
user.id_str = id
|
||||
self.db["users"][user.id_str] = user
|
||||
return user
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user