Skip to content

Instantly share code, notes, and snippets.

Created May 20, 2017 16:18
Show Gist options
  • Save anonymous/6827d53f1439a9149afbb0850c7c9a53 to your computer and use it in GitHub Desktop.
Save anonymous/6827d53f1439a9149afbb0850c7c9a53 to your computer and use it in GitHub Desktop.
import time
from steampy.client import SteamTradeClient, TradeOfferState
from steampy.guard import load_steam_guard
# Set API key
api_key = ''
# Set path to SteamGuard file
steamguard_path = "C:/Users/Robbie/PycharmProjects/python-auto-steam-trade/Steamguard.txt"
# Steam username
username = ''
# Steam password
password = ''
def main():
print('This is the donation bot accepting items for free.')
if not are_credentials_filled():
print('You have to fill credentials in storehouse.py file to run the example')
print('Terminating bot')
return
client = SteamTradeClient(api_key)
client.login(username, password, steamguard_path)
print('Bot logged in successfully, fetching offers every 60 seconds')
while True:
offers = client.get_trade_offers()['response']['trade_offers_received']
for offer in offers:
if is_donation(offer):
offer_id = offer['tradeofferid']
num_accepted_items = len(offer['items_to_receive'])
client.accept_trade_offer(offer_id)
print('Accepted trade offer {}. Got {} items'.format(offer_id, num_accepted_items))
time.sleep(60)
def are_credentials_filled() -> bool:
return api_key != '' and steamguard_path != '' and username != '' and password != ''
def is_donation(offer: dict) -> bool:
return offer.get('items_to_receive') \
and not offer.get('items_to_give') \
and offer['trade_offer_state'] == TradeOfferState.Active \
and not offer['is_our_offer']
if __name__ == "__main__":
# execute only if run as a script
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment