Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/TreePlanting_Draft.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added __pycache__/credentials.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/models.cpython-37.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
consumer_key = 'TDdNFe5s13NzbKODdSdhXzQB9'
consumer_secret = 'bLT2ZkPdQWsrltidAO6tRVAvuHz9zDrT07adgzf5Pk5fVEMcSP'
access_key = '1003611264029949953-3TngjKNkbUMWM7iMMaInWFCKW7qXe5'
access_secret = '8iPyOCu6kmyBKxhyim8mHBMbY2yJWtd3HdvXiyd3ziv6Q'
57 changes: 0 additions & 57 deletions index.html

This file was deleted.

70 changes: 70 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import tweepy
import credentials
from models import UserTree
from flask import Flask, render_template, json


app = Flask(__name__)

auth = tweepy.OAuthHandler(credentials.consumer_key, credentials.consumer_secret)
auth.set_access_token(credentials.access_key, credentials.access_secret)
api = tweepy.API(auth)


p_tweets = api.search("I beat cancer")

accounts = {}


#for tweet in p_tweets:
#userInstance = UserTree(tweet.author.screen_name, tweet.author.name,
#tweet.author.profile_image_url, tweet.text, tweet.author.created_at)
#accounts[tweet.author.name] = userInstance
#print(tweet.text)


#val = accounts['PJ']
#print(val.tweet_text)

@app.route('/')
def hello_world():
return render_template('index.html')

@app.route('/tree')
def tree_page():
return render_template('tree.html')

q = ["I am cancer free", "beat it"]
for tweet in tweepy.Cursor(api.search, q , result_type = "recent", include_entities = False, include_rts = False, tweet_node = "extended").items(25):
id_tweet = tweet._json['id']
username_tweet = tweet._json['user']['screen_name']
link_tweet = "https://twitter.com/" + str(username_tweet) + "/status/" + str(id_tweet)
status = "Congratulations! We are so happy to hear that, come to our website to meet your own virtual tree "
congrats = status + link_tweet
user_id = tweet._json['user']['id']
#text = tweet.text
#username = tweet.author.screen_name

if 'RT' not in tweet.text:
api.update_status(congrats)
api.send_direct_message(user_id, text = "We are so happy and proud that you win this battle with cancer. For that, we want to honor you with a virtual tree on your name, you can visit it on our website. You deserve it. "+ link_tweet)

#print([username, text])















if __name__ == '__main__':
app.run()

8 changes: 8 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class UserTree:

def __init__(self, name, username, picture, tweet_text, date):
self.name = name
self.username = username
self.picture = picture
self.tweet_text = tweet_text
self.date = date
Loading