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

Commit

Permalink
allow user_id to be filled if optional screen_name is included
Browse files Browse the repository at this point in the history
  • Loading branch information
bear committed Sep 29, 2018
1 parent eb46879 commit 61b8c63
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion twitter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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',
Expand Down

1 comment on commit 61b8c63

@jeremylow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1,000th commit!

Please sign in to comment.