Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding:Utf-8 -*-
- import sys
- import twitter
- def unfollowator(api, argv):
- if (len(argv) < 3) or (len(argv) > 2 and argv[2] != "force"):
- print "WARNING this will unfollow all the friends you have who doesn't"\
- "follow you !"
- print
- print 'Write "python twitterscript.py unfollow force" if you know what'\
- ' you are doing.\n'
- sys.exit(1)
- if len(argv) <= 3:
- stop = 1000
- else:
- stop = int(argv[3])
- my_friends = api.GetFriends()
- my_followers = api.GetFollowers()
- # get name of my followers
- my_followers = [i.screen_name for i in my_followers]
- a = 0
- for i in my_friends:
- if i.screen_name not in my_followers:
- print "bye bye", i.screen_name
- api.DestroyFriendship(i.screen_name)
- # oui ce code est imonde
- a += 1
- if a == stop:
- print "Stop at %s unfollow" % stop
- break
- def steal_friends(api, argv):
- if len(argv) <= 2:
- print "Need user name"
- sys.exit(1)
- if len(argv) <= 3:
- stop = 1000
- else:
- stop = int(argv[3])
- user = argv[2]
- amis = api.GetFriends(user)
- a = 0
- for i in amis:
- try:
- api.CreateFriendship(i.screen_name)
- except Exception, e:
- print "Exception for %s" % i.screen_name, e
- else:
- print i.screen_name
- # oui ce code est imonde
- a += 1
- if a == stop:
- print "Stop at %s new friends" % stop
- break
- def follow_followers(api, argv):
- if len(argv) <= 2:
- stop = 1000
- else:
- stop = int(argv[2])
- amis = api.GetFriends()
- a = 0
- for i in amis:
- try:
- api.CreateFriendship(i.screen_name)
- except Exception, e:
- print "Exception for %s" % i.screen_name, e
- else:
- print i.screen_name
- # oui ce code est imonde
- a += 1
- if a == stop:
- print "Stop at %s new friends" % stop
- break
- def print_help():
- print "Commands:"
- print " unfollow unfollow all the people that aren't following me"
- print " steal follow all the friends off someone, user name require"
- print " ff follow my followers"
- print
- print "Don't forget to put your user name and your password in the script !"
- if __name__ == "__main__":
- api = twitter.Api(username='zoubiboulba', password='hophophop')
- if len(sys.argv) <= 1:
- print_help()
- sys.exit(1)
- command = {"steal" : steal_friends, "unfollow" : unfollowator,
- "ff" : follow_followers}
- if sys.argv[1] not in command.keys():
- print "Unknow command", sys.argv[1]
- else:
- command[sys.argv[1]](api, sys.argv)
- # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement