Change conditions for delete

master
Thor 3 years ago
parent bfdfc901fe
commit f812744668
  1. 11
      fedidel.py

@ -105,10 +105,9 @@ class Instance:
while True: while True:
try: try:
self.state_lock.acquire() self.state_lock.acquire()
min_id = self.state["min_id"]
self.state_lock.release() self.state_lock.release()
statuses = self.api.account_statuses(my_id, min_id = min_id) statuses = self.api.account_statuses(my_id, min_id = self.state["min_id"])
while not statuses is None and len(statuses) > 0: while not statuses is None and len(statuses) > 0:
log_print(self.name, "Found {} new status(es)".format(len(statuses))) log_print(self.name, "Found {} new status(es)".format(len(statuses)))
@ -116,12 +115,13 @@ class Instance:
for status in sorted(statuses, for status in sorted(statuses,
key = lambda status: status["created_at"]): key = lambda status: status["created_at"]):
self.track_status(status) self.track_status(status)
self.state["min_id"] = status["id"]
self.save_state() self.save_state()
statuses = self.api.fetch_previous(statuses) statuses = self.api.fetch_previous(statuses)
# Rate limit (300 requests per 5 minutes, i.e. 1 per second) # Rate limit (max 300 requests per 5 minutes, i.e. 1 per second)
time.sleep(1) time.sleep(1)
except: except:
@ -206,15 +206,12 @@ class Instance:
timeslot_key = encode_time(status["created_at"]) timeslot_key = encode_time(status["created_at"])
self.state_lock.acquire() self.state_lock.acquire()
if status["reblog"] is None: if status["reblog"] is None and not status["visibility"] is "direct":
timeslots = self.state["timeslots"] timeslots = self.state["timeslots"]
if not timeslot_key in timeslots: if not timeslot_key in timeslots:
timeslots[timeslot_key] = set() timeslots[timeslot_key] = set()
timeslots[timeslot_key].add(status_id) timeslots[timeslot_key].add(status_id)
if status_id > self.state["min_id"]:
self.state["min_id"] = status_id
self.state_lock.release() self.state_lock.release()
def next_expired(self): def next_expired(self):

Loading…
Cancel
Save