Socket
Book a DemoInstallSign in
Socket

scratch-websocket-api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scratch-websocket-api

A API for scratch with websocket

0.1.7
pipPyPI
Maintainers
1

Scratch Websocket API

Overview

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

Installation

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

pip install scratch-websocket-api websocket-client requests

websocket-clientとrequestsはこのライブラリで必要なのでインストールしてください。

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---", "PASSWORD").connect(846708650, 2, True)
conn.send(["1", "2"], [random.randint(1, 10), random.randint(1, 10)])  
print(conn.get(["1","2"]))

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

こちらがそのプロジェクトです

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.