Giter Site home page Giter Site logo

rhys-wootton-cackett / popularitybot Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 533 KB

A Discord bot that tracks the changes in popularity of tracks that are currently in CTGP Revolution.

Home Page: https://discord.com/api/oauth2/authorize?client_id=787357691637923864&permissions=8&scope=bot

License: GNU General Public License v3.0

C# 100.00%

popularitybot's Introduction


PopularityBot is a Discord bot that tracks the changes in popularity of tracks that are currently in Mario Kart Wii, and its #1 mod pack CTGP Revolution. It was created to remove the struggles of seeing how popular certain tracks are, and has built in polling functionality to allows users to vote on tracks. It also comes with an ability to search for tracks on the Custom Mario Kart Wiiki.

How it works

PopularityBot works by using two datasets, the CTGP Revolution Time Trial API, and the WiimmFi weekly CTWW statistics page. The flow of getting the popularity of each track is as follows:

  1. Every hour, PopularityBot will connect to the CTGP Revolution Time Trial API and grab the data from the their respective sections (original-track-leaderboards.json and ctgp-leaderboard.json.
  2. PopularityBot will then store the track’s name and SHA1 hash, along with its popularity score, in a HashMap, which allows PopularityBot to map a unique track to a popularity value.
  3. PopularityBot then knows all tracks that are in CTGP Revolution, along with the 32 base game tracks, and begins to connect to two WiimmFi statistics page, the Nintendo tracks statistics and the CTGP Revolution tracks statistics.
  4. Once connected, it scans through each row, seeing if there is a name match in the existing HashMap created from the Time Trial API, using the SHA1 hash.
    1. If there is a match, a formula is run to determine its popularity score.
    2. If there is no match, the track is not in CTGP Revolution, so we skip it.

Commands

Popularity Commands

!nin commands relate to the base game tracks in Mario Kart Wii. !ctgp commands relate to the tracks in CTGP Revolution.

  • !nintop & !ctgptop : Shows the top 10 tracks in ascending order of popularity.
  • !ninbottom & !ctgpbottom : Shows the bottom 10 tracks in descending order of popularity.
  • !nintopbottom & !ctgptopbottom : Combines the results from the previous two commands into one.
  • !ninlist/ctgplist <starting_point> <ending_point> Lists the number of tracks from the starting point specified in ascending order of popularity. The number of tracks has to be between 2 and 25 inclusive.
  • !ninfind/ctgpfind <search_param> Lists all tracks containing the search parameter in ascending order of popularity. It stops listing tracks after a 25th track has been found.

All these commands have overloads for only showing popularity based on Time Trials and WiimmFi popularity. This is achieved by adding wf or tt at the end of each command.

Poll Commands

  • !pollsetup Sets up the polling capabilities of the bot. This command can only be run by a server administrator.
  • !startpoll Starts the process of creating a poll. It will ask a few questions relating to the creation of the poll, and once all questions have been answered, a poll is started.

Other Commands

  • !wiki Sends details of a custom track from the Custom Mario Kart Wiiki.
  • !github Sends a link to the GitHub repo for PopularityBot.
  • !donate Sends a message on how to donate to me to help this project and others I make.

Building From Source

  1. Clone the project and load in Visual Studio.
  2. Create a new application in the Discord Developer Portal and add a new bot to that application.
  3. Create an App.config file in the same folder as the .cs files, and paste the following:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="secret" value="[BOT_TOKEN_GOES_HERE]"/>
      </appSettings>
    </configuration>
  4. Build and run the project

Dependencies

Current Issues

  • If the bot goes down for any reason, and is restarted, active polls will no longer be concluded.
    • This can be remedied by either starting a new poll and having users vote again, or count up the results manually when the original poll would have ended.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

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.