Compare commits
No commits in common. "027b1f597da6129d8199a235b244992541600d08" and "d5444f5f16be3e2fd0ee6998559350b530d2935e" have entirely different histories.
027b1f597d
...
d5444f5f16
12
mas2ff2.py
12
mas2ff2.py
@ -157,13 +157,15 @@ def run(instance, access_token, fanfou_cookie, fanfou_token):
|
|||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
# get every new status
|
while True:
|
||||||
while min_id:
|
requests.get('https://up.tunpok.com/api/push/sQLwSpeiUH?msg=OK&ping=')
|
||||||
|
# get new status
|
||||||
me_timeline = mastodon_cli.account_statuses(
|
me_timeline = mastodon_cli.account_statuses(
|
||||||
me_id, exclude_replies=True, min_id=min_id)
|
me_id, exclude_replies=True, min_id=min_id)
|
||||||
# if no new status
|
# if no new status
|
||||||
if not me_timeline:
|
if not me_timeline:
|
||||||
break
|
time.sleep(10)
|
||||||
|
continue
|
||||||
statuses = []
|
statuses = []
|
||||||
for status in me_timeline:
|
for status in me_timeline:
|
||||||
statuses.append(status)
|
statuses.append(status)
|
||||||
@ -173,7 +175,7 @@ def run(instance, access_token, fanfou_cookie, fanfou_token):
|
|||||||
if str(status['id']) not in posted_ids:
|
if str(status['id']) not in posted_ids:
|
||||||
content = status['content'].replace('<br />', '\n')
|
content = status['content'].replace('<br />', '\n')
|
||||||
content = re.sub('<.*?>', '', content)
|
content = re.sub('<.*?>', '', content)
|
||||||
logger.info(status['id'] + ' ' + content)
|
logger.info(status['id'], content)
|
||||||
post_fanfou(fanfou_cookie, fanfou_token, content, status['media_attachments'])
|
post_fanfou(fanfou_cookie, fanfou_token, content, status['media_attachments'])
|
||||||
with open('last_id.txt', 'a') as f:
|
with open('last_id.txt', 'a') as f:
|
||||||
f.write(str(status['id']) + '\n')
|
f.write(str(status['id']) + '\n')
|
||||||
@ -183,8 +185,6 @@ def run(instance, access_token, fanfou_cookie, fanfou_token):
|
|||||||
# update min_id
|
# update min_id
|
||||||
if statuses:
|
if statuses:
|
||||||
min_id = statuses[-1]['id']
|
min_id = statuses[-1]['id']
|
||||||
else:
|
|
||||||
min_id = None
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
cookie = 'u=stokesia; uuid=24edfe42401cbb03cf1f.1676446846.21; PHPSESSID=d4l9m3tp09gasff6r3u8mv9p12; m=yvettezhong%40gmail.com; tgw_l7_route=f174d6f255742a6ee2e9a07cf9cca0fa'
|
cookie = 'u=stokesia; uuid=24edfe42401cbb03cf1f.1676446846.21; PHPSESSID=d4l9m3tp09gasff6r3u8mv9p12; m=yvettezhong%40gmail.com; tgw_l7_route=f174d6f255742a6ee2e9a07cf9cca0fa'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user