Giter Club home page Giter Club logo

loot-bot's Introduction

Loot Bot - Discord Bot for free content on Twitch Prime Gaming and Epic Games

python discord twitch prime docker

A discord bot to check for available content on Twitch Prime Gaming and Epic Games Store and posting it in the discord chat.

Contents

Setup (for non-technical users)

Step 1: Setting up a discord bot

You need to set up a discord bot:

  1. Navigate to https://discord.com/developers/applications and create a new application. You can choose whatever name fits your need.
  2. In your new application, navigate to the section Bot and create a bot. You can choose whatever name fits your need. This name will be the default display name of the bot on your discord server.
  3. In your bots settings you will find the token. Save it for later steps. This token is important. Keep it always a secret!
  4. In your application in the section OAuth2 you will find your client ID. With that ID you can invite your new bot to your discord server. To do so, navigate to discordapp.com/oauth2/authorize?client_id=XXXXXXX&scope=bot but replace the "XXXXXXX" with your client ID.
  5. After inviting the bot, he will appear in the user list of your server. Yet he will be marked as "offline" but that will change as soon as you finished the setup and the bot should be running.

Step 2: Running the bot

To run this bot, it is advised to use Docker. Docker is a way to run programs in a standardized container that works on any platform.

Download Docker for your system and start it

Download this repository. For the bot to work, you have to write your bot's token into the config file. The config file is located at bot/ressources/config.yml. In the section token, replace the "O" with your token.

All other parts of the config are optional for you to configure or keep the default settings. However, one important part to look out for is the section games_to_inlcude. Only games listed here will be displayed by the bot in the discord chat.

Open a terminal and navigate into the downloaded directory. Issue the following commands to build and start the docker container:

# Build docker image
docker build -t twitch_prime_bot .

# Run docker image as container
docker run -it twitch_prime_bot

After starting the container you are finished with the setup.

Run without Docker

It is recommended to run this bot in a Docker Container. However, it is also possible to run it without. For that you need to Download Google Chrome to your system and run the bot.

Step 3: How to use commands in discord chat

In the discord chat, you can use the commands listed below. All these commands can be changed to any other phrase you like in the config file.

Make sure the bot has access to the channel you are using. If the bot appears in the user list of that channel, everything should be set up correctly.

Command Description
!twitch Displays current content from the prime gaming website. If available, stored data will be used (max 24h old).
!twitch fetch Displays current content from the prime gaming website. Always tries to fetch new data. This might take longer.
!epic Displays current content from the epic games store website. If available, stored data will be used (max 24h old).
!epic fetch Displays current content from the epic games store website. Always tries to fetch new data. This might take longer.

Screenshots

Example message

Technical Design

icon

Diagram of dataflow from website to Discord chat

The core of this bot is the functionality to gather data from Amazon Prime Gaming. Since there is no API for this purpose, this bot fetches the HTML code from the Prime Gaming Website and extracts all relevant data from it. This is mainly done by using Selenium and BeautifulSoup.

Since fetching new data takes some time, data will be stored locally in a JSON file. New data will first be fetched after 24 hours have passed. This is especially useful when a lot of users use the bot at the same time.

This is wrapped in a discord bot built using the Discord Python API. The discord bot then runs in a Docker container.

loot-bot's People

Contributors

falyrion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

loot-bot's Issues

Running docker build -t twitch_prime_bot . gives error

This is the first time I'm using docker, I installed it with this guide: https://www.simplilearn.com/tutorials/docker-tutorial/how-to-install-docker-on-ubuntu

After doing the docker build command I get this error:

ubuntu@instance-20221115-1321:~/Loot-Bot-main$ sudo docker build -t twitch_prime_bot .
Sending build context to Docker daemon  324.1kB
Step 1/13 : FROM --platform=linux/amd64 python:3.10
 ---> 13ad26b9696b
Step 2/13 : RUN apt-get -y update
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
 ---> Running in 8201d6b20e6f
exec /bin/sh: exec format error
The command '/bin/sh -c apt-get -y update' returned a non-zero code: 1

[Bug] ModuleNotFoundError: No module named 'packaging'

Traceback (most recent call last):
  File "//discord_bot.py", line 4, in <module>
    from bot_modules import get_twitch_data, get_epic_games_data
  File "/bot_modules/get_twitch_data.py", line 4, in <module>
    from webdriver_manager.chrome import ChromeDriverManager
  File "/usr/local/lib/python3.10/site-packages/webdriver_manager/chrome.py", line 7, in <module>
    from webdriver_manager.drivers.chrome import ChromeDriver
  File "/usr/local/lib/python3.10/site-packages/webdriver_manager/drivers/chrome.py", line 1, in <module>
    from packaging import version
ModuleNotFoundError: No module named 'packaging'

When running the bot in Docker, the above error message appears

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.