The script logs an account’s total karma and dynamically generates a chart with the data it’s collected. Below is an example using data collected from /u/GallowBoob – a Redditor who’s infamous for his high karma count. The chart is showing data that was collected every minute for over 3 months.
Setup
1. Clone the repo
git clone https://github.com/paramt/trackarma.git
2. Install dependencies
pip install praw
pip install matplotlib
3. Configure PRAW
- Create a new app on Reddit
- Follow this link
- Click
create new app
- Choose
personal use script
- Add a name and description
- Click
create app
and copy the ID and secret
- Create a file named
praw.ini
inside the repo - Make a new configuration that looks like this
[Bot] client_id=[YOUR APP ID] client_secret=[YOUR APP SECRET] user_agent=Karma Tracker Bot 1.0
4. Configure Trackarma
- Open
constants.py
- Change the value of
reddit_name
to the username you’re tracking - Optionally, you can change other constants there (like the chart’s title)
5. Set up a scheduled task
Run sudo python src/collect_data.py
at a constant interval using Crontab on Linux or Task Scheduler on Windows.
To generate the chart, run sudo python src/generate_chart.py
. The live example is running both commands every minute, but you may choose to run them at any interval
Output
The script will output everything in data/
chart.png
– a line graph displaying the Redditor’s karma over timekarma-total.txt
– a record of the Redditor’s karma over time, separated with newlineskarma-delta.txt
– a record of the Redditor’s karma gain over time, separated with newlines
License
This project is licensed under the MIT license. You are free to use, modify, and distribute the source code as long as you include the original license file.