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

Commit c863cf4

Browse files
authored
Merge pull request #487 from Gummary/master
Add api.Replyto for convenience
2 parents 2ca97e4 + 0204960 commit c863cf4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

twitter/api.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4836,6 +4836,32 @@ def VerifyCredentials(self, include_entities=None, skip_status=None, include_ema
48364836

48374837
return User.NewFromJsonDict(data)
48384838

4839+
def ReplyTo(self, status, in_reply_to_status_id, **kwargs):
4840+
"""Relay to a status. Automatically add @username before the status for
4841+
convenience.This method calls api.GetStatus to get username.
4842+
4843+
4844+
Args:
4845+
status (str):
4846+
The message text to be replyed.Must be less than or equal to 140 characters.
4847+
in_reply_to_status_id (int):
4848+
The ID of an existing status that the status to be posted is in reply to.
4849+
**kwargs:
4850+
The other args api.PostUpadtes need.
4851+
4852+
Returns:
4853+
(twitter.Status) A twitter.Status instance representing the message replied.
4854+
"""
4855+
reply_status = self.GetStatus(in_reply_to_status_id)
4856+
u_status = "@%s " % reply_status.user.screen_name
4857+
if isinstance(status, str) or self._input_encoding is None:
4858+
u_status = u_status + status
4859+
else:
4860+
u_status = u_status + str(u_status, self._input_encoding)
4861+
4862+
return self.PostUpdate(u_status, in_reply_to_status_id=in_reply_to_status_id, **kwargs)
4863+
4864+
48394865
def SetCache(self, cache):
48404866
"""Override the default cache. Set to None to prevent caching.
48414867

0 commit comments

Comments
 (0)