getThreadList fix: end
is ignored by the querry
This commit is contained in:
@@ -512,25 +512,27 @@ class Client(object):
|
|||||||
# Strip the start and parse out the returned image_id
|
# Strip the start and parse out the returned image_id
|
||||||
return json.loads(r._content[9:])['payload']['metadata'][0]['image_id']
|
return json.loads(r._content[9:])['payload']['metadata'][0]['image_id']
|
||||||
|
|
||||||
def getThreadInfo(self, userID, start, length=20, thread_type='user'):
|
def getThreadInfo(self, userID, last_n=20, start=None, thread_type='user'):
|
||||||
"""Get the info of one Thread
|
"""Get the info of one Thread
|
||||||
|
|
||||||
:param userID: ID of the user you want the messages from
|
:param userID: ID of the user you want the messages from
|
||||||
:param start: the start index of a thread
|
:param last_n: (optional) number of retrieved messages from start
|
||||||
:param length: (optional) number of retrieved messages from start
|
:param start: (optional) the start index of a thread (Deprecated)
|
||||||
:param thread_type: (optional) change from 'user' for group threads
|
:param thread_type: (optional) change from 'user' for group threads
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert length > 0, 'length must be positive integer, got %d' % length
|
assert last_n > 0, 'length must be positive integer, got %d' % last_n
|
||||||
|
assert start is None, '`start` is deprecated, always 0 offset querry is returned'
|
||||||
data = {}
|
data = {}
|
||||||
if thread_type == 'user':
|
if thread_type == 'user':
|
||||||
key = 'user_ids'
|
key = 'user_ids'
|
||||||
else:
|
else:
|
||||||
key = 'thread_fbids'
|
key = 'thread_fbids'
|
||||||
|
assert
|
||||||
data['messages[{}][{}][offset]'.format(key, userID)] = start
|
# deprecated
|
||||||
data['messages[{}][{}][limit]'.format(key, userID)] = length
|
# `start` doesn't matter, always returns from the last
|
||||||
|
# data['messages[{}][{}][offset]'.format(key, userID)] = start
|
||||||
|
data['messages[{}][{}][limit]'.format(key, userID)] = last_n
|
||||||
data['messages[{}][{}][timestamp]'.format(key, userID)] = now()
|
data['messages[{}][{}][timestamp]'.format(key, userID)] = now()
|
||||||
|
|
||||||
r = self._post(MessagesURL, query=data)
|
r = self._post(MessagesURL, query=data)
|
||||||
@@ -554,8 +556,12 @@ class Client(object):
|
|||||||
:param end: (optional) the last index of a thread
|
:param end: (optional) the last index of a thread
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not end: end = start + 20
|
# deprecated
|
||||||
if end <= start: end = start + end
|
# end does not limit the length of the returned threads
|
||||||
|
# if not end: end = start + 20
|
||||||
|
# if end <= start: end = start + end
|
||||||
|
|
||||||
|
assert end is None, 'end is deprecated'
|
||||||
|
|
||||||
timestamp = now()
|
timestamp = now()
|
||||||
date = datetime.now()
|
date = datetime.now()
|
||||||
|
Reference in New Issue
Block a user