Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Feb 1, 2019. It is now read-only.
/steam-tradePublic archive

An asynchronous, event based python steam trade lib

License

NotificationsYou must be signed in to change notification settings

Zwork101/steam-trade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An asynchronous, event based python steam trade lib

Description

Steam-Trade is an asynchronous, event based, python steam trade library. It uses the python portpyee of EventEmitter, so you can focus on processing trades, and not fetching for them and parsing them!

It'sasynchronous, so that means it can do multiple tasks at the same time! What does this mean for you? What that means, if you get multiple trades at once, it can work on all of them at the same time. This is for total efficiency, and it's easy to work with!

It'sevent based, so that means you won't have code, doing loops, polling for trades, we do all that for you. All you have to write is a listener@manager.on('new_trade') and your function to proccess the event.

Installation

You'll need to install this through pip, Python's package manager. If you don't have pip installed, then reinstall python with the install pip option checked (It's possible other ways, but this is seriously the easiest).If you're installing python via a linux command line and pip isn't available, try runningsudo apt install python3-pip.

Dopip install -U steam-trade, or if pip isn't added to path dopython -m pip install -U steam-trade, substituting python with whatever you use to run python3.6 normally (this differs if you have another version of python installed)

Then, you will access it under a different name when importing it:

importpytrade

Usage

First, you will need to create anAsyncClient object, and aTradeManager object (see why the AsyncClient object is required inFAQ)

steam_login=pytrade.login.AsyncClient("Zwork101","abc123",shared_secret="super-secret-secret")trade_manager=pytrade.manager_trade.TradeManager("12345678","steam api key",identity_secret="also-super-secret")global_manager=pytrade.GlobalManager([trade_manager])

Now, run any setup code you want.

After that, create coroutines to proccess events. Useasync beforedef to expalin to python that function is a coroutine. Then, write the code to proccess these events.

@trade_manager.on('logged_on')asyncdeflogin():print("Trade Manager is logged in")@trade_manager.on('trade_accepted')asyncdeftrade_accept(trade_offer):print('----NEW TRADE ACCEPTED-----------')print(f'Trade Offer Id:{trade_offer.tradeofferid}')print(f'From User:{trade_offer.steamid_other.toString()}')print('---------------------------------')

Then, you need to run the program forever. Currently, there is no "clean" way to exit.

loop=asyncio.get_event_loop()loop.run_until_complete(asyncio.ensure_future(trade_manager.login(steam_login)))global_manager.run_forever()

FAQ

Q: Why have a class just for a steam login? Why is there a global manager and a trade manager? Why does the global manager take the trade manager in a list?

A: Futureproofing. The global manager should be able to take many more modules, not just a trade manager. This makes it easy to add something like a steam chat manager in the future.

Q: What if I want to use the program, and not run it forever?

A: You will have to useasyncio.ensure_future(function you want to use) for each coroutine, unless you call it in another coroutine. Each manager has apoll method, you could run that when you like.

Q: How can I help?

A: There are lots of ways! Upload an example, rewrite some code (make sure to check it works first!), send a donation or just star the project - it is all appreciated!

Q: Who the hell made thisamazing library?!?

A: Check out thecontibutors tab!

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp