diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/TreePlanting_Draft.iml b/.idea/TreePlanting_Draft.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/TreePlanting_Draft.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ba24381 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6c455c2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/__pycache__/credentials.cpython-37.pyc b/__pycache__/credentials.cpython-37.pyc new file mode 100644 index 0000000..4c5fb18 Binary files /dev/null and b/__pycache__/credentials.cpython-37.pyc differ diff --git a/__pycache__/models.cpython-37.pyc b/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..b373561 Binary files /dev/null and b/__pycache__/models.cpython-37.pyc differ diff --git a/credentials.py b/credentials.py new file mode 100644 index 0000000..c30e10e --- /dev/null +++ b/credentials.py @@ -0,0 +1,4 @@ +consumer_key = 'TDdNFe5s13NzbKODdSdhXzQB9' +consumer_secret = 'bLT2ZkPdQWsrltidAO6tRVAvuHz9zDrT07adgzf5Pk5fVEMcSP' +access_key = '1003611264029949953-3TngjKNkbUMWM7iMMaInWFCKW7qXe5' +access_secret = '8iPyOCu6kmyBKxhyim8mHBMbY2yJWtd3HdvXiyd3ziv6Q' diff --git a/index.html b/index.html deleted file mode 100644 index bcac812..0000000 --- a/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - Freedom Forest - - - - - -
-
-

Freedom Forest

-

Here, we love to uplift and celebrate you winning the hardest health battles!

- See Your Tree -
-
- - - -
-
- -

🦾 Congratulations on your defeat!

-

FreedomForest aims to uplift and be a part of welcoming you to your new beginning.

-

sampletextt sampletextt sampletextt sampletextt

-

sampletextt sampletextt sampletextt sampletextt

-
-
- -
-
-

Stay Connected

-

Send a positive note to recent warriors.

- Twitter - Donate to AIDS - Help Prevent Cancer - Email -
-
- - - - diff --git a/main.py b/main.py new file mode 100644 index 0000000..fc92c0c --- /dev/null +++ b/main.py @@ -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() + diff --git a/models.py b/models.py new file mode 100644 index 0000000..90b8694 --- /dev/null +++ b/models.py @@ -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 diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..f97b58f --- /dev/null +++ b/templates/index.html @@ -0,0 +1,212 @@ + + + + Freedom Forest + + + + + + + +
+
+

Freedom Forest

+

Here, we love to uplift and celebrate you winning the hardest health battles!

+ See Your Tree +
+
+ + + +
+
+ +

🦾 Congratulations on your defeat!

+

FreedomForest aims to uplift and be a part of welcoming you to your new beginning.

+

sampletextt sampletextt sampletextt sampletextt

+

sampletextt sampletextt sampletextt sampletextt

+
+
+ +
+
+

Stay Connected

+

Send a positive note to recent warriors.

+ Twitter + Donate to AIDS + Help Prevent Cancer + Email +
+
+ + + + diff --git a/templates/tree.html b/templates/tree.html new file mode 100644 index 0000000..893ea95 --- /dev/null +++ b/templates/tree.html @@ -0,0 +1,211 @@ + + + + See Your Tree + + + + + + +
+
+

See Your Tree

+

See yourself as a new plant in a larger garden of other overcomers!

+ Search by Twitter Username +
+
+ + + +
+
+ +

Find your tree below!

+

+

+

+
+
+ +
+
+

Stay Connected

+

Send a positive note to recent warriors.

+ Twitter + Donate to AIDS + Help Prevent Cancer + Email +
+
+ + + +