print("Checking subscriptions...") while True: data = twister.dhtget(username, "profile", "s") try: twister_subscriptions = data[0]["p"]["v"]["mqtt_topics"] except: twister_subscriptions = [] print("Got: " + ', '.join(twister_subscriptions)) if not set(subscriptions) <= set(twister_subscriptions): print("Updating subscriptions...") try: seq = data[0]["p"]["seq"] + 1 except: seq = 1 rc = twister.dhtput(username, "profile", "s", {"mqtt_topics": subscriptions}, username, seq) time.sleep(5) else: break latest_posts = {} latest_dms = {} print("Getting latest public posts...") for fellow in following: posts = twister.getposts(1, [{"username": fellow}], 3) try: last = posts[0]["userpost"]["k"] except: last = 0 latest_posts[fellow] = last
print("Checking subscriptions...") while True: data = twister.dhtget(username, "profile", "s") try: twister_subscriptions = data[0]["p"]["v"]["mqtt_topics"] except: twister_subscriptions = [] print("Got: " + ', '.join(twister_subscriptions)) if not set(subscriptions) <= set(twister_subscriptions): print("Updating subscriptions...") try: seq = data[0]["p"]["seq"] + 1 except: seq = 1 rc = twister.dhtput(username, "profile", "s", {"mqtt_topics":subscriptions}, username, seq) time.sleep(5) else: break latest_posts = {} latest_dms = {} print("Getting latest public posts...") for fellow in following: posts = twister.getposts(1, [{"username":fellow}], 3) try: last = posts[0]["userpost"]["k"] except: last = 0 latest_posts[fellow] = last