Skip to content

ekkx/yaylib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,177 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yaylib

yaylib

好きでつながるバーチャルワールド - Yay! の API ライブラリ

Go  TypeScript  Python

あらゆる操作の自動化や、ボットの開発が可能です。

Discord に参加

Yay! の API を Go / TypeScript / Python から扱うための非公式 SDK です。

インストール

go get github.com/ekkx/yaylib/v2   # Go
npm install yaylib                 # TypeScript
pip install yaylib                 # Python

クイックスタート (Go)

package main

import (
	"context"

	"github.com/ekkx/yaylib/v2"
)

func main() {
	ctx := context.Background()
	client := yaylib.NewClient()

	// ログイン(セッションは透過的にキャッシュされます)
	client.LoginWithEmail(ctx).Email("...").Password("...").Execute()

	// タイムラインを取得
	tl, _, _ := client.GetTimeline(ctx, yaylib.NoreplyModeFalse).Number(20).Execute()
	_ = tl

	// 投稿する
	client.CreatePost(ctx).
		XJwt(client.GenerateXJwt()).
		PostType("text").
		Text("hello from yaylib").
		Execute()
}

すべてのオペレーションは client.<Operation> として直接呼び出せます。

イベントストリーム

stream, _ := client.OpenEventStream(ctx)
sub, _ := stream.Subscribe(ctx, yaylib.ChatRoomChannel())

for ev := range sub.Events() {
	switch e := ev.(type) {
	case *yaylib.NewMessageEvent:
		// 新着メッセージを受信
		fmt.Println("new message:", e)
	}
}

サンプル

実行できるサンプルを examples/ に用意しています(全言語共通)。

  • 認証 + タイムライン取得
  • テキスト投稿
  • イベントストリームの簡単なボット
  • セッション永続化とエラー処理
YAY_EMAIL=... YAY_PASSWORD=... go run ./examples/go/timeline

⚖️ ライセンス

MIT © ekkx

About

nanameue, Inc. Yay! (イェイ) - API ライブラリ 🛠️

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors