Twitter replied-to feature now supports replies to users as well as statuses.
This commit is contained in:
parent
2fd4375d78
commit
d2ad68cc4e
|
@ -43,13 +43,13 @@ def twitter(inp):
|
||||||
def find_reply(reply_name):
|
def find_reply(reply_name):
|
||||||
for name, id in history:
|
for name, id in history:
|
||||||
if name == reply_name:
|
if name == reply_name:
|
||||||
return id
|
return id if id != -1 else name
|
||||||
|
|
||||||
if inp[0] == '@':
|
if inp[0] == '@':
|
||||||
reply_id = find_reply(inp[1:])
|
reply_inp = find_reply(inp[1:])
|
||||||
if reply_id == None:
|
if reply_inp == None:
|
||||||
return 'error: no replies to %s found' % inp
|
return 'error: no replies to %s found' % inp
|
||||||
inp = reply_id
|
inp = reply_inp
|
||||||
|
|
||||||
url = 'http://twitter.com'
|
url = 'http://twitter.com'
|
||||||
getting_nth = False
|
getting_nth = False
|
||||||
|
@ -60,6 +60,7 @@ def twitter(inp):
|
||||||
text = 'status/text'
|
text = 'status/text'
|
||||||
reply_name = 'status/in_reply_to_screen_name'
|
reply_name = 'status/in_reply_to_screen_name'
|
||||||
reply_id = 'status/in_reply_to_status_id'
|
reply_id = 'status/in_reply_to_status_id'
|
||||||
|
reply_user = 'status/in_reply_to_user_id'
|
||||||
|
|
||||||
if re.match(r'^\d+$', inp):
|
if re.match(r'^\d+$', inp):
|
||||||
getting_id = True
|
getting_id = True
|
||||||
|
@ -69,6 +70,7 @@ def twitter(inp):
|
||||||
text = 'text'
|
text = 'text'
|
||||||
reply_name = 'in_reply_to_screen_name'
|
reply_name = 'in_reply_to_screen_name'
|
||||||
reply_id = 'in_reply_to_status_id'
|
reply_id = 'in_reply_to_status_id'
|
||||||
|
reply_user = 'in_reply_to_user_id'
|
||||||
elif re.match(r'^\w{1,15}$', inp):
|
elif re.match(r'^\w{1,15}$', inp):
|
||||||
url += '/users/show/%s.xml' % inp
|
url += '/users/show/%s.xml' % inp
|
||||||
screen_name = 'screen_name'
|
screen_name = 'screen_name'
|
||||||
|
@ -124,8 +126,9 @@ def twitter(inp):
|
||||||
|
|
||||||
reply_name = tweet.find(reply_name).text
|
reply_name = tweet.find(reply_name).text
|
||||||
reply_id = tweet.find(reply_id).text
|
reply_id = tweet.find(reply_id).text
|
||||||
if reply_name is not None and reply_id is not None:
|
reply_user = tweet.find(reply_user).text
|
||||||
add_reply(reply_name, reply_id)
|
if reply_name is not None and (reply_id is not None or reply_user is not None):
|
||||||
|
add_reply(reply_name, reply_id if reply_id else -1)
|
||||||
|
|
||||||
time = strftime('%Y-%m-%d %H:%M:%S',
|
time = strftime('%Y-%m-%d %H:%M:%S',
|
||||||
strptime(time.text,
|
strptime(time.text,
|
||||||
|
|
Loading…
Reference in New Issue