Added delay parameter and brough Casey back
This commit is contained in:
parent
5f885b8b5b
commit
d0b061f3db
15
async-bot.py
15
async-bot.py
|
@ -102,7 +102,12 @@ class AsyncBotManager:
|
||||||
else:
|
else:
|
||||||
print("unknown event", event, data)
|
print("unknown event", event, data)
|
||||||
|
|
||||||
async def writer(self, bot_index: int, proxy_url: Optional[str] = None):
|
async def writer(
|
||||||
|
self,
|
||||||
|
bot_index: int,
|
||||||
|
proxy_url: Optional[str] = None,
|
||||||
|
delay: float = 0.25,
|
||||||
|
):
|
||||||
proxy = ProxyConnector.from_url(proxy_url) if proxy_url else None
|
proxy = ProxyConnector.from_url(proxy_url) if proxy_url else None
|
||||||
async with ClientSession(connector=proxy) as http:
|
async with ClientSession(connector=proxy) as http:
|
||||||
async with AsyncSimpleClient(http_session=http) as sio:
|
async with AsyncSimpleClient(http_session=http) as sio:
|
||||||
|
@ -116,7 +121,7 @@ class AsyncBotManager:
|
||||||
if current != expected:
|
if current != expected:
|
||||||
print(f"[{bot_index:2d}] swap {x:3d} {y:3d}")
|
print(f"[{bot_index:2d}] swap {x:3d} {y:3d}")
|
||||||
await sio.emit("toggle_bit", {"index": index})
|
await sio.emit("toggle_bit", {"index": index})
|
||||||
await asyncio.sleep(0.25)
|
await asyncio.sleep(delay)
|
||||||
break
|
break
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
|
||||||
|
@ -204,7 +209,11 @@ async def amain():
|
||||||
if n_proxies := len(settings["proxies"]):
|
if n_proxies := len(settings["proxies"]):
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
*[
|
*[
|
||||||
mgr.writer(i, settings["proxies"][i % n_proxies])
|
mgr.writer(
|
||||||
|
i,
|
||||||
|
settings["proxies"][i % n_proxies],
|
||||||
|
settings["delay"],
|
||||||
|
)
|
||||||
for i in range(settings["n_bots"])
|
for i in range(settings["n_bots"])
|
||||||
],
|
],
|
||||||
return_exceptions=True,
|
return_exceptions=True,
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
|
@ -2,7 +2,8 @@
|
||||||
"url": "https://onemillioncheckboxes.com",
|
"url": "https://onemillioncheckboxes.com",
|
||||||
"font": "./ic8x8u.ttf",
|
"font": "./ic8x8u.ttf",
|
||||||
"proxies": [],
|
"proxies": [],
|
||||||
"n_bots": 3,
|
"n_bots": 5,
|
||||||
|
"delay": 0.125,
|
||||||
"avoid": [
|
"avoid": [
|
||||||
{
|
{
|
||||||
"type": "rect",
|
"type": "rect",
|
||||||
|
@ -70,8 +71,14 @@
|
||||||
{
|
{
|
||||||
"type": "image",
|
"type": "image",
|
||||||
"path": "./pictures/neko.png",
|
"path": "./pictures/neko.png",
|
||||||
"x": 32,
|
"x": 263,
|
||||||
"y": 64
|
"y": 229
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"path": "./pictures/casey.png",
|
||||||
|
"x": 256,
|
||||||
|
"y": 256
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue