py-mcws
MinecraftとPythonを繋げるためのシンプルなライブラリ
インストール
pip install py-mcws
使い方
import py_mcws
server = py_mcws.WebsocketServer()
@server.event
async def on_ready(host, port):
print("サーバーを起動しました。")
print(f"'/connect {host}:{port}' で接続できます")
@server.event
async def on_connect():
print("接続しました")
await server.command("say Hello World!") # メッセージを送信
@server.event
async def on_PlayerMessage(event):
print(event)
server.start(host="0.0.0.0", port=19132)
接続の仕方
Minecraft内のチャットで以下のコマンドを実行してください。
/connect host:port
イベントを受け取る
PlayerMessageイベントを受け取る例
@server.event
async def on_PlayerMessage(event):
print(event)
コマンドを実行する
Minecraft と接続している状態でコマンドを実行してください。
cmd = await server.command("say Hello World!")
print(cmd)
記事
以下の記事は、inunosinsiさんによる記事です。
thanks!
Metadata
Release files for py-mcws 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py-mcws-2.0.2.tar.gz | 5.8 kB | Without provenance | Details for py-mcws-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_mcws-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for py_mcws-2.0.2-py3-none-any.whl |
Total release size: 11.9 kB
Release files / py-mcws-2.0.2.tar.gz
| Download URL | py-mcws-2.0.2.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4888a6f44d93b497f044f9350528a4c3975951738bbe5f6ac3acf5bdf097a2ff
|
|
BLAKE2b-256 checksum How to use checksums |
bdbe7493949059641d203227022c5703d31d581beafaf66045c3fc5e2c533212
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / py_mcws-2.0.2-py3-none-any.whl
| Download URL | py_mcws-2.0.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37c7a484433c625a62cd1441a87f318186271181b264ac4fae05b253e832bb42
|
|
BLAKE2b-256 checksum How to use checksums |
15147fc7964b0bcf375bb06cec40f5c6733919a5acb4c977e650e3d79cb889c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for py-mcws 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.