Example #1
0
def print_unfollowers(args):
    user = args.user
    limit = args.limit
    fmt = args.fmt
    whitelisted = args.whitelisted
    friends_ids = api.friends_ids(user.id)[0]
    followers_ids = user.followers_ids()[0]
    i = 0
    for friend_id in friends_ids:
        if friend_id in followers_ids:
            continue
        friend = api.get_user(friend_id)
        if friend.screen_name in whitelisted:
            continue
        i += 1
        if i > limit:
            return
        if not api.exists_friendship(friend_id, user.id):
            try:
                print fmt % friend.__dict__

            except tweepy.error.TweepError, e:
                print '* %s (%s)' % (
                        friend.name,
                        friend.screen_name,
                        )
                print '  Error:', e
Example #2
0
parser.add_argument('--format', '-f', dest='fmt', default=default_fmt)
parser.add_argument('--user', '-u')
parser.add_argument('--whitelisted', '-w', nargs='+',
        help='File with list of whitelisted users')

args = parser.parse_args()

if args.whitelisted:
    whitelisted = set()
    for path in args.whitelisted:
        if os.path.isfile(path):
            with open(path) as instream:
                for line in instream.readlines():
                    whitelisted.add(line.strip())
    args.whitelisted = whitelisted
else:
    args.whitelisted = ()


from twitter_cli.common import api

if args.user:
    args.user = api.get_user(args.user)
else:
    args.user = api.me()

from twitter_cli.printing import print_unfollowers
print_unfollowers(args)

# eof
Example #3
0
default_fmt = '%(screen_name)s'
#fmt = '* %(name)s (%(screen_name)s) t#=%(statuses_count)d fg=%(friends_count)d ff=%(followers_count)d l=%(lang)s\n%(description)s'

parser = argparse.ArgumentParser(description='Show users not following back')
parser.add_argument('files', metavar='FILE...', nargs='+',
        help='Files with lists of usernames')
parser.add_argument('--limit', '-l', type=int, default=default_limit)
parser.add_argument('--format', '-f', dest='fmt', default=default_fmt)

args = parser.parse_args()

from twitter_cli.common import api

me = api.me()
friends_ids = api.friends_ids(me.id)[0]

for filename in args.files:
    with open(filename) as instream:
        i = 0
        for line in instream.readlines():
            username = line.strip()
            user = api.get_user(username)
            if user.id not in friends_ids:
                continue
            i += 1
            if i > args.limit:
                break
            print 'unfollowing', username, '...'
            user.unfollow()