Вот основная функция:
Код: Выделить всё
import asyncio
import aioprocessing
import multiprocessing
import subprocess
# local imports
import steam_bot
async def open_auth():
_ = await asyncio.create_subprocess_exec('wine', '/Users/vortex/Desktop/Steam Project/SDA/Steam Desktop Authenticator.exe')
async def start_bot(q):
p = aioprocessing.AioProcess(target=steam_bot.main)
p.start()
await p.join()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
tasks = [
asyncio.ensure_future(open_auth()),
asyncio.ensure_future(start_bot()),
]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
Вот Steam_bot, использующий пакет Steamio:
Код: Выделить всё
import steam
class MyClient(steam.Client):
async def on_ready(self):
print("------------")
print("Logged in as")
print("Username:", self.user)
print("ID:", self.user.id64)
print("Friends:", len(await self.user.friends()))
print("------------")
async def on_message(self, message: steam.Message):
# we do not want the bot to reply to itself
if message.author == self.user:
return
if message.content.startswith("!hello"):
await message.channel.send(f"Hello {message.author}")
def main():
client = MyClient()
client.run("username", "password")
Вполне может возникнуть проблема с тем, как я запускаю программу с помощью aioprocess. Я столкнулся с препятствием, пытаясь устранить ошибки такого типа. Мне нужна помощь в попытке запустить эти два типа программ в одной основной программе.
Подробнее здесь: https://stackoverflow.com/questions/798 ... subprocess
Мобильная версия