Monday, February 14, 2022

Free Games Bot


The Free Games Bot output in my discord channel

This is a little project that I made in my spare time. My goal was to learn more about python scripting by trying to make it ‘do things’. Free games bot is a script that interfaces with the API of a game sale aggregating website called IsThereAnyDeal.com, sorts the payload it receives as a result of its search parameters, and then posts the results on either slack or discord channel using webhooks.

It can be run manually, or can be added to the windows task scheduler to be run as often as you wish.

The search parameters and other information are loaded from a json file. The settings json can have more than one bot profile in it. Multiple profiles can be used to post to multiple channels using different webhooks urls, to store different search criteria or both.

Each profile records what it found last session in a json. Since it remembers what it found last time, the likelihood of repeat posts is reduced.

Bot Settings

The settings JSON may contain multiple bot profiles, each with their own unique settings and discord or slack channel targets.

ITAD API Parameters

The API Parameters are key value pairs that are sent to the ITAD web API to specify what data you want to receive in the payload.
  • key: The API Key from ITAD.
  • offset: The position at which to start the search. ie. From the 500th entry.
  • limit: The number after which to stop. ie. After 4000 entries.
  • region: Filters results by countries within a region.
  • country: Filters deals by country, as well as determines the currency conversion.
  • shops: Filter by specific shops. This is set programmatically by the script based on the store filter.
  • sort: Criteria to sort by. ie. By price cut in descending order.

Other Parameters

  • web_hook_address: The address of the webhook from your discord channel.
  • store_filter: Can either exclude or include shops from the complete list of shops. The value here will inform what gets sent to the ITAD API.
  • game_filters: The script will go through the data downloaded from ITAD and filter it based on criteria.
    • min_discount_percent: The minimum discount to report in percent.
    • min_price_old: The minimum before-sale price to report in dollars.
    • max_price_new: The maximum sale price to report.
    • exclude_keywords: Any problem keywords in game titles you don't want to hear about.
  • tracking_json: The filename of the tracking json to be created. It's so you can give a unique name to your record per profile. The record is the bot's memory of what it posted yesterday.

You can check out my project on github!

No comments:

Post a Comment