Skip to content

viclai/bracket-buster

Repository files navigation

Bracket Buster

Synopsis

Bracket Buster is a personal project in development which allows users in a chat application, namely HipChat, to fill out March Madness 🏀 brackets, and see how their predictions match up with the final results as more March Madness games are played during the season. HipChat users can install this bot, or add-on, in a chat room and fill out a bracket without having to sign up for a separate account as sites like ESPN require you to.

Installation

To install this add-on, first log into your HipChat account. Then, go to the integrations settings. At the bottom of the page, click on Install an integration from descriptor URL. Enter the descriptor URL as https://bracket-buster.herokuapp.com/atlassian-connect.json. Then select a chat room to install this add-on in. To complete the installation process, accept the scopes of the add-on. You should get a message in your HipChat room confirming that the add-on was installed.

Development

To develop this add-on and run it locally, first download or clone this repository. Then, make sure that you have the following software installed on your machine.

To be able to make this add-on accessible to the HipChat server from your local machine, open a tunnel with ngrok by executing the following command in a terminal or command prompt.

ngrok http 3000

Then, copy the HTTPS forwarding URL generated by ngrok and open a new terminal or command prompt to paste it into the config.json file in the project folder as the value of the localBaseUrl key under the development environment. Once that is saved, enter the following commands to install the dependencies and start the add-on.

npm install
node app.js

Then, install this add-on in your HipChat room as a private integration by providing the descriptor URL as the HTTPS URL generated by ngrok. Refer to the steps in the Installation section for more details.

Refer to the HipChat Connect guides and HipChat API reference for more information on how to develop this HipChat add-on.

Developer Notes

Data

The following is a general format of the object that is passed as context to render the HTML for the dialog box.

{
    "bracketData" : {
        "state" : {
            "unavailable" : true,
            "available"   : false,
            "set"         : false
        },
        "empty_bracket" : "A stringified object representing an empty bracket",
        "regions" : {
            "region1" : {
                "name" : "east",
                "1st Round" : [
                    {
                        "result" : {
                            "team1" : {
                                "seed"  : 1,
                                "name"  : "UCLA",
                                "score" : 85
                            },
                            "team2" : {
                                "seed"  : 16,
                                "name"  : "Kent St",
                                "score" : 59
                            }
                        },
                        "prediction" : {
                            "team1" : {
                                "seed"  : 1,
                                "name"  : "UCLA",
                                "score" : 85
                            },
                            "team2" : {
                                "seed"  : 16,
                                "name"  : "Kent St",
                                "score" : 59
                            }
                        }
                    },
                    ...
                ],
                "2nd Round" : [
                    {
                        "result" : {
                            "team1" : {
                                "seed"  : " ",
                                "name"  : " ",
                                "score" : " "
                            },
                            "team2" : {
                                "seed"  : " ",
                                "name"  : " ",
                                "score" : " "
                            }
                        },
                        "prediction" : {
                            "team1" : {
                                "seed"  : 1,
                                "name"  : "UCLA",
                                "score" : " "
                            },
                            "team2" : {
                                "seed"  : " ",
                                "name"  : " ",
                                "score" : " "
                            }
                        }
                    },
                    ...
                ],
                "Sweet 16"  : [],
                "Elite 8"   : []
            },
            "region2" : {
                "name" : "midwest",
                "1st Round" : [],
                "2nd Round" : [],
                "Sweet 16"  : [],
                "Elite 8"   : []
            },
            "region3" : {
                "name" : "south",
                "1st Round" : [],
                "2nd Round" : [],
                "Sweet 16"  : [],
                "Elite 8"   : []
            },
            "region4" : {
                "name" : "west",
                "1st Round" : [],
                "2nd Round" : [],
                "Sweet 16"  : [],
                "Elite 8"   : []
            },
            "national" : {
                "Final Four" : {
                    "result" : {
                        "team1" : {
                            "seed"  : 1,
                            "name"  : "Kentucky",
                            "score" : 65
                        },
                        "team2" : {
                            "seed"  : 1,
                            "name"  : "N Carolina",
                            "score" : 68
                        },
                        "team3" : {
                            "seed"  : 2,
                            "name"  : "Villanova",
                            "score" : 59
                        },
                        "team4" : {
                            "seed"  : 5,
                            "name"  : "Syracuse",
                            "score" : 40
                        }
                    },
                    "prediction" : {
                        "team1" : {
                            "seed"  : " ",
                            "name"  : " ",
                            "score" : " "
                        },
                        "team2" : {
                            "seed"  : " ",
                            "name"  : " ",
                            "score" : " "
                        },
                        "team3" : {
                            "seed"  : " ",
                            "name"  : " ",
                            "score" : " "
                        },
                        "team4" : {
                            "seed"  : " ",
                            "name"  : " ",
                            "score" : " "
                        }
                    }
                },
                "Championship" : {
                    "result" : {
                        "team1" : {
                            "seed"  : 1,
                            "name"  : "Kentucky",
                            "score" : 65
                        },
                        "team2" : {
                            "seed"  : 1,
                            "name"  : "N Carolina",
                            "score" : 68
                        }
                    },
                    "prediction" : {
                        "team1" : {
                            "seed"  : " ",
                            "name"  : " ",
                            "score" : " "
                        },
                        "team2" : {
                            "seed"  : " ",
                            "name"  : " ",
                            "score" : " "
                        }
                    }
                },
                "Champion" : {
                    "result" : {
                        "team1" : {
                            "seed"  : 1,
                            "name"  : "Kentucky",
                            "score" : 65
                        }
                    },
                    "prediction" : {
                        "team1" : {
                            "seed"  : " ",
                            "name"  : " ",
                            "score" : " "
                        }
                    }
                }
            }
        }
    }
}

Values of " " are meant to act as filler in order for the shape and format of the bracket in HTML to stay intact.

The bracket data can be in one of three possible states, as specified by the key state. An Unavilable state signifies that no bracket data is available as it is currently not March Madness season. An Available state indicates that the teams and matchups for the tournament are available, and users can fill out their own brackets and make their picks. A Set state means that the tournament games have started so users cannot make any further changes to their brackets.

Features

The following is a list of ideas for features to implement, ordered in decreasing priority.

  • View bracket by triggering the input action next to the text input field
  • Populate bracket with data scraped from an appropriate website
  • Scrape content from an appropriate website to get the official start date of March Madness for the current year so that user brackets can be locked at the appropriate time
  • Show games and leaderboard in sidebar
  • Create configuration page
  • Create hotkeys to conveniently switch between My Picks and Results
  • Use glances to show updates to the leaderboard and games being played
  • Include the First Four games in the bracket

Although the data can be scraped from an appropriate website, there is currently no method of determining which Final Four team from each of the 4 regions plays one another.

If you have an idea that's not listed, please make a feature request by creating a new issue.