diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100755 index 0000000..9748b85 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,31 @@ +## How to contribute to College Football Risk + +#### **Did you find a bug?** + +* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/cfbd/college-risk/issues). + +* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/cfbd/college-risk/issues/new?assignees=bluescar). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring. + +#### **Did you write a patch that fixes a bug?** + +* Open a new GitHub pull request with the patch. + +* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. + +#### **Did you fix whitespace, format code, or make a purely cosmetic patch?** + +Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of College Football Risk will generally not be accepted. + +#### **Do you intend to add a new feature or change an existing one?** + +* Suggest your change by reaching out to me via [email](mailto:admin@collegefootballdata.com) or [Twitter](https://twitter.com/CFB_Risk) and start writing code. + +* Do not open an issue on GitHub until you have collected positive feedback about the change. GitHub issues are primarily intended for bug reports and fixes. + +#### **Do you have questions about the source code?** + +* Please do reach out to me via [email](mailto:admin@collegefootballdata.com) or [Twitter](https://twitter.com/CFB_Risk) with any questions you may have. + +Thanks! + +BlueSCar \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100755 index 0000000..bb4e528 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,32 @@ + + +## Description + + +## Motivation and Context + + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Types of changes + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) + +## Checklist: + + +- [ ] My code follows the code style of this project. +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. + + + +@BlueSCar \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..c36428a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 CFBD + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..799b8eb --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Risk Python Scripts +This repo is intended to to be a library of generic Python scripts for College Football Risk. The primary purpose is to give leadership of teams appropriate resources to organize and recruit, particularly if the team has lacked much organization in the past. + +## General Reddit Notification (general_reddit_notification.py) + +This script can be used to send out a general notification via reddit PMs. The script requires a CSV files which it uses to read the list of players to message. The CSV file should contain at least one column of valid reddit usernames with a "player" header. + +This script is fault tolerant and will continue to process the batch of players, even if one of the messages fails. The script will output two text files denoting which players were successfully messages and which failed. + +Required fill ins: + +* CLIENT_ID - Reddit client id obtained from the Reddit development console +* CLIENT_SECRET - Reddit client secret obtained from the Reddit development console +* APP_NAME - used in the user-agent string and must be unique +* APP_VERSION - used in the user-agent string +* USERNAME - Username of account used for sending PMs +* PASSWORD - Password of account used for sending PMs +* TEAM - Name of team +* PLACE_MESSAGE_HERE - Contents of message \ No newline at end of file diff --git a/general_reddit_notification.py b/general_reddit_notification.py new file mode 100644 index 0000000..1b393d7 --- /dev/null +++ b/general_reddit_notification.py @@ -0,0 +1,46 @@ +import pandas as pd +import praw + +reddit = praw.Reddit(client_id='CLIENT_ID', + client_secret='CLIENT_SECRET', + user_agent='User-Agent: web:APP_NAME:vAPP_VERSION (by /u/USERNAME)', + username='USERNAME', + password='PASSWORD') + +# requires a populated CSV file with a 'player' column +df = pd.read_csv('./players.csv') +players = list(df['player']) + +successfully_messaged = [] #initializes empty list for users successfully messaged +failed_to_message = [] #empty list for users not messaged + + +for player in players: + try: + reddit.redditor(player).message('Join TEAM Risk today!', ''' +Greeetings {0}! + +  + +PLACE_MESSAGE_HERE + +  + +You will receive no further messages from us. Hope you join us! + +TEAM Risk Leadership + '''.format(player)) + print(player + ' messaged successfully!') + successfully_messaged = successfully_messaged + [player] + except: + print("Error in messaging user " + player) + failed_to_message = failed_to_message + [player] + +# output successes and failures to separate text files +with open('successes.txt', 'w') as f: + for item in successfully_messaged: + f.write("%s\n" % item) + +with open('failures.txt', 'w') as f: + for item in failed_to_message: + f.write("%s\n" % item) \ No newline at end of file