This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added module support
- Loading branch information
Showing
12 changed files
with
183 additions
and
151 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,104 @@ | ||
# NOT UPDATED | ||
|
||
import asyncio | ||
from pytrade import login, client | ||
import pytrade | ||
|
||
steam_cli = login.AsyncClient('name', 'pass', shared_secret='secret') | ||
manager = client.TradeManager('steam 64 id', key='apikey', identity_secret='your other secret') | ||
steam_client = pytrade.login.AsyncClient('name', 'pass', shared_secret='secret') | ||
trade_manager = pytrade.manager_trade.TradeManager('steam 64 id', key='apikey', identity_secret='your other secret') | ||
global_manager = pytrade.GlobalManager([trade_manager]) | ||
|
||
|
||
# This will be called, when it completes the client.login | ||
@manager.on('logged_on') | ||
@trade_manager.on('logged_on') | ||
async def login(): | ||
print('Logged in!') | ||
|
||
|
||
# On a new trade, this will be called. an EconTradeOffer.TradeOffer object will be passed in | ||
@manager.on('new_trade') | ||
@trade_manager.on('new_trade') | ||
async def new_offer(trade_offer): | ||
print(f"Got Offer: {trade_offer.tradeofferid}") | ||
|
||
|
||
# A new confirmation (including ones that are going to be accepted automatically) | ||
@manager.on('new_conf') | ||
@trade_manager.on('new_conf') | ||
async def new_conf(conf): | ||
print(f"Got confirmation: {conf.id}") | ||
|
||
|
||
# This is called at the end of polling | ||
@manager.on('end_poll') | ||
# This is called at the end of global polling | ||
@trade_manager.on('global_end_poll') | ||
async def poll_end(): | ||
print("Global poll ended.") | ||
|
||
|
||
# This is called at the start of global polling | ||
@trade_manager.on('global_start_poll') | ||
async def poll_start(): | ||
print("Global poll started.") | ||
|
||
|
||
# This is called at the end of trade polling | ||
@trade_manager.on('trade_end_poll') | ||
async def poll_end(): | ||
print("Poll ended.") | ||
print("Trade poll ended.") | ||
|
||
|
||
# This is called at the start of polling | ||
@manager.on('start_poll') | ||
# This is called at the start of trade polling | ||
@trade_manager.on('trade_start_poll') | ||
async def poll_start(): | ||
print("Poll started.") | ||
print("Trade poll started.") | ||
|
||
|
||
# This is called when there is an error in some of your code | ||
@manager.on('error') | ||
@trade_manager.on('error') | ||
async def error(message): | ||
print(f"Our code errored: {message}") | ||
|
||
|
||
# This is called when there is an error whilst polling. | ||
# This should be caught and polling will continue as normal | ||
@manager.on('poll_error') | ||
@trade_manager.on('trade_poll_error') | ||
async def poll_error(message): | ||
print(f"Poll error: {message}") | ||
|
||
|
||
# This is called when a trade is accepted | ||
@manager.on('trade_accepted') | ||
@trade_manager.on('trade_accepted') | ||
async def accepted_offer(trade_offer): | ||
print(f"Accepted Offer: {trade_offer.tradeofferid}") | ||
|
||
|
||
# This is called when a trade is declined | ||
@manager.on('trade_declined') | ||
@trade_manager.on('trade_declined') | ||
async def declined_offer(trade_offer): | ||
print(f"Declined Offer: {trade_offer.tradeofferid}") | ||
|
||
|
||
# This is called when a trade is cancelled | ||
@manager.on('trade_canceled') | ||
@trade_manager.on('trade_canceled') | ||
async def canceled_offer(trade_offer): | ||
print(f"Canceled Offer: {trade_offer.tradeofferid}") | ||
|
||
|
||
# This is called when a trade has expired | ||
@manager.on('trade_expired') | ||
@trade_manager.on('trade_expired') | ||
async def expired_offer(trade_offer): | ||
print(f"Expired Offer: {trade_offer.tradeofferid}") | ||
|
||
|
||
# This is called when a trade has been countered | ||
@manager.on('trade_countered') | ||
@trade_manager.on('trade_countered') | ||
async def countered_offer(trade_offer): | ||
print(f"Countered Offer: {trade_offer.tradeofferid}") | ||
|
||
|
||
# This is called when a trade state has changed to something unexpected | ||
@manager.on('trade_state_changed') | ||
@trade_manager.on('trade_state_changed') | ||
async def changed_offer(trade_offer): | ||
print(f"Countered Offer: {trade_offer.tradeofferid}") | ||
|
||
# This is the basic setup for the program, and it will run forever. Currently, there is no "nice" way to end it. | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(asyncio.ensure_future(manager.login(steam_cli))) | ||
manager.run_forever() | ||
loop.run_until_complete(asyncio.ensure_future(trade_manager.login(steam_client))) | ||
global_manager.run_forever() |
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
Oops, something went wrong.