Steam API的Python封装
项目描述
steam.py
A modern, easy to use, and async ready package to interact with the Steam API. Heavily inspired by discord.py.
主要功能
- 使用
async
/await
语法编写的现代Pythonic API - 命令扩展以帮助创建机器人
- 具有面向对象设计,易于使用
- 完全类型提示,以加快开发速度
安装
需要Python 3.10或更高版本
要安装库,请运行以下命令之一
# Linux/macOS
python3 -m pip install -U steamio
# Windows
py -m pip install -U steamio
或者对于开发版本。
# Linux/macOS
python3 -m pip install -U "steamio @ git+https://github.com/Gobot1234/steam.py@main"
# Windows
py -m pip install -U "steamio @ git+https://github.com/Gobot1234/steam.py@main"
快速示例
import steam
class MyClient(steam.Client):
async def on_ready(self) -> None:
print("Logged in as", self.user)
async def on_trade(self, trade: steam.TradeOffer) -> None:
if not trade.is_our_offer():
await trade.user.send("Thank you for your trade")
print(f"Received trade: #{trade.id}")
print("Trade partner is:", trade.user)
print("We would send:", len(trade.sending), "items")
print("We would receive:", len(trade.receiving), "items")
if trade.is_gift():
print("Accepting the trade as it is a gift")
await trade.accept()
client = MyClient()
client.run("username", "password")
机器人示例
from steam.ext import commands
bot = commands.Bot(command_prefix="!")
@bot.command
async def ping(ctx: commands.Context) -> None:
await ctx.send("Pong!")
bot.run("username", "password")
链接
项目详情
关闭
哈希值 for steamio-1.0.1-cp311-cp311-macosx_14_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0df7647e8ca4925ace3da7b8657a78ba4a430364d97360383ef857b063e54c3e |
|
MD5 | 94e990bb1f6ede8b8ce1ba86692eaa4f |
|
BLAKE2b-256 | c9ad8db1dfc4c3c53add2f89895e34aba6cfd76385475253031f01c79abd6a93 |