Skip to content

Commit

Permalink
our first working prototype
Browse files Browse the repository at this point in the history
Co-authored-by: qrshivani <[email protected]>
  • Loading branch information
eldinesh and qrshivani committed Feb 18, 2022
1 parent 475ef87 commit 2adb279
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 18 deletions.
Binary file added __pycache__/auth.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/manage.cpython-310.pyc
Binary file not shown.
31 changes: 19 additions & 12 deletions auth.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import tweepy
def auth():
import tweepy

consumer_key = "QS9Vk6mSmKTri97Oz4yNuY3sH"
consumer_secret = "szyiAlz9d0i5PmGEEEkukeyReDYHrFEgaMW2kTkytaqI1W2lH0"
callback= "oob"
consumer_key = "QS9Vk6mSmKTri97Oz4yNuY3sH"
consumer_secret = "szyiAlz9d0i5PmGEEEkukeyReDYHrFEgaMW2kTkytaqI1W2lH0"
callback= "oob"

oauth1_user_handler = tweepy.OAuth1UserHandler(
consumer_key, consumer_secret,
callback)
oauth1_user_handler = tweepy.OAuth1UserHandler(
consumer_key, consumer_secret,
callback)

print(oauth1_user_handler.get_authorization_url(access_type='write'))
print("Visit this link to generate 6-digit PIN: ", oauth1_user_handler.get_authorization_url(access_type='write'))

verifier = input("Input PIN: ")
access_token, access_token_secret = oauth1_user_handler.get_access_token(verifier)
verifier = input("Input PIN: ")
access_token, access_token_secret = oauth1_user_handler.get_access_token(verifier)

api = tweepy.API(oauth1_user_handler)
with open("credentials.yaml", "w") as f:
f.write("access_token: {}\n".format(access_token))
f.write("access_token_secret: {}\n".format(access_token_secret))

print(api.verify_credentials().screen_name)
api = tweepy.API(oauth1_user_handler)

print("Signed in as: ", api.verify_credentials().screen_name)

return api
2 changes: 2 additions & 0 deletions credentials.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
access_token: 1216406244358901760-hhvrs0sFgkaEDVs3HBYQAPCY5HuG7M
access_token_secret: 8PFieUa4Xf4AIxCSrRq6FAamcntWuHGmXvsDZUTrEIPed
9 changes: 3 additions & 6 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
def new_tweeet(text):
def new_tweeet(text, api):
api.update_status(status = text)

def del_tweet(id):
def del_tweet(id, api):
api.destroy_status(id)





31 changes: 31 additions & 0 deletions twimanage.py
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
import tweepy
import yaml

from auth import *
from manage import *


print("Welcome to Twimanage! This is a simple Twitter management tool. /n")

# Load credentials and authenticate
try:
api = auth()
print("Authentication successful!")

except:
print("Authentication failed! Please check your credentials.yaml file.")
exit()

user_choice = (int(input("1. New Tweet\n2. Delete Tweet(Needs Tweed ID)\n3. Quit\n>>>")))
if user_choice == 1:
tweet = input("What would you like to tweet? ")
new_tweeet(tweet, api)
print("Tweet sent!")

elif user_choice == 2:
id = input("What is the ID of the tweet you want to delete? ")
del_tweet(id, api)
print("Tweet deleted!")

elif user_choice == 3:
print("Goodbye!")
exit()

0 comments on commit 2adb279

Please sign in to comment.