From 61b8c6325e272290bcdbf92d7dbb09d3478b3748 Mon Sep 17 00:00:00 2001 From: "bear (Mike Taylor)" Date: Sat, 29 Sep 2018 19:49:24 -0400 Subject: [PATCH] allow user_id to be filled if optional screen_name is included --- twitter/api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/twitter/api.py b/twitter/api.py index 4c462e35..15a778f1 100755 --- a/twitter/api.py +++ b/twitter/api.py @@ -2997,7 +2997,8 @@ def GetSentDirectMessages(self, def PostDirectMessage(self, text, - user_id, + user_id=None, + screen_name=None, return_json=False): """Post a twitter direct message from the authenticated user. @@ -3012,6 +3013,11 @@ def PostDirectMessage(self, """ url = '%s/direct_messages/events/new.json' % self.base_url + # Hack to allow some sort of backwards compatibility with older versions + # part of the fix for Issue #587 + if user_id is None and screen_name is not None: + user_id = self.GetUser(screen_name=screen_name).id + event = { 'event': { 'type': 'message_create',