A bot that looks up teams and players for Collegiate Starleague Dota2 and provides draft information.
Currently deployed for Discord and previously deployed for Slack.
Complete details in cli.py but here is a TLDR.
Tangybot Interacts with the user similar to a command line interface(CLI). There is functionality for looking up teams,
lookup ([--last] | <team_number>)
and looking up individual players through their steam profiles
profile ([--last] | [user_1, user_2, ...]) [--num_games (100)]
[--max_heroes (5)] [--min_games (5)] [--tourney_only]
These instructions will help you get a copy of this project on your local machine. You will need the following minimum prerequisites:
- A steam API key
Though if you desire additional functionality, you will need more. Additional prerequisites are defined in each of the respective sections below:
- Clone this repository
- Install the requirements. Run
pip install -r requirements.txt, optionally in a virtual environment - Set your steam key as an environment variable. In bash, this can be done like
export STEAM_KEY=YOUR_KEY_HERE, and in anaconda for windows you can useset STEAM_KEY=YOUR_KEY_HERE - TangyBot can be directly invoked from the command line, via
python cli.py [args]. Try a basic query, likepython cli.py lookup 839to look up the University of Michigan
If you wish to run the bot in a Discord server, you will also need the following for setting up (any) Discord bot.
- Discord client ID
- Discord bot token
- Set the environment variables for the bot's token and client id. Similar to above, this is done via
export DISCORD_CLIENT_ID=YOUR_BOT_IDandexport DISCORD_TOKEN=YOUR_BOT_TOKEN - Test the bot by running
python discord_bot.py file. You should see the bot reply withTangy Bot Startand you should be able to invoke TangyBot in Discord. Test it out by typing (in a channel the bot can access)@TangyBot lookup 839to try and lookup the University of Michigan again
One feature of Heroku is its ephemeral filesystem, which means that any changes to files are erased upon restarting dynos. This does not play well with the information that Tangy Bot wants to cache, so if you are deploying to an ephemeral filesystem, you may want to use the AWS backend instead of the standard file backend.
We decided to use AWS' DynamoDB due to being free forever (as far as we are aware) for smaller workloads, while still being reliable. Thus, you will need the following for using the AWS backend:
- AWS Access Key
- AWS Secret Access Key
The default region is hardcoded as us-east-2 for the moment, since it seems difficult to specify within Heroku.
- Configure AWS on your computer
- Set up DynamoDB tables. Specifically, TangyBot is looking for tables named
TangyBot_SessionandTangyBot_Profile - When launching the discord bot, do so via
python discord_bot.py aws.cli.pycurrently does not support the backend
IDK create a pull request I guess. Formatting is not really strict PEP8, but do at least try to follow the general ideas.
If you want to create a new command in TangyBot that is invoked in the format TangyBot command [args] you will need to modify the following files:
- cli.py: add support for the new command inside TangyBotArgParse, i.e.
self.subparses.add_parser()then configure it appropriately as you would any other argument parser. - backend.py: create a new function with the following signature inside TangyBotBackend:
async def command_name(self, your_kwargs, that_you_want, username="user", **_). The kwargs that you want should be the same as those that you have defined inside cli.py;usernameis the user that is making the request, and the additional**_is required to ensure that no unexpected kwargs (such ascommand) are received and python doesn't complain. - frontend.py: create a new function with the following signature inside FrontendFormatter:
def command_name(self, backend_kwargs, that_you_want):where the arguments are those that you have returned from the backend. For example, if your backend command returned a dict in the format{name: ...}you would usenameas the argument.
See also the complete list of contributors who have participated in this project