|
| 1 | +<div><a id="readme-top"></a></div> |
| 2 | +<div align="center"> |
| 3 | + <img src="https://img.shields.io/github/stars/ekkx/yaylib?style=for-the-badge&logo=appveyor&color=blue" /> |
| 4 | + <img src="https://img.shields.io/github/forks/ekkx/yaylib?style=for-the-badge&logo=appveyor&color=blue" /> |
| 5 | + <img src="https://img.shields.io/github/issues/ekkx/yaylib?style=for-the-badge&logo=appveyor&color=informational" /> |
| 6 | + <img src="https://img.shields.io/github/issues-pr/ekkx/yaylib?style=for-the-badge&logo=appveyor&color=informational" /> |
| 7 | +</div> |
| 8 | +<br /> |
| 9 | +<p align="center"> |
| 10 | + <a href="https://github.com/othneildrew/Best-README-Template"> |
| 11 | + <img src="https://github.com/ekkx/yaylib/assets/77382767/45c45b21-d812-4cad-8f27-315ffef53201" alt="Logo" height="300px"> |
| 12 | + </a> |
| 13 | + <h3 align="center">yaylib</h3> |
| 14 | + <p align="center"> |
| 15 | + 同世代とつながる通話コミュニティ - Yay!(イェイ)の API ライブラリ<br /> |
| 16 | + あらゆる操作の自動化や、ボットの開発が可能です。 |
| 17 | + <br /> |
| 18 | + <br /> |
| 19 | + <a href="https://github.com/ekkx/yay.js"> |
| 20 | + <strong>Node.js 版はこちらから »</strong> |
| 21 | + </a> |
| 22 | + <br /> |
| 23 | + <br /> |
| 24 | + <a href="https://github.com/ekkx/yaylib/issues">Report Bug</a> |
| 25 | + · |
| 26 | + <a href="https://github.com/ekkx/yaylib/issues">Request Feature</a> |
| 27 | + · |
| 28 | + <a href="https://discord.gg/MEuBfNtqRN">Join the discord</a> |
| 29 | + </p> |
| 30 | +</p> |
| 31 | + |
| 32 | +> **利用者の皆様へ**<br /> > **2024 年 5 月 1 日をもちまして、「好きでつながるバーチャルワールド Yay!(イェイ)」のライブラリである [yaylib](https://github.com/ekkx/yaylib) 及び [yay.js](https://github.com/ekkx/yay.js) のソースコードは一時的に非公開となります。それに伴い、これらのライブラリのアップデートやメンテナンスも一時停止いたします。<br />利用者の皆様にはご迷惑をおかけしますがご理解のほどよろしくお願いいたします。**<br />連絡先: [[email protected]](mailto:[email protected]) |
| 33 | +
|
| 34 | +<!-- TABLE OF CONTENTS --> |
| 35 | + |
| 36 | +<details> |
| 37 | + <summary>Table of Contents</summary> |
| 38 | + <ol> |
| 39 | + <li><a href="#buy-me-a-coffee">Buy me a coffee</a></li> |
| 40 | + <li><a href="#-installation">インストール</a></li> |
| 41 | + <li><a href="#-quick-example">使用例</a></li> |
| 42 | + <li><a href="#crown-yaylib-で誕生したロボットたち">yaylib で誕生したロボットたち</a></li> |
| 43 | + <li><a href="#handshake-共同開発について">共同開発について</a></li> |
| 44 | + <li><a href="#免責事項">免責事項</a></li> |
| 45 | + <li><a href="#利用許諾">利用許諾</a></li> |
| 46 | + </ol> |
| 47 | +</details> |
| 48 | + |
| 49 | +<!-- Buy me a coffee --> |
| 50 | + |
| 51 | +## Buy me a coffee |
| 52 | + |
| 53 | +このライブラリが気に入っていただけたら、<a href="https://github.com/ekkx/yaylib/">**リポジトリにスターをお願いします</a>(⭐)** |
| 54 | +また、Buy Me a Coffee からご支援いただけますと幸いです。 |
| 55 | + |
| 56 | +<a href="https://www.buymeacoffee.com/qvco" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a> |
| 57 | + |
| 58 | +<!-- 使用例 --> |
| 59 | + |
| 60 | +## [<img src="https://github.com/ekkx/yaylib/assets/77382767/dc7dcea0-c581-4039-8fc2-3994884d2ba3" width="30" height="30" />](https://github.com/ekkx) Quick Example |
| 61 | + |
| 62 | +#### ✨ 投稿を作成する |
| 63 | + |
| 64 | +```python |
| 65 | +import yaylib |
| 66 | + |
| 67 | +client = yaylib.Client() |
| 68 | +client.login(email="your_email", password="your_password") |
| 69 | + |
| 70 | +client.create_post("Hello with yaylib!") |
| 71 | +``` |
| 72 | + |
| 73 | +#### ✨ 埋め込みリンクの投稿を作成する |
| 74 | + |
| 75 | +```python |
| 76 | +import yaylib |
| 77 | + |
| 78 | +client = yaylib.Client() |
| 79 | +client.login(email="your_email", password="your_password") |
| 80 | + |
| 81 | +client.create_post("Hello with yaylib!", shared_url="https://github.com/ekkx/yaylib") |
| 82 | +``` |
| 83 | + |
| 84 | +#### ✨ 画像と一緒に投稿を作成する |
| 85 | + |
| 86 | +```python |
| 87 | +import yaylib |
| 88 | + |
| 89 | +client = yaylib.Client() |
| 90 | +client.login(email="your_email", password="your_password") |
| 91 | + |
| 92 | +# 画像のパスを指定 |
| 93 | +image_paths = [ |
| 94 | + "./test1.jpg", |
| 95 | + "./test2.jpg", |
| 96 | + "./test3.jpg", |
| 97 | +] |
| 98 | + |
| 99 | +# 画像の使い道を指定 |
| 100 | +image_type = yaylib.ImageType.post |
| 101 | + |
| 102 | +# サーバー上にアップロード |
| 103 | +attachments = client.upload_image(image_paths, image_type) |
| 104 | + |
| 105 | +# サーバー上のファイル名を指定する |
| 106 | +# attachmentsが一つ飛ばしなのはオリジナル品質の画像のみを指定するため |
| 107 | +client.create_post( |
| 108 | + "Hello with yaylib!", |
| 109 | + attachment_filename=attachments[0].filename, |
| 110 | + attachment_2_filename=attachments[2].filename, |
| 111 | + attachment_3_filename=attachments[4].filename, |
| 112 | +) |
| 113 | +``` |
| 114 | + |
| 115 | +#### ✨ タイムラインを 100 件取得する |
| 116 | + |
| 117 | +```python |
| 118 | +import yaylib |
| 119 | + |
| 120 | +client = yaylib.Client() |
| 121 | + |
| 122 | +timeline = client.get_timeline(number=100) |
| 123 | + |
| 124 | +for post in timeline.posts: |
| 125 | + print(post.user.nickname) # 投稿者名 |
| 126 | + print(post.text) # 本文 |
| 127 | + print(post.likes_count) # いいね数 |
| 128 | + print(post.reposts_count) # (´∀`∩)↑age↑の数 |
| 129 | + print(post.in_reply_to_post_count) # 返信の数 |
| 130 | +``` |
| 131 | + |
| 132 | +#### ✨ タイムラインをキーワードで検索して「いいね」する |
| 133 | + |
| 134 | +```python |
| 135 | +import yaylib |
| 136 | + |
| 137 | +client = yaylib.Client() |
| 138 | +client.login(email="your_email", password="your_password") |
| 139 | + |
| 140 | +timeline = client.get_timeline_by_keyword( |
| 141 | + keyword="プログラミング", |
| 142 | + number=15 |
| 143 | +) |
| 144 | + |
| 145 | +for post in timeline.posts: |
| 146 | + client.like(post.id) |
| 147 | +``` |
| 148 | + |
| 149 | +#### ✨ 新規ユーザーをフォローする |
| 150 | + |
| 151 | +```python |
| 152 | +import yaylib |
| 153 | + |
| 154 | +client = yaylib.Client() |
| 155 | +client.login(email="your_email", password="your_password") |
| 156 | + |
| 157 | +new_users = client.search_users(recently_created=True) |
| 158 | + |
| 159 | +for new_user in new_users.users: |
| 160 | + client.follow_user(new_user.id) |
| 161 | +``` |
| 162 | + |
| 163 | +#### ✨ リアルタイムでチャットを取得する |
| 164 | + |
| 165 | +```python |
| 166 | +import yaylib |
| 167 | +from yaylib import Message |
| 168 | + |
| 169 | +class MyBot(yaylib.Client): |
| 170 | + def on_ready(self): |
| 171 | + print("ボットがオンラインになりました!") |
| 172 | + |
| 173 | + def on_chat_request(self, total_count): |
| 174 | + # チャットリクエストはすべて承認する |
| 175 | + chat_requests = self.get_chat_requests() |
| 176 | + for chat_room in chat_requests.chat_rooms: |
| 177 | + self.accept_chat_requests([chat_room.id]) |
| 178 | + |
| 179 | + # 最新のメッセージをon_message_create関数に送信 |
| 180 | + message = self.get_messages(chat_requests.chat_rooms[0].id) |
| 181 | + self.on_message_create(message[0]) |
| 182 | + |
| 183 | + def on_message_create(self, message: Message): |
| 184 | + # 「ping」というメッセージに対して「pong」と返信する |
| 185 | + if message.text == "ping": |
| 186 | + self.send_message(message.room_id, text="pong") |
| 187 | + |
| 188 | + def on_chat_room_delete(self, room_id): |
| 189 | + print(f"チャットルームが削除されました。ルームID: {room_id}") |
| 190 | + |
| 191 | +intents = yaylib.Intents.none() |
| 192 | +intents.chat_message = True |
| 193 | + |
| 194 | +bot = MyBot(intents=intents) |
| 195 | +bot.run("your_email", "your_password") |
| 196 | +``` |
| 197 | + |
| 198 | +より詳しい使用例については、[こちら](https://github.com/ekkx/yaylib/blob/master/examples) を参照してください。 |
| 199 | + |
| 200 | +<p align="right">(<a href="#readme-top">トップに戻る</a>)</p> |
| 201 | + |
| 202 | +<!-- yaylib で誕生したボットの一覧 --> |
| 203 | + |
| 204 | +## :crown: yaylib で誕生したロボットたち |
| 205 | + |
| 206 | +「yaylib」を用いて開発したロボットがある場合は、ぜひ教えてください! |
| 207 | + |
| 208 | +<table align="center"> |
| 209 | + <thead> |
| 210 | + <tr> |
| 211 | + <th><a href="https://yay.space/user/5855987">MindReader AI</a></th> |
| 212 | + <th><a href="https://yay.space/user/7874560">☀️気象くん☁️</a></th> |
| 213 | + <th><a href="https://yay.space/user/7406336">GIGAZINE</a></th> |
| 214 | + </tr> |
| 215 | + </thead> |
| 216 | + <tbody> |
| 217 | + <tr> |
| 218 | + <td align="center"> |
| 219 | + <img src="https://github.com/ekkx/yaylib/assets/77382767/cc41ce3c-0e11-4ec5-be99-ff7090a95667" width="200px"> |
| 220 | + <br /> |
| 221 | + <p>開発者: <a href="https://yay.space/user/35152">毛の可能性</a></p> |
| 222 | + </td> |
| 223 | + <td align="center"> |
| 224 | + <img src="https://github.com/ekkx/yaylib/assets/77382767/4fd728a0-9b3a-427f-ac1f-70e6d6538564" width="200px"> |
| 225 | + <br /> |
| 226 | + <p>開発者: <a href="https://yay.space/user/7520368">tori</a></p> |
| 227 | + </td> |
| 228 | + <td align="center"> |
| 229 | + <img src="https://github.com/ekkx/yaylib/assets/77382767/65fcb885-4fbe-4170-9378-6f8d9af61ff8" width="200px"> |
| 230 | + <br /> |
| 231 | + <p>開発者: <a href="https://yay.space/user/1298298">ぺゅー</a></p> |
| 232 | + </td> |
| 233 | + </tr> |
| 234 | + </tbody> |
| 235 | +</table> |
| 236 | + |
| 237 | +<!-- 免責事項 --> |
| 238 | + |
| 239 | +## 免責事項 |
| 240 | + |
| 241 | +yaylib は、API の公式なサポートやメンテナンスを提供するものではありません。このクライアントを使用する場合、**利用者はリスクや責任を自己負担できるもの**とします。このクライアントによって提供される情報やデータの正確性、信頼性、完全性、適時性について、いかなる保証も行いません。また、このクライアントの使用によって生じた損害や不利益について、一切の責任を負いかねます。利用者は自己の責任において、このクライアントを使用し、API にアクセスするものとします。なお、この免責事項は予告なく変更される場合があります。 |
| 242 | + |
| 243 | +<!-- ライセンス --> |
| 244 | + |
| 245 | +## ライセンス |
| 246 | + |
| 247 | +<p align="center"> |
| 248 | + <a href="https://github.com/ekkx"> |
| 249 | + <img src="https://github.com/ekkx/yaylib/assets/77382767/5d6aef18-5d98-4c9b-9f54-791308b393af" width="256" height="256"> |
| 250 | + </a> |
| 251 | +</p> |
| 252 | + |
| 253 | +<p align="center"> |
| 254 | + <strong>MIT © <a href="https://github.com/ekkx">ekkx</a></strong> |
| 255 | +</p> |
| 256 | + |
| 257 | +フルライセンスは [こちら](https://github.com/ekkx/yaylib/blob/master/LICENSE) からご確認いただけます。 |
| 258 | +このプロジェクトは、 **【MIT ライセンス】** の条件の下でライセンスされています。 |
| 259 | + |
| 260 | +<p align="right">(<a href="#readme-top">トップに戻る</a>)</p> |
0 commit comments