Created
May 20, 2017 16:18
-
-
Save anonymous/6827d53f1439a9149afbb0850c7c9a53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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