refactor: 保存每次请求到的最新消息 id
This commit is contained in:
parent
02a51c6bef
commit
bcbc299167
@ -129,8 +129,7 @@ def run(instance, access_token, fanfou_cookie, fanfou_token):
|
||||
# first time run
|
||||
posted_ids = []
|
||||
# if file not exist, create it
|
||||
with open('last_id.txt', 'a+') as f:
|
||||
f.seek(0)
|
||||
with open('last_id.txt', 'r') as f:
|
||||
# read lines
|
||||
posted_ids = f.readlines()
|
||||
# remove \n
|
||||
@ -164,6 +163,9 @@ def run(instance, access_token, fanfou_cookie, fanfou_token):
|
||||
if statuses:
|
||||
min_id = statuses[-1]['id']
|
||||
else:
|
||||
if min_id:
|
||||
with open('last_id.txt', 'a') as f:
|
||||
f.write(str(min_id) + '\n')
|
||||
min_id = None
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user