BromineCore
MisskeyのWebsocketAPI単体の実装です。
ノートを講読したり、通知を取得したり。リバーシbotも頑張れば実装できます。
Example
簡単なタイムライン閲覧クライアントです。
トークン無しでタイムラインをリアルタイムで閲覧できます。
import asyncio
from brcore import Bromine, enum
INSTANCE = "misskey.io"
TL = enum.MisskeyChannelNames.LOCAL_TIMELINE
TL_ARGS = enum.MisskeyChannelArgs.LocalTimeline()
brm = Bromine(instance=INSTANCE)
def note_printer(note: dict) -> None:
"""ノートの情報を受け取って描画する関数"""
NOBASIBOU_LENGTH = 20
user = note["user"]
username = user["name"] if user["name"] is not None else user["username"]
print("-"*NOBASIBOU_LENGTH)
if note.get("renoteId") and note["text"] is None:
# リノートのときはリノート先だけ書く
print(f"{username}がリノート")
note_printer(note["renote"])
# リノートはリアクション数とか書きたくないので
# ここで返す
print("-"*NOBASIBOU_LENGTH)
return
else:
# 普通のノート
print(f"{username}が投稿しました。 noteid: {note['id']}")
if note.get("reply"):
# リプライがある場合
print("リプライ:")
note_printer(note["reply"])
if note.get("text"):
# 本文
print("テキスト:")
print(note["text"])
if note.get("renoteId"):
# 引用
print("引用:")
note_printer(note["renote"])
if len(note["files"]) != 0:
# ファイルがある時
print(f"ファイル数: {len(note['files'])}")
# リアクションとかを書く
print(f"リプライ数: {note['repliesCount']}, リノート数: {note['renoteCount']}, リアクション数: {note['reactionCount']}")
reactions = []
for reactionid, val in note["reactions"].items():
if reactionid[-3:] == "@.:":
# ローカルのカスタム絵文字のidはへんなのついてるので消す
reactionid = reactionid[:-3] + ":"
reactions.append(f"({reactionid}, {val})")
if len(reactions) != 0:
print("リアクション: ", ", ".join(reactions))
print("-"*NOBASIBOU_LENGTH)
@brm.ws_connect_deco(TL, **TL_ARGS)
async def note_async(note: dict) -> None:
note_printer(note["body"])
print() # 空白をノート後に入れておく
# デコレータを使わない場合は、下のように書くこともできる
# brm.ws_connect(TL, note_async, **TL_ARGS)
if __name__ == "__main__":
try:
print("start...")
asyncio.run(brm.main())
except KeyboardInterrupt:
print("fin")
Metadata
Release files for brominecore 1.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 |
|---|---|---|---|---|
| brominecore-1.2.tar.gz | 11.5 kB | Without provenance | Details for brominecore-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| brominecore-1.2-py3-none-any.whl | Python 3 | none | any | Details for brominecore-1.2-py3-none-any.whl |
Total release size: 23.5 kB
Release files / brominecore-1.2.tar.gz
| Download URL | brominecore-1.2.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2131b0b47c3d2a1c4b48c0bc427b55abcd288e8f880b7860bb1bb1e2e0b876a3
|
|
BLAKE2b-256 checksum How to use checksums |
9b60ecf9d25a34eb8588a08ed52cc40a2d086ada87d90b108ec9194e319b0f41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / brominecore-1.2-py3-none-any.whl
| Download URL | brominecore-1.2-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8619e7b5842078aa40b3204db917119905822b37ef5634d1e0756e1b502d1e6e
|
|
BLAKE2b-256 checksum How to use checksums |
34cc81092ef18e799fedb91cdcf9429c3bf5501fbdf02ced5b8eacc774f0b290
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for brominecore 1.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.