Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit 61b8c63

Browse files
committed
allow user_id to be filled if optional screen_name is included
1 parent eb46879 commit 61b8c63

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

twitter/api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2997,7 +2997,8 @@ def GetSentDirectMessages(self,
29972997

29982998
def PostDirectMessage(self,
29992999
text,
3000-
user_id,
3000+
user_id=None,
3001+
screen_name=None,
30013002
return_json=False):
30023003
"""Post a twitter direct message from the authenticated user.
30033004
@@ -3012,6 +3013,11 @@ def PostDirectMessage(self,
30123013
"""
30133014
url = '%s/direct_messages/events/new.json' % self.base_url
30143015

3016+
# Hack to allow some sort of backwards compatibility with older versions
3017+
# part of the fix for Issue #587
3018+
if user_id is None and screen_name is not None:
3019+
user_id = self.GetUser(screen_name=screen_name).id
3020+
30153021
event = {
30163022
'event': {
30173023
'type': 'message_create',

0 commit comments

Comments
 (0)