mirror of
https://github.com/osmarks/random-stuff
synced 2025-01-02 21:40:35 +00:00
heavdrone
This commit is contained in:
parent
b7a3686155
commit
34b060524e
18
heavdrone.py
18
heavdrone.py
@ -78,16 +78,20 @@ async def spudnet_connect():
|
|||||||
assert json.loads(await conn.recv())["type"] == "ok"
|
assert json.loads(await conn.recv())["type"] == "ok"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def aliveness_loop():
|
async def send_alive():
|
||||||
while True:
|
return await send({ "type": "alive_info", "name": await getconf("name"), "category": await getconf("category"),
|
||||||
if conn:
|
|
||||||
await send({ "type": "alive_info", "name": await getconf("name"), "category": await getconf("category"),
|
|
||||||
"buttons": [
|
"buttons": [
|
||||||
{ "type": "textarea", "respondon": "set_name", "name": "Set Name" },
|
{ "type": "textarea", "respondon": "set_name", "name": "Set Name" },
|
||||||
{ "type": "textarea", "respondon": "set_cat", "name": "Set Category" } ,
|
{ "type": "textarea", "respondon": "set_cat", "name": "Set Category" } ,
|
||||||
{ "type": "chatlike", "2way": "repl", "name": "Python REPL" },
|
{ "type": "chatlike", "2way": "repl", "name": "Python REPL" },
|
||||||
{ "type": "chatlike", "2way": "chat", "name": "Dronechat" }
|
{ "type": "chatlike", "2way": "chat", "name": "Dronechat" },
|
||||||
|
{ "type": "simple", "onclick": "counter", "name": await getconf("counter") or "0" }
|
||||||
]})
|
]})
|
||||||
|
|
||||||
|
async def aliveness_loop():
|
||||||
|
while True:
|
||||||
|
if conn:
|
||||||
|
await send_alive()
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
loop.create_task(aliveness_loop())
|
loop.create_task(aliveness_loop())
|
||||||
@ -111,6 +115,10 @@ async def spudnet_connect():
|
|||||||
loop.create_task(run())
|
loop.create_task(run())
|
||||||
if data["type"] == "chat":
|
if data["type"] == "chat":
|
||||||
await send({ "type": "stream_upd", "streamid": "chat", "data": f"{rmsg['sid']}: {data['data']}" })
|
await send({ "type": "stream_upd", "streamid": "chat", "data": f"{rmsg['sid']}: {data['data']}" })
|
||||||
|
if data["type"] == "counter":
|
||||||
|
c = int(await getconf("counter") or "0")
|
||||||
|
await setconf("counter", str(c + 1))
|
||||||
|
await send_alive()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user