Skip to content

Commit

Permalink
Merge pull request the-ethan-hunt#130 from hmangukia/master
Browse files Browse the repository at this point in the history
Twitter feature enhanced
  • Loading branch information
the-ethan-hunt authored Jul 15, 2018
2 parents 428f3bc + 2130518 commit 5581bdf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
9 changes: 5 additions & 4 deletions windows/activities.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ List of the things that B.E.N.J.I. can do:
* Create a file(txt, docx, pptx,xlsx, vsdx and rtf supported)
* Podcast
* Calculator
* Get top 10 tweets
* Twitter(get top 10 tweets, get list of people you are following)

Keep reading to see how to do all the above mentioned jobs with B.E.N.J.I.

Expand Down Expand Up @@ -125,9 +125,10 @@ NOTE: All the recorded files will be saved on the desktop. Make sure that the fi
* "***podcast***". This will redirect you to "CastBox" which is a good source of podcasts.
* "***calculator***". This will open Calculator.
* "***exit/over/close/stop*** to exit BENJI.
* "***get tweets***" get latest 10 tweets from timeline. For this an app is to be registered at https://apps.twitter.com/ (if confused, have a look at https://spring.io/guides/gs/register-twitter-app/). A new file named "twitterCredentials.py" is to be made in the windows folder. Save the consumer key, consumer secret, access token, access token secret with the names consumer_key, consumer_secret, access_token, access_secret repectively in the "twitterCredentials.py"


* "***get tweets***" Get latest 10 tweets from timeline. For this an app is to be registered at https://apps.twitter.com/ (if confused, have a look at https://spring.io/guides/gs/register-twitter-app/). A new file named "twitterCredentials.py" is to be made in the windows folder. Save the consumer key, consumer secret, access token, access token secret with the names consumer_key, consumer_secret, access_token, access_secret repectively in the "twitterCredentials.py". Speak/type "get tweets" and top 10 tweets will be shown, also when and by whom it was created.
* Get latest 10 tweets done by the user. Speak/type "get my tweets" and top 10 tweets done by the user(you) will be shown with the time when it was tweeted
* You can get a list of everyone you follow from twitter by saying "get list of people I follow on twitter"

>In cases where the commands are separated by '/', use any one of the mentioned commands
>For example, use either ***What is your name*** or ***Identify Yourself*** or ***Who are you***. Don't type all of them at once.
Expand Down
20 changes: 16 additions & 4 deletions windows/benji.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,22 @@ def events(frame,put):
auth = OAuthHandler(twitterCredentials.consumer_key, twitterCredentials.consumer_secret)
auth.set_access_token(twitterCredentials.access_token, twitterCredentials.access_secret)
api = tweepy.API(auth)

for status in tweepy.Cursor(api.home_timeline).items(10):
print("\n", status.text)
print("By ", status.user.screen_name, " at ", status.user.created_at)
if link[-2] == "my":
for tweet in tweepy.Cursor(api.user_timeline).items(10):
print("\n", json.dumps(tweet.text))
print("on ", tweet.created_at)
elif link[1] == "tweets":
for status in tweepy.Cursor(api.home_timeline).items(10):
print("\n", status.text)
print("By ", status.user.screen_name, " at ", status.user.created_at)

#Get friends from twitter
elif link[-3] == "follow" and link[-1] == "twitter":
auth = OAuthHandler(twitterCredentials.consumer_key, twitterCredentials.consumer_secret)
auth.set_access_token(twitterCredentials.access_token, twitterCredentials.access_secret)
api = tweepy.API(auth)
for friend in tweepy.Cursor(api.friends).items():
print("\nName: ", json.dumps(friend.name), " Username: ", json.dumps(friend.screen_name))

#Screenshot
elif put.startswith('take screenshot') or put.startswith("screenshot"):
Expand Down

0 comments on commit 5581bdf

Please sign in to comment.