CHG: describot notifies only following users on the home timeline
This commit is contained in:
parent
e8e1c03b08
commit
dfed69e958
11
describot.py
11
describot.py
|
@ -12,6 +12,8 @@ api_mastoes = get_api('masto.es', bot_name)
|
||||||
max_posts=20
|
max_posts=20
|
||||||
warned=[]
|
warned=[]
|
||||||
|
|
||||||
|
following = list_read(bot_name + "_following")
|
||||||
|
|
||||||
def check_timeline(domain, api_external, timeline_name = 'local'):
|
def check_timeline(domain, api_external, timeline_name = 'local'):
|
||||||
last_ids = list_read(bot_name + "_" + domain + "_last_ids")
|
last_ids = list_read(bot_name + "_" + domain + "_last_ids")
|
||||||
warned.extend(list_read(bot_name + "_" + domain))
|
warned.extend(list_read(bot_name + "_" + domain))
|
||||||
|
@ -21,7 +23,7 @@ def check_timeline(domain, api_external, timeline_name = 'local'):
|
||||||
new_last_ids.append(post['id'])
|
new_last_ids.append(post['id'])
|
||||||
for i in range(0, len(timeline) - 2):
|
for i in range(0, len(timeline) - 2):
|
||||||
post = timeline[i]
|
post = timeline[i]
|
||||||
if str(post['id']) not in last_ids and (str(post['account']['acct']) not in warned or timeline_name == 'home'):
|
if str(post['id']) not in last_ids and (str(post['account']['acct']) not in warned or (timeline_name == 'home' and post['account']['acct'] in following)):
|
||||||
for media in post['media_attachments']:
|
for media in post['media_attachments']:
|
||||||
if media['description'] is None:
|
if media['description'] is None:
|
||||||
print('Warning ' + post['account']['acct'])
|
print('Warning ' + post['account']['acct'])
|
||||||
|
@ -34,8 +36,11 @@ def check_timeline(domain, api_external, timeline_name = 'local'):
|
||||||
|
|
||||||
notifications = get_new_notifications(api_mastoes, bot_name, types=['follow'])
|
notifications = get_new_notifications(api_mastoes, bot_name, types=['follow'])
|
||||||
for n in notifications:
|
for n in notifications:
|
||||||
print("Following: " + n['account']['acct'])
|
if n['account']['acct'] not in following:
|
||||||
api_mastoes.account_follow(n['account']['id'])
|
print("Following: " + n['account']['acct'])
|
||||||
|
api_mastoes.account_follow(n['account']['id'])
|
||||||
|
following.append(n['account']['acct'])
|
||||||
|
list_append(bot_name + "_following", n['account']['acct'])
|
||||||
|
|
||||||
|
|
||||||
check_timeline('masto.es', api_mastoes)
|
check_timeline('masto.es', api_mastoes)
|
||||||
|
|
Loading…
Reference in New Issue