def main(a, args): a.ignored_errors = { (177, 'friends.add'): None, } a.timeout = 10 banned = list(map(int, open(accounts.getFile('banned.txt')).read().split())) controller = scriptlib.createFriendController() friends = scriptlib.getFriends(a, fields=controller.fields) logging.info('Starting to delete') for i in friends: if not (controller.isGood(i) or i['id'] in banned): a.friends.delete.delayed(user_id=i['id']) logging.info('deleted ' + str(i['id'])) log.write('_update_friends', 'deleted ' + str(i['id'])) a.sync() foll = scriptlib.getFollowers(a, fields=controller.fields) logging.info('Starting to add') def cb(req, resp): logging.info(('added ' if resp else 'error ') + str(req['user_id'])) for i in foll: if controller.isGood(i): a.friends.add.delayed(user_id=i['id']).callback(cb) a.sync() logging.info('\nFinished')
def main(a, args): friends = scriptlib.getFriends(a, fields='can_write_private_message') to_del = [] for j in friends: if not j['can_write_private_message']: to_del.append(str(j['id'])) logging.info('Found id{} ({} {})'.format(j['id'], j['first_name'], j['last_name'])) check_friend.appendNoadd(to_del)
def main(a, args): friends = scriptlib.getFriends(a, fields='can_write_private_message') to_del = [] for j in friends: if not j['can_write_private_message']: to_del.append(str(j['id'])) logging.info('Found id{} ({} {})'.format(j['id'], j['first_name'], j['last_name'])) scriptlib.createFriendController().appendNoadd(to_del)
def main(a, args): days = config.get('delfriends.days_till_unfriend', 'i') prepare = 'prepare' in args if prepare: f = open(accounts.getFile('_delfriends.txt'), 'w') else: try: f = set( map(int, open(accounts.getFile('_delfriends.txt')).read().split())) except FileNotFoundError: logging.info('_delfriends.txt not found') return friends = scriptlib.getFriends(a) now = time.time() to_del = [] cnt = 0 def checkHistory(req, resp): nonlocal cnt if resp['count'] == 0 or now - resp['items'][0][ 'date'] > 3600 * 24 * days: if prepare: f.write(str(req['user_id']) + '\n') else: to_del.append(str(req['user_id'])) logging.info('Found ' + str(req['user_id'])) cnt += 1 for i in friends: if not prepare and i not in f: continue a.messages.getHistory.delayed(count=1, user_id=i).callback(checkHistory) a.sync() if prepare: f.close() else: scriptlib.createFriendController().appendNoadd(to_del) logging.info('Total: ' + str(cnt))
def main(a, args): days = config.get('delfriends.days_till_unfriend', 'i') prepare = 'prepare' in args if prepare: f = open(accounts.getFile('_delfriends.txt'), 'w') else: try: f = set(map(int, open(accounts.getFile('_delfriends.txt')).read().split())) except FileNotFoundError: logging.info('_delfriends.txt not found') return friends = scriptlib.getFriends(a) now = time.time() to_del = [] cnt = 0 def checkHistory(req, resp): nonlocal cnt if resp['count'] == 0 or now - resp['items'][0]['date'] > 3600 * 24 * days: if prepare: f.write(str(req['user_id']) + '\n') else: to_del.append(str(req['user_id'])) logging.info('Found ' + str(req['user_id'])) cnt += 1 for i in friends: if not prepare and i not in f: continue a.messages.getHistory.delayed(count=1, user_id=i).callback(checkHistory) a.sync() if prepare: f.close() else: check_friend.appendNoadd(to_del) logging.info('Total: ' + str(cnt))