From eda02fb215e3cc132f53fe702f1a17ef189612ea Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sun, 13 Apr 2014 18:51:20 +1000 Subject: [PATCH 01/13] Update requirements.txt Allow requests dependencies to be greater than or equal to minimum required version if a more recent one is already available. Change reflected in setup.py. --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 917c31a..b9fe523 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ coverage==3.6.0 -requests==2.1.0 -requests_oauthlib==0.4.0 +requests>=2.1.0 +requests_oauthlib>=0.4.0 python-coveralls==2.1.0 nose-cov==1.6 responses==0.2.0 From 3911011d202ae4f7f6f5021e550fa449b9f3574b Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sat, 17 May 2014 13:08:34 +1000 Subject: [PATCH 02/13] CLI script to display a tweet and the poster of that tweet using the tweet status ID through command line arguments. --- examples/show_status.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/show_status.py diff --git a/examples/show_status.py b/examples/show_status.py new file mode 100644 index 0000000..b4da77f --- /dev/null +++ b/examples/show_status.py @@ -0,0 +1,23 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: show_status.py 463604849372704768 + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("ID number of tweet to fetch: ") # For Python 3.x use: target = input("ID number of tweet to fetch: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + tweet = twitter.show_status(id=twid) + print(tweet["user"]["name"]+" ("+tweet["user"]["screen_name"]+"): "+tweet["text"]) +except TwythonError as e: + print(e) + +# This will print: Name (screen name): the content of the tweet selected. From f18af22c00e04277c80dc420708b1d613c04c559 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sat, 17 May 2014 13:17:13 +1000 Subject: [PATCH 03/13] Fixed the comment lines to relate to the action performed. --- examples/block_spammer.py | 2 +- examples/block_user.py | 2 +- examples/unblock_user.py | 2 +- examples/unfollow_user.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/block_spammer.py b/examples/block_spammer.py index c579904..89757f4 100644 --- a/examples/block_spammer.py +++ b/examples/block_spammer.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: block_spammer.py SomeoneAnnoying import sys diff --git a/examples/block_user.py b/examples/block_user.py index a06c5f0..be0a115 100644 --- a/examples/block_user.py +++ b/examples/block_user.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: block_user.py A_Twitter_Troll import sys diff --git a/examples/unblock_user.py b/examples/unblock_user.py index 80ea19c..57a6355 100644 --- a/examples/unblock_user.py +++ b/examples/unblock_user.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: unblock_user.py Not_So_Bad_After_All import sys diff --git a/examples/unfollow_user.py b/examples/unfollow_user.py index 2417035..1e708f6 100644 --- a/examples/unfollow_user.py +++ b/examples/unfollow_user.py @@ -2,7 +2,7 @@ from twython import Twython, TwythonError # Optionally accept user data from the command line (or elsewhere). # -# Usage: follow_user.py ryanmcgrath +# Usage: unfollow_user.py Not_So_Cool_Really import sys From 7a270707c56a91c5655502849b0379ea0b181b66 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sat, 24 May 2014 19:27:48 +1000 Subject: [PATCH 04/13] Fixing or removing true status in examples. --- examples/block_spammer.py | 2 +- examples/block_user.py | 2 +- examples/unblock_user.py | 2 +- examples/unfollow_user.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/block_spammer.py b/examples/block_spammer.py index 89757f4..64b797d 100644 --- a/examples/block_spammer.py +++ b/examples/block_spammer.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.report_spam(screen_name=target, follow="true") + twitter.report_spam(screen_name=target) except TwythonError as e: print(e) diff --git a/examples/block_user.py b/examples/block_user.py index be0a115..6b151ff 100644 --- a/examples/block_user.py +++ b/examples/block_user.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.create_block(screen_name=target, follow="true") + twitter.create_block(screen_name=target, skip_status="true") except TwythonError as e: print(e) diff --git a/examples/unblock_user.py b/examples/unblock_user.py index 57a6355..dcb6ebb 100644 --- a/examples/unblock_user.py +++ b/examples/unblock_user.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.destroy_block(screen_name=target, follow="true") + twitter.destroy_block(screen_name=target, skip_status="true") except TwythonError as e: print(e) diff --git a/examples/unfollow_user.py b/examples/unfollow_user.py index 1e708f6..863eda8 100644 --- a/examples/unfollow_user.py +++ b/examples/unfollow_user.py @@ -15,6 +15,6 @@ else: twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) try: - twitter.destroy_friendship(screen_name=target, follow="true") + twitter.destroy_friendship(screen_name=target) except TwythonError as e: print(e) From 1b57f94418d1f0e4ce4a6eecef259a1480f81862 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:22:16 +1000 Subject: [PATCH 05/13] Reversing change due to merge errors. --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index b9fe523..917c31a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ coverage==3.6.0 -requests>=2.1.0 -requests_oauthlib>=0.4.0 +requests==2.1.0 +requests_oauthlib==0.4.0 python-coveralls==2.1.0 nose-cov==1.6 responses==0.2.0 From e549c74f665301d8c433019be60f770ba1204032 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:29:21 +1000 Subject: [PATCH 06/13] Removed files and offending branches. Now to reverse the polarity of the neutron flow. --- examples/block_spammer.py | 20 -------------------- examples/block_user.py | 20 -------------------- examples/follow_user.py | 20 -------------------- examples/show_status.py | 23 ----------------------- examples/unblock_user.py | 20 -------------------- examples/unfollow_user.py | 20 -------------------- 6 files changed, 123 deletions(-) delete mode 100644 examples/block_spammer.py delete mode 100644 examples/block_user.py delete mode 100644 examples/follow_user.py delete mode 100644 examples/show_status.py delete mode 100644 examples/unblock_user.py delete mode 100644 examples/unfollow_user.py diff --git a/examples/block_spammer.py b/examples/block_spammer.py deleted file mode 100644 index 64b797d..0000000 --- a/examples/block_spammer.py +++ /dev/null @@ -1,20 +0,0 @@ -from twython import Twython, TwythonError - -# Optionally accept user data from the command line (or elsewhere). -# -# Usage: block_spammer.py SomeoneAnnoying - -import sys - -if len(sys.argv) >= 2: - target = sys.argv[1] -else: - target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") - -# Requires Authentication as of Twitter API v1.1 -twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) - -try: - twitter.report_spam(screen_name=target) -except TwythonError as e: - print(e) diff --git a/examples/block_user.py b/examples/block_user.py deleted file mode 100644 index 6b151ff..0000000 --- a/examples/block_user.py +++ /dev/null @@ -1,20 +0,0 @@ -from twython import Twython, TwythonError - -# Optionally accept user data from the command line (or elsewhere). -# -# Usage: block_user.py A_Twitter_Troll - -import sys - -if len(sys.argv) >= 2: - target = sys.argv[1] -else: - target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") - -# Requires Authentication as of Twitter API v1.1 -twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) - -try: - twitter.create_block(screen_name=target, skip_status="true") -except TwythonError as e: - print(e) diff --git a/examples/follow_user.py b/examples/follow_user.py deleted file mode 100644 index b9e78a8..0000000 --- a/examples/follow_user.py +++ /dev/null @@ -1,20 +0,0 @@ -from twython import Twython, TwythonError - -# Optionally accept user data from the command line (or elsewhere). -# -# Usage: follow_user.py ryanmcgrath - -import sys - -if len(sys.argv) >= 2: - target = sys.argv[1] -else: - target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") - -# Requires Authentication as of Twitter API v1.1 -twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) - -try: - twitter.create_friendship(screen_name=target, follow="true") -except TwythonError as e: - print(e) diff --git a/examples/show_status.py b/examples/show_status.py deleted file mode 100644 index b4da77f..0000000 --- a/examples/show_status.py +++ /dev/null @@ -1,23 +0,0 @@ -from twython import Twython, TwythonError - -# Optionally accept user data from the command line (or elsewhere). -# -# Usage: show_status.py 463604849372704768 - -import sys - -if len(sys.argv) >= 2: - target = sys.argv[1] -else: - target = raw_input("ID number of tweet to fetch: ") # For Python 3.x use: target = input("ID number of tweet to fetch: ") - -# Requires Authentication as of Twitter API v1.1 -twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) - -try: - tweet = twitter.show_status(id=twid) - print(tweet["user"]["name"]+" ("+tweet["user"]["screen_name"]+"): "+tweet["text"]) -except TwythonError as e: - print(e) - -# This will print: Name (screen name): the content of the tweet selected. diff --git a/examples/unblock_user.py b/examples/unblock_user.py deleted file mode 100644 index dcb6ebb..0000000 --- a/examples/unblock_user.py +++ /dev/null @@ -1,20 +0,0 @@ -from twython import Twython, TwythonError - -# Optionally accept user data from the command line (or elsewhere). -# -# Usage: unblock_user.py Not_So_Bad_After_All - -import sys - -if len(sys.argv) >= 2: - target = sys.argv[1] -else: - target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") - -# Requires Authentication as of Twitter API v1.1 -twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) - -try: - twitter.destroy_block(screen_name=target, skip_status="true") -except TwythonError as e: - print(e) diff --git a/examples/unfollow_user.py b/examples/unfollow_user.py deleted file mode 100644 index 863eda8..0000000 --- a/examples/unfollow_user.py +++ /dev/null @@ -1,20 +0,0 @@ -from twython import Twython, TwythonError - -# Optionally accept user data from the command line (or elsewhere). -# -# Usage: unfollow_user.py Not_So_Cool_Really - -import sys - -if len(sys.argv) >= 2: - target = sys.argv[1] -else: - target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") - -# Requires Authentication as of Twitter API v1.1 -twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) - -try: - twitter.destroy_friendship(screen_name=target) -except TwythonError as e: - print(e) From da7940ec5b9870cfe95d8e2e7515e3b22293d8d2 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:35:08 +1000 Subject: [PATCH 07/13] Updating requirements to allow Twython to work with versions of Requests higher than the minimum. --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 917c31a..b9fe523 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ coverage==3.6.0 -requests==2.1.0 -requests_oauthlib==0.4.0 +requests>=2.1.0 +requests_oauthlib>=0.4.0 python-coveralls==2.1.0 nose-cov==1.6 responses==0.2.0 From f4614cc0676fdd8b6d5114d0f5a4a78808caf8e5 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:38:30 +1000 Subject: [PATCH 08/13] Restoring spammer blocking example. --- examples/block_spammer.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/block_spammer.py diff --git a/examples/block_spammer.py b/examples/block_spammer.py new file mode 100644 index 0000000..64b797d --- /dev/null +++ b/examples/block_spammer.py @@ -0,0 +1,20 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: block_spammer.py SomeoneAnnoying + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + twitter.report_spam(screen_name=target) +except TwythonError as e: + print(e) From af1a68eecb1a61fb84c1e0a9e5fe6209f5a8624a Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:39:36 +1000 Subject: [PATCH 09/13] Restoring follow user example. --- examples/follow_user.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/follow_user.py diff --git a/examples/follow_user.py b/examples/follow_user.py new file mode 100644 index 0000000..b9e78a8 --- /dev/null +++ b/examples/follow_user.py @@ -0,0 +1,20 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: follow_user.py ryanmcgrath + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + twitter.create_friendship(screen_name=target, follow="true") +except TwythonError as e: + print(e) From 8e44989c01c4ee7372c60d955140f90783d3dad8 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:41:12 +1000 Subject: [PATCH 10/13] Add script example to block users, takes input from the command line or interactively. --- examples/block_user.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/block_user.py diff --git a/examples/block_user.py b/examples/block_user.py new file mode 100644 index 0000000..6b151ff --- /dev/null +++ b/examples/block_user.py @@ -0,0 +1,20 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: block_user.py A_Twitter_Troll + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + twitter.create_block(screen_name=target, skip_status="true") +except TwythonError as e: + print(e) From a95092f33ef3663d81745e869ad6425cd6912762 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:42:53 +1000 Subject: [PATCH 11/13] Example script to display a tweet. --- examples/show_status.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/show_status.py diff --git a/examples/show_status.py b/examples/show_status.py new file mode 100644 index 0000000..b4da77f --- /dev/null +++ b/examples/show_status.py @@ -0,0 +1,23 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: show_status.py 463604849372704768 + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("ID number of tweet to fetch: ") # For Python 3.x use: target = input("ID number of tweet to fetch: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + tweet = twitter.show_status(id=twid) + print(tweet["user"]["name"]+" ("+tweet["user"]["screen_name"]+"): "+tweet["text"]) +except TwythonError as e: + print(e) + +# This will print: Name (screen name): the content of the tweet selected. From c820e49230b973f9cfcb0a75eb9ded57598dba97 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:44:34 +1000 Subject: [PATCH 12/13] Example script to remove a block from an account. --- examples/unblock_user.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/unblock_user.py diff --git a/examples/unblock_user.py b/examples/unblock_user.py new file mode 100644 index 0000000..dcb6ebb --- /dev/null +++ b/examples/unblock_user.py @@ -0,0 +1,20 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: unblock_user.py Not_So_Bad_After_All + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + twitter.destroy_block(screen_name=target, skip_status="true") +except TwythonError as e: + print(e) From 564db6da1bd039d3aefb29500f5a537ad111f4a8 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Tue, 5 Aug 2014 22:45:29 +1000 Subject: [PATCH 13/13] Example script to stop following a user. --- examples/unfollow_user.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/unfollow_user.py diff --git a/examples/unfollow_user.py b/examples/unfollow_user.py new file mode 100644 index 0000000..863eda8 --- /dev/null +++ b/examples/unfollow_user.py @@ -0,0 +1,20 @@ +from twython import Twython, TwythonError + +# Optionally accept user data from the command line (or elsewhere). +# +# Usage: unfollow_user.py Not_So_Cool_Really + +import sys + +if len(sys.argv) >= 2: + target = sys.argv[1] +else: + target = raw_input("User to follow: ") # For Python 3.x use: target = input("User to follow: ") + +# Requires Authentication as of Twitter API v1.1 +twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) + +try: + twitter.destroy_friendship(screen_name=target) +except TwythonError as e: + print(e)