Coder Social home page Coder Social logo

pennydreadfulmtg / penny-dreadful-tools Goto Github PK

View Code? Open in Web Editor NEW
38.0 8.0 28.0 51.34 MB

A suite of tools for the Penny Dreadful MTGO community

Home Page: https://pennydreadfulmagic.com

License: MIT License

Python 84.60% Shell 0.03% HTML 3.78% JavaScript 4.76% PLpgSQL 0.09% Mako 0.03% Dockerfile 0.07% Mustache 6.64% Procfile 0.01%
magic-the-gathering mtgo hacktoberfest

penny-dreadful-tools's Introduction

Penny Dreadful Tools

Repository for the tools used by the Penny Dreadful Community.

View individual subdirectories for details

Build Status Uptime Robot status

Modules

analysis is for Magic Online game log analysis.

decksite is the code for pennydreadfulmagic.com.

discordbot is the Discord chatbot.

github_tools are some GitHub integration utillities.

logsite is the code for logs.pennydreadfulmagic.com.

logsite_migrations are alembic database migrations for logsite.

magic is for information about Magic – cards, decklists, card images, legality, etc.

maintenance is for useful scripts, usually run via cron.

modo_bugs is for integration with https://github.com/PennyDreadfulMTG/modo-bugs/issues.

price_grabber builds a database of card prices.

rotation_script is for the script that handles Penny Dreadful rotation (card legality changes each season).

shared contains a bunch of general purpose helper classes. Things that could be used in any project.

shared_web contains a bunch of web-specific helper classes. It also contains our React code for "live" data tables.

Contributing

Contributions are very welcome. Please join the Discord at https://pennydreadfulmagic.com/discord/ and feel free to ask questions in #code.

Development Environment Setup

If you plan on running things outside of the containers (eg: dev.py or logsite):

Configuring Environment

  • Add a bot at https://discordapp.com/developers/applications/me
  • Add a bot user for the bot
  • Add the bot to your server with https://discordapp.com/oauth2/authorize?client_id=<your client id here>&scope=bot
  • Go to the Bot section.
  • Click to reveal the token (not secret) on https://discordapp.com/developers/applications/me
  • Copy .env.example to .env and alter the value for "token" to this value. (or to "token" in config.json if not in docker setup)
  • Do the same for the discord client_id and client_secret
  • Optionally take a look at shared/configuration.py and enter any required non-default information into .env
  • You will want to investigate the various targets in dev.py that acts as a Makefile. Some of these utilities use GitHub's commandline git-enchancer, hub: https://github.com/github/hub

Manual Development Environment Setup (Non-docker instructions)

  • Install MariaDB 10.0+
  • Install python 3.10
  • Install pipenv
  • Install npm
  • git clone https://github.com/PennyDreadfulMTG/Penny-Dreadful-Tools.git
  • cd Penny-Dreadful-Tools
  • pipenv install
  • pipenv run python build.py
  • Using the values from your .env issue the following commands in MySQL (you don't need to create the databases):
    • CREATE USER '<mysql_user>'@'<mysql_host>' IDENTIFIED BY '<mysql_passwd>';
    • GRANT ALL ON <decksite_database>.* TO '<mysql_user>'@'<mysql_host>'; GRANT ALL ON <decksite_test_database>.* TO '<mysql_user>'@'<mysql_host>';
    • GRANT ALL ON <prices_database>.* TO '<mysql_user>'@'<mysql_host>';
    • GRANT ALL ON <magic_database>.* TO '<mysql_user>'@'<mysql_host>';
    • GRANT ALL ON <logsite_database>.* TO '<mysql_user>'@'<mysql_host>';
  • Download a copy of the production decksite database (with personal information stripped):
    • mysql -u <mysql_user> -p<mysql_passwd> -e "CREATE DATABASE <decksite_database>"
    • curl https://pennydreadfulmagic.com/static/dev-db.sql.gz >/tmp/dev-db.sql.gz
    • gunzip /tmp/dev-db.sql.gz
    • mysql -u <mysql_user> -p<mysql_passwd> <decksite_database> </tmp/dev-db.sql
    • mysql -u <mysql_user> -p<mysql_passwd> -e "CREATE DATABASE <decksite_test_database>"
  • Some very minor parts of the bot (the "modofail" command) use libopus and ffmpeg which are not in pip and must be installed in a your-OS-specific way separately. Very optional.

Running Decksite (pennydreadfulmagic.com)

Running Logsite (logs.pennydreadfulmagic.com)

Running Discordbot

  • pipenv run python run.py discordbot
  • Visit your Discord server.

Running the tests

There are various levels of granularity but in general use you want:

  • pipenv run python dev.py test # Runs the unit tests, type checking, lint.

Check the dev.py source code for the full set of options including unit, types, lint (covered by test above) as well as functional (integration tests), perf (performance tests). release will take you all the way from your committed change to a PR via the tests (needs GitHub's commandline gh/hub installed).

Working on React components

  • Run logsite
  • pipenv run python dev.py watch # Builds bundle.js after every file change.

penny-dreadful-tools's People

Contributors

adambiltcliffe avatar aurous avatar bakert avatar binaryswordsman avatar bors[bot] avatar clates avatar codyjasonbennett avatar dependabot-preview[bot] avatar dependabot[bot] avatar eightbitellie avatar github-actions[bot] avatar jgabrielygalan avatar kalioc avatar kzcheng avatar lokrium avatar md822 avatar mergify[bot] avatar mmrsad avatar mvousden avatar pre-commit-ci[bot] avatar pseudodude avatar pysean avatar pyup-bot avatar requires avatar silasary avatar snyk-bot avatar tsutton avatar volvary avatar vorpal-buildbot avatar wizzerinus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

penny-dreadful-tools's Issues

Potentially delete/redownload old images

Between new card images coming out (in better quality), and card combos that will never be used again, it might be worth deleting some of the older images that are accruing in the cache.

Let's think about ways to do that.

Fix database Release Date

  • We don't convert date to seconds-since-epoch but we have release_date as an INTEGER type. sqlite will let us insert it anyway but that's hella broken.

Multiverse ID is not correctly populated

multiverse_id = cards[0].multiverse_id is not working with cards retrieved from the db so fallback images will fail. Multiverse id doesn't seem to be populated in the db.

NOT doesn't work entirely correctly in !search

There's a bug when the first part of a query is NOT. NOT in general is a little broken and could be replaced by '-' as per magidex. -- do_test('NOT c:g', 'NOT (id IN (SELECT card_id FROM card_color WHERE or_id = 5))')

Standardize quotes

  • Standardize on single quotes except where single quotes are contained within the string.

!Random tweaks

  • Random should take a numeric argument and default to 1.

Create database more efficiently

Build server takes an hour to create the database so switch to an executeMany or even just big long INSERTs with many entries.

Normalize Image sizes

  • EMN and other smaller images look stupid when joined. Normalize size before joining on the image server.

Support :10:, :UU:, :2W: emojis

@binarySwordsman has added :00:, :10:, :11:, :12:, :13:, :15:, :16:, :01:, :2B:, :2G:, :2R:, :2U:, :2W:, :02:, :03:, :04:, :05:, :06:, :07:, :08:, :09:, :BG:, :BP:, :BR:, :BB:, :CC:, :EE:, :GP:, :GU:, :GW:, :GG:, :RG:, :RP:, :RW:, :RR:, :SS:, :TT:, :UB:, :UP:, :UR:, :UU:, :WB:, :WP:, :WU:, :WW:, :XX:

The rule is "remove curly braces and slashes. If single letter, double up. If single number prepend with 0."

Note there is currently no emoji for {E} (Energy), {Y}, {Z}, {Q} (untap), {P} (generic Phyrexian mana, only on one card's rules text), {20} (only in one card's rules text), nor any of the un-set specific symbols - {100}, {1,000,000}, {∞}, {hr}, {½}, {hw}.

Fuzzy matching

[Ad Nauseum] should load Ad Nauseam. [all sun's dawn] and [all suns dawn] should load All Suns' Dawn.

Providing the full name of Split Cards [Fire // Ice] doesn't work

  • Split cards. The bot expects one half [Fire] or the other [Ice] but the image server expects both. So either the bot doesn't respond or if it does it doesn't get an image. We should support: [Fire], [Fire / Ice] and [Fire // Ice] and variations ignoring whitespace.

Local mode

  • Add --local commandline option that causes the bot to run locally and receive commands from commandline instead of (as well as?) connecting to discord.

Zero Byte uploads

  • As of Sep 26th we are still uploading zero byte files sometimes despite the checks we have -- what's going on?

Support negation operation in !search (for example "c!rug")

c!rug is not yet supported. do_test('(c!rug OR c:c) "Beyond lies the wub" o:trample', "((cost LIKE '%rug%') OR (cost LIKE '%c%')) AND (name LIKE '%Beyond lies the wub%' OR type LIKE '%Beyond s the wub%' OR text LIKE '%Beyond lies the wub%') AND (text LIKE '%trample%')");

Form help text programatically from list of commands

As more commands get added they should automatically appear in help.

At one extreme of this kind of approach is docopt (see http://docopt.org/) which is, let's be honest, amazing.

A simple solution would be to have a command-making class or function that expects a name and a string description and we use that for all commands.

Reduce Max file length

  • Max 255 chars for filename length is cutting it too fine given that we have to add an extension so cut off at a lower number.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.