Skip to main content

A API for scratch with websocket

Project description

Scratch Websocket API

Overview

このライブラリは、Websocketを通じてScratch(またはTurbowarp)に接続し、そのクラウド変数を変更するために作成されました。

Installation

Python3が必須となります。Python2は使えないと思います。

pip install scratch-websocket-api

Usage

Connect

Websocketを使用してサーバーに接続します

import scratch_api.scratch_ws_api as scratch3  
conn = scratch3.login("USERNAME", "PASSWORD").connect(ProjectID, max_connections, isScratch)  

USERNAME: (string) あなたのユーザー名

PASSWORD: (string) あなたのパスワード

ProjectID: (int) あなたのプロジェクトのID (https://scratch.mit.edu/projects/{projectid})この部分がプロジェクトIDです

max_connections: (int) 最大同時送信数、この数の分、同時に変数を変更できます

isScratch: (boolean or string) TrueならScratch、FalseならTurbowarp、URLを入力すると特定のサーバーに接続できます。

Get Cloud Variable

conn.get(var_NAME)  

var_NAME: list 取得するクラウド変数の名前(例: ["Sample1", "Sample2"]) 戻り値: list 取得できなかった場合、Noneが返ります。 (例: [200, None]

補足 クラウド変数の取得のみの場合には、最大接続数は0でもOKです

Set Cloud Valiable

conn.set(var_NAME, var_VALUE)

var_NAME: list 変更するクラウド変数の名前(例: ["Sample1", "Sample2"]) var_VALUE: list 変更する数値 (intまたはstr)(例: ["20", 1304]

Sample

import random  
import scratch_api.scratch_ws_api as scratch3 

conn = scratch3.login("yosshi---_Cloudvar", ".Cloudsession").connect(846708650, 2, True)
conn.send(["1", "2"], [random.randint(1, 10), random.randint(1, 10)])  
print(conn.get(["1","2"]))

ランダムに変数を変更するだけの単純なプログラムです

https://scratch.mit.edu/projects/846708650 こちらがそのプロジェクトです

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scratch-websocket-api-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scratch_websocket_api-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file scratch-websocket-api-0.1.0.tar.gz.

File metadata

  • Download URL: scratch-websocket-api-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for scratch-websocket-api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb23eef79e7e5120810b0ba2a9c379ec85d74d33a039e0894ec1047533721d72
MD5 1a63a5f660ae00176b3d417617a1143a
BLAKE2b-256 7cca78ca8f1224e769007f7e3da452eff10c642a295fb45ebd3b6e1cb6595e4d

See more details on using hashes here.

File details

Details for the file scratch_websocket_api-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scratch_websocket_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 294f8010b45b46219a7a9c79fb4c1e98ce438e90c93949e94e30e4eb0f135674
MD5 634b46816172e64060adce41409fa460
BLAKE2b-256 00cccc5cafc30c71a5a9f307913bb3b1ed29bb6d4632a6cefca44a060e3f047a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page