PykeBot2 is a Discord bot that I had developed in order to easily determine how skilled opponents in a given League of Legends tournament would be.
When I was playing League of Legends in an amateur team in the German university league we would often participate in tournaments hosted via Toornament.
Many of the tournaments we played were open invite such that the strength of the teams we would face varied a lot.
To better understand how difficult it would be for us to win a given tournament I developed PykeBot and later on rewrote it into PykeBot2 with an improved design.

Both versions of PykeBot were great learning experiences for me as I learned more about Python and establishing control flows that enabled multiple user requests to be served at once.
I wrote PykeBot2 in asynchronous Python on top of the amazing discord.py library.
Moreover, a central part of the design is the queuing system with each part of the system responsible for processing requests in some form having its own queue.
For instance, one part is responsible for retrieving the player and team names from the target tournament and another is responsible for retrieving the rankings of each player.

A user can send out a command to “stalk” a specific tournament by giving the link to the specific tournament to PykeBot via Discord chat.
PykeBot then creates a new request instance as a dataclass, which it then proceeds to move through its queues.
Whenever it passes a step in the processing, the respective information gathered, for example, the names of the players, are attached to the request object before passing it on.

Another challenge within the project was retrieving the actual data from online sources.
The implementation of PykeBot supports both web scraping and API retrieval of data.
If an API key is available, for instance, for the Riot API to retrieve player ranks or for the Toornament API to retrieve players, this is preferred as it is faster and more efficient.
However, Toornament changed their initial API, which allowed for retrieving the players of any public tournament such that after the change only owned tournaments could be retrieved.
With that only the HTML web scraping of Toornament was left as a viable approach.

Nevertheless, PykeBot2 still supports Toornament via the slower web scraping approach along with other web pages and is still a viable tool when frequently playing League of Legends Tournaments.
Check out the full source code here: https://github.com/Twalord/PykeBot2

Next Post Previous Post