SteamGifts Bot

Role_Play
4 min readMay 20, 2023

--

https://github.com/s-tyda/steamgifts-bot

In this guide, I’ll take a bot for the steamgifts site.

Sorry about the translation, it’s a little crooked. I translated it to DeepL.

I found it on the expanses of GitHub, first, about the functionality it is pretty great.

  • Automatically enters giveaways.
  • Undetectable.
  • Configurable.
  • Sleeps to restock the points.
  • Can run 24/7.

You might ask and what makes it different from other bots, but the fact that this bot can be configured as you like.

For example, you can change the divisions by importance. To explain, this stack is responsible for importance. (photo below)

Wishlist — This section is to find games from your Steam wishlist (don’t forget to sync your accounts)

Recommended — recommendations, this section is clear.

Copies — distributions with more than one key (chances are better)

Group — distribution from subscribed groups.

All — all giveaways.

And що is DLC and New, but I do not use them, so I will not explain.

Priorities No touching!!!

Now let’s move on to practice.
At first startup it will ask for a cookie (don’t be afraid they are not cookies, you can keep them)

To get a cookie, we need the Cookie-Editor extension

Go to the site and click on extensions. We see the line PHPSESSID copy the code and go into our software drive the code and then drive the number of points which should wait for the bot to start working.

We see the line PHPSESSID copy the code and go into our code, drive the code and then, drive the number of points that should wait for the bot to start working.

As I explained to you at the beginning, put the order as you want, but I have this.

Everyone start the bot and be happy that everything works. If you want, you can put it in the autoloader.

import configparser
import questionary
import json
from prompt_toolkit.document import Document
from prompt_toolkit.validation import Validator, ValidationError
from main import SteamGifts
from common import log, Singleton
from typing import Dict, Any
from functools import cached_property
import pyautogui
import time

class PointValidator(Validator):
def validate(self, doc: Document) -> bool:
value = doc.text
try:
value = int(value)
except Exception:
raise ValidationError(
message="Value should be a number",
cursor_position=len(doc.text),
)

if value <= 0:
raise ValidationError(
message="Value should be greater than 0",
cursor_position=len(doc.text),
)
return True


class ConfigReader(metaclass=Singleton):
def __init__(self) -> None:
self.config = configparser.ConfigParser()
self.config.read("config/config.ini")

def _save_config(self) -> None:
with open("config/config.ini", "w") as configfile:
self.config.write(configfile)

def _ask_for_cookie(self) -> str:
cookie = questionary.text(
"Enter PHPSESSID cookie (Only needed to provide once):"
).ask()
self.config["DEFAULT"]["cookie"] = cookie
self._save_config()
return cookie

def _ask_for_pinned(self) -> bool:
pinned_games = questionary.confirm(
"'Should bot enter pinned games?'"
).ask()
self.config["DEFAULT"]["enter_pinned_games"] = str(pinned_games)
self._save_config()
return pinned_games

def _ask_for_min_points(self) -> int:
min_points = questionary.text(
message="Enter minimum points to start working (bot will try "
"to enter giveaways until minimum value is reached):",
validate=PointValidator,
).ask()
self.config["DEFAULT"]["min_points"] = min_points
self._save_config()
return int(min_points)

@cached_property
def data(self) -> Dict[str, Any]:
with open("config/config.json") as json_data_file:
data = json.load(json_data_file)

if not self.config["DEFAULT"].get("cookie"):
data["cookie"] = self._ask_for_cookie()
else:
data["cookie"] = self.config["DEFAULT"].get("cookie")

if not self.config["DEFAULT"].get("enter_pinned_games"):
data["enter_pinned_games"] = self._ask_for_pinned()
else:
data["enter_pinned_games"] = self.config["DEFAULT"].getboolean(
"enter_pinned_games"
)

if not self.config["DEFAULT"].get("min_points"):
data["min_points"] = self._ask_for_min_points()
else:
data["min_points"] = self.config["DEFAULT"].getint("min_points")
return data


def move_mouse():
while True:
pyautogui.moveRel(1, 0)
time.sleep(10)


def run() -> None:
log("SteamGifts Bot", color="blue", figlet=True)
log("Welcome to SteamGifts Bot!", color="green")
log("Created by: github.com/s-tyda", color="white")

config = ConfigReader()
s = SteamGifts(**config.data)

import threading

mouse_thread = threading.Thread(target=move_mouse)
mouse_thread.daemon = True
mouse_thread.start()

s.start()


if __name__ == "__main__":
run()

Throw this code in the cli.py file, but this is where I say goodbye, good luck to everyone, see you soon, bye.

--

--