Skip to content

yuwex/scratchcloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scratchcloud

An asynchronous Pythonic wrapper for scratch.mit.edu cloud websockets.

PyPi Package Version PyPi Package Python Versions PyPi Downloads / Month Discord server invite

Features

  • Efficient asynchronous connection with Scratch.
  • Event-based handling of cloud variables.
  • Built-in reconnecting.
  • Encoding and decoding support.

Extensions

  • Fetching data from the Scratch API.
  • Easily customizable codecs for encoding and decoding variables.
  • Sending and parsing large cloud payloads.
  • Validating the cloud by finding who changed a cloud variable.

Example

from scratchcloud import CloudClient, CloudChange

client = CloudClient('yuwe', '588579111')

@client.event
async def on_connect():
    print('Connected!')

@client.event
async def on_disconnect():
    print('Disconnected!')

@client.event
async def on_message(cloud: CloudChange):
    print(f"{cloud.name} was set to {cloud.value}!")
    await client.set_cloud(cloud.name, "123")

client.run("SuperSecretPassword22")

Links