Skip to content
πŸ™πŸ˜πŸ¦πŸ‰ Explaining cards in reddit.com/r/hearthstone
Branch: master
Clone or download
Latest commit 7848d6d May 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data add Zayle, Shadow Cloak May 15, 2019
logo add logo without whitespace Apr 23, 2019
.gitattributes
.gitignore add KFT release cards and extended card description Aug 8, 2017
LICENSE Initial commit Apr 10, 2016
README.md Update README.md Apr 22, 2019
cardDB.py add KFT release cards and extended card description Aug 8, 2017
card_json_form.html Rise of Shadows, Dragon and TopDeck Link Mar 14, 2019
commentDB.py force named parameters Jul 6, 2017
constants.py fix reply sometimes containing less than 7 cards. fixes #5 Nov 26, 2018
credentials.py.example adds user blacklist to not answer mtg bot May 14, 2018
formatter.py finish RoS release Apr 10, 2019
hearthscan-bot.py remove verbose log message May 5, 2019
helper.py fix reply sometimes containing less than 7 cards. fixes #5 Nov 26, 2018
praw.ini.example rewrite for praw 4 Mar 23, 2017
praww.py answer own submissions (posts not comments) Apr 10, 2019
requirements.txt adds requirements.txt Mar 25, 2018
scrape.py finish RoS release Apr 10, 2019
selfPost.py add simple self-post script to post changelog to bot profile Mar 14, 2019
start.sh initial open source commit Apr 10, 2016
test.py Rise of Shadows, Dragon and TopDeck Link Mar 14, 2019

README.md

hearthscan-bot

Explaining cards in reddit.com/r/hearthstone.
To see the bot in action send a PM containing [[Ragnaros]] to /u/hearthscan-bot

Requirements

  • tested on Python 3.4+
  • Python libraries: requests, praw, lxml
  • Reddit API id, secret and refresh-token

Tests

To run the offline unit tests; clone this repo and:

pip install -r requirements.txt

copy credentials.py.example credentials.py
copy praw.ini.example praw.ini
python3 test.py

To run the full tests, prepare your own credentials.py and praw.ini and start tests using python3 test.py online.
The test creates a test.log.

Running the bot

Make sure the online test is successful!
I use the start.sh on my PI to run in background.
If you want to start it without script, no parameters are required to start it (python3 hearthscan-bot.py).
The script pipes startup errors to std.txt and err.txt. The bot logs to bot.log once it is running.

There are JSON files included in this repository. If you want current data you can always recreate them using scrape.py.

While the bot is running, you can teach it new cards without stopping it. Create or edit tempinfo.json in the data-directory or edit it in this git repository.

Delete the lockfile.lock or kill it on Linux to stop the bot gracefully.

Learning from this bot

A good starting point is hearthscan-bot.py/main(). I've tried to comment the code and use consistent, self explaining names.
There are nice people out there answering questions (/r/learnpython, /r/redditdev) and the PRAW documentation is decent.

License

All code contained here is licensed by MIT.

You can’t perform that action at this time.