Skip to content

Instantly share code, notes, and snippets.

@zudsniper
Last active July 9, 2023 22:26
Show Gist options
  • Save zudsniper/69f6494d2741c941e13f050dd8e013c7 to your computer and use it in GitHub Desktop.
Save zudsniper/69f6494d2741c941e13f050dd8e013c7 to your computer and use it in GitHub Desktop.
πŸ† minimal bot script for use with @godot1234 Steam.py lib for confirmation testing

steampytest

(python3.10 or 3.11 or idk but definitely not python 3.9 or earlier)

Excruciatingly simple python steam bot implementation to test Gobot1234's Steam.py repository.


Summary

It seems that Steam mobile confirmations are broken due to the somewhat recent change to the Steam mobile confirmation API structure. This is definitely annoying, but it shouldn't be all that difficult.

@tf2autobot/steam-tradeoffer-manager has fixed this, and probably the upstream steam-tradeoffer-manager repo I just didn't look there

Running This Test

Tested only on macOS Catalina 10.15 (don't ask i'm insane)

Requires python3.10 or greater, and pip package python-dotenv, along with the dev build of steam.py of course.

(check bob_builder.sh "installer" script for more information.)


Thanks for making this lib in general. Hopefully you can fix this without much trouble, if you intend to. Have a good day!
@zod

#!/bin/bash
# bob_builder.sh
# --------------
#
# builds env for steampytest.py mobile confirmations "bot"
#
# SOURCES
# - https://github.com/Gobot1234/steam.py
# - https://stackoverflow.com/questions/69503329/pip-is-not-working-for-python-3-10-on-ubuntu
#
# @zudsniper
# add virtualenv & enter it
python3 -m pip install virtualenv
python3 -m virtualenv venv
. venv/bin/activate
# print version
python3 --version
# install dotenv
python3 -m pip install python-dotenv
# install dev build of Steam.py
python3 -m pip install -U "steamio @ git+https://github.com/Gobot1234/steam.py@main"
# finished
echo -e "${A_GREEN}${A_BOLD}Done.${A_RESET}\n Try steampytest.py"
#!/usr/bin/python3
#
# warning: MUST be python 3.10 or greater.
# the environment also is not set up correctly by default.
# please see `bob_builder.sh` for that
import steam
import os
import asyncio
from dotenv import load_dotenv
# load environment vars from .env file
load_dotenv()
# allow override via local env vars
# TODO: implement
mainusername = os.getenv('USERNAME')
mainpassword = os.getenv('PASSWORD')
mainshared_secret = os.getenv('SHARED_SECRET')
mainidentity_secret = os.getenv('IDENTITY_SECRET')
class MainBot(steam.Client):
async def on_ready(self) -> None:
print("Logged into main bot: ", self.user)
async def on_trade_receive(self, trade: steam.TradeOffer) -> None:
print(f"Accepting trade #{trade.id} from {str(trade.partner.id64)}")
await trade.accept()
async def main():
global Main
Main = MainBot()
await Main.login(mainusername, mainpassword, shared_secret=mainshared_secret,
identity_secret=mainidentity_secret)
if name == "main":
try:
asyncio.run(main())
except:
traceback.print_exc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment