From 8a80b016114bc263f883481edcc0713c7e9d602f Mon Sep 17 00:00:00 2001 From: Charles Edward Baiden Date: Sat, 1 Aug 2020 14:28:07 -0400 Subject: [PATCH 1/9] base code --- .idea/.gitignore | 3 ++ .idea/TreePlanting_Draft.iml | 8 +++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++ .idea/misc.xml | 7 ++++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ __pycache__/credentials.cpython-37.pyc | Bin 0 -> 410 bytes __pycache__/models.cpython-37.pyc | Bin 0 -> 513 bytes credentials.py | 4 +++ main.py | 33 ++++++++++++++++++ models.py | 8 +++++ index.html => templates/index.html | 4 ++- 12 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/TreePlanting_Draft.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 __pycache__/credentials.cpython-37.pyc create mode 100644 __pycache__/models.cpython-37.pyc create mode 100644 credentials.py create mode 100644 main.py create mode 100644 models.py rename index.html => templates/index.html (94%) 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 0000000000000000000000000000000000000000..4c5fb18b314793ce9b2215db8744a4640bdbfb7d GIT binary patch literal 410 zcmX|7O;5r=5G`MZ5Q!Hr-o0?Zl$I81j1j0i*;F;gp9 zCx#3LeJJ1tKS*75D1$Lr&C*d9yvK^^|L{EH5@1oY-VJNoq=xz}I;rTt2A--<@ct)81Yqc`Y-H Freedom Forest - + + + From 07ae0f50a3b2ede32bd0e8a96eaa9172ec5d9f3a Mon Sep 17 00:00:00 2001 From: leesel <30633157+leesel@users.noreply.github.com> Date: Sat, 1 Aug 2020 14:36:09 -0400 Subject: [PATCH 2/9] Update index.html --- templates/index.html | 155 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 54103a4..a4c819a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,8 +3,161 @@ Freedom Forest - +<-- --> + From 51fc7607dba50ac286478bb22b5a4a5001839dc4 Mon Sep 17 00:00:00 2001 From: Charles Edward Baiden Date: Sat, 1 Aug 2020 14:42:58 -0400 Subject: [PATCH 3/9] update --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index a4c819a..f97b58f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,7 +3,7 @@ Freedom Forest -<-- --> + From 3bbc5dc03f1ac2445ae8721432b11baebbae0323 Mon Sep 17 00:00:00 2001 From: leesel <30633157+leesel@users.noreply.github.com> Date: Sat, 1 Aug 2020 15:47:39 -0400 Subject: [PATCH 7/9] Update tree.html --- templates/tree.html | 153 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 1 deletion(-) diff --git a/templates/tree.html b/templates/tree.html index 56ff9f2..893ea95 100644 --- a/templates/tree.html +++ b/templates/tree.html @@ -5,7 +5,158 @@ From d79a0df61fa5dfb52e8939333917c3b964eef81a Mon Sep 17 00:00:00 2001 From: Charles Edward Baiden Date: Sun, 2 Aug 2020 00:16:50 -0400 Subject: [PATCH 8/9] Update main.py --- main.py | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 9fec959..6f27e7f 100644 --- a/main.py +++ b/main.py @@ -16,13 +16,12 @@ 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) +#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) -c = p_tweets[0].text #val = accounts['PJ'] #print(val.tweet_text) @@ -32,16 +31,35 @@ def hello_world(): return render_template('index.html') @app.route('/tree') -def tree_page(value): - val = "Charles" - return '{}'.format(value) - -@app.route('/test') -def test(): - for val in p_tweets: - g = tree_page(value=val) - return g - return +def tree_page(): + return render_template('tree.html') + +for tweet in tweepy.Cursor(api.search,q = "I am cancer free", 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 = "Congrats, we are so happy to hear that " + #congrats = status + link_tweet + #api.update_status(congrats) + + if 'RT' not in tweet.text: + username = tweet.author.screen_name + text = tweet.text + + print([username, text]) + + + + + + + + + + + + + if __name__ == '__main__': From a919acee33c5da854c58be64d965f8e807452c36 Mon Sep 17 00:00:00 2001 From: CaroCardozo Date: Sun, 2 Aug 2020 10:31:50 -0500 Subject: [PATCH 9/9] Add a direct message Add a direct message to the user adding the tweet that we are refering to, congratulating them and letting them know they have a virtual tree. Also change the tweet text to a more warm one and descomment the main part. --- main.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 6f27e7f..fc92c0c 100644 --- a/main.py +++ b/main.py @@ -34,19 +34,22 @@ def hello_world(): def tree_page(): return render_template('tree.html') -for tweet in tweepy.Cursor(api.search,q = "I am cancer free", 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 = "Congrats, we are so happy to hear that " - #congrats = status + link_tweet - #api.update_status(congrats) - +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: - username = tweet.author.screen_name - text = 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]) + #print([username, text])