yaylib 1.5.0b2__tar.gz → 1.5.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/PKG-INFO +127 -84
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/README.md +126 -82
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/pyproject.toml +0 -1
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/__init__.py +1 -8
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/auth.py +8 -10
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/group.py +10 -16
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/misc.py +3 -3
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/post.py +36 -66
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/user.py +18 -27
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/client.py +13 -55
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/device.py +3 -10
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/errors.py +3 -8
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/models.py +66 -68
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/responses.py +90 -61
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/utils.py +1 -1
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/LICENSE +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/__init__.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/call.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/chat.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/notification.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/review.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/api/thread.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/config.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/constants.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/state.py +0 -0
- {yaylib-1.5.0b2 → yaylib-1.5.0.dev1}/yaylib/ws.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: yaylib
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.0.dev1
|
|
4
4
|
Summary: 同世代と趣味の通話コミュニティ - Yay! (イェイ) で投稿やタイムラインの取得、リツイートやいいねの実行、フォローや投稿の検索など様々な機能をPythonプログラムから利用可能なAPIクライアントツールです。
|
|
5
5
|
Home-page: https://github.com/ekkx/yaylib
|
|
6
6
|
License: MIT
|
|
@@ -15,7 +15,6 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
15
15
|
Requires-Dist: aiohttp (==3.9.5)
|
|
16
16
|
Requires-Dist: cryptography (==41.0.1)
|
|
17
17
|
Requires-Dist: pillow (==9.3.0)
|
|
18
|
-
Requires-Dist: poetry-version-plugin (>=0.2.0,<0.3.0)
|
|
19
18
|
Project-URL: Repository, https://github.com/ekkx/yaylib
|
|
20
19
|
Description-Content-Type: text/markdown
|
|
21
20
|
|
|
@@ -28,7 +27,7 @@ Description-Content-Type: text/markdown
|
|
|
28
27
|
</div>
|
|
29
28
|
<br />
|
|
30
29
|
<p align="center">
|
|
31
|
-
<a href="https://
|
|
30
|
+
<a href="https://github.com/othneildrew/Best-README-Template">
|
|
32
31
|
<img src="https://github.com/ekkx/yaylib/assets/77382767/45c45b21-d812-4cad-8f27-315ffef53201" alt="Logo" height="300px">
|
|
33
32
|
</a>
|
|
34
33
|
<h3 align="center">yaylib</h3>
|
|
@@ -42,78 +41,87 @@ Description-Content-Type: text/markdown
|
|
|
42
41
|
</a>
|
|
43
42
|
<br />
|
|
44
43
|
<br />
|
|
45
|
-
<a href="https://
|
|
44
|
+
<a href="https://github.com/ekkx/yaylib/issues">Report Bug</a>
|
|
46
45
|
·
|
|
47
|
-
<a href="https://github.com/ekkx/yaylib/issues
|
|
46
|
+
<a href="https://github.com/ekkx/yaylib/issues">Request Feature</a>
|
|
48
47
|
·
|
|
49
|
-
<a href="https://discord.gg/MEuBfNtqRN">
|
|
48
|
+
<a href="https://discord.gg/MEuBfNtqRN">Join the discord</a>
|
|
50
49
|
</p>
|
|
51
50
|
</p>
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
<!-- TABLE OF CONTENTS -->
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>Table of Contents</summary>
|
|
56
|
+
<ol>
|
|
57
|
+
<li><a href="#buy-me-a-coffee">Buy me a coffee</a></li>
|
|
58
|
+
<li><a href="#-installation">インストール</a></li>
|
|
59
|
+
<li><a href="#-quick-example">使用例</a></li>
|
|
60
|
+
<li><a href="#crown-yaylib-で誕生したロボットたち">yaylib で誕生したロボットたち</a></li>
|
|
61
|
+
<li><a href="#handshake-共同開発について">共同開発について</a></li>
|
|
62
|
+
<li><a href="#免責事項">免責事項</a></li>
|
|
63
|
+
<li><a href="#利用許諾">利用許諾</a></li>
|
|
64
|
+
</ol>
|
|
65
|
+
</details>
|
|
66
|
+
|
|
67
|
+
<!-- Buy me a coffee -->
|
|
68
|
+
|
|
69
|
+
## Buy me a coffee
|
|
70
|
+
|
|
71
|
+
このライブラリが気に入っていただけたら、<a href="https://github.com/ekkx/yaylib/">**リポジトリにスターをお願いします</a>(⭐)**
|
|
72
|
+
また、Buy Me a Coffee からご支援いただけますと幸いです。
|
|
73
|
+
|
|
74
|
+
<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>
|
|
54
75
|
|
|
55
76
|
<!-- インストール -->
|
|
56
77
|
|
|
57
78
|
## [<img src="https://github.com/ekkx/yaylib/assets/77382767/2f632349-0cbc-4c81-bc19-11d24c8c142b" width="30" height="30" />](https://github.com/ekkx) Installation
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
**※ Python 3.10 以上のバージョンが必要です。**
|
|
81
|
+
|
|
82
|
+
「yaylib」をインストールするには、以下のコマンドをターミナル上で実行します:
|
|
60
83
|
|
|
61
84
|
```shell
|
|
62
85
|
pip install yaylib
|
|
63
86
|
```
|
|
64
87
|
|
|
65
|
-
> [!TIP]
|
|
66
|
-
> 動作条件は `Python 3.10` 以上からです。
|
|
67
|
-
|
|
68
88
|
<br>
|
|
69
89
|
|
|
70
|
-
|
|
90
|
+
> [!TIP]
|
|
91
|
+
> 開発環境をインストールする場合は、以下の手順を実行します:
|
|
71
92
|
|
|
72
|
-
|
|
93
|
+
```shell
|
|
94
|
+
git clone https://github.com/ekkx/yaylib.git
|
|
73
95
|
|
|
74
|
-
|
|
96
|
+
cd yaylib
|
|
75
97
|
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
make up
|
|
99
|
+
```
|
|
78
100
|
|
|
79
|
-
|
|
80
|
-
bot.login('your_email', 'your_password')
|
|
101
|
+
<!-- 使用例 -->
|
|
81
102
|
|
|
82
|
-
|
|
83
|
-
```
|
|
103
|
+
## [<img src="https://github.com/ekkx/yaylib/assets/77382767/dc7dcea0-c581-4039-8fc2-3994884d2ba3" width="30" height="30" />](https://github.com/ekkx) Quick Example
|
|
84
104
|
|
|
85
|
-
#### ✨
|
|
105
|
+
#### ✨ 投稿を作成する
|
|
86
106
|
|
|
87
107
|
```python
|
|
88
108
|
import yaylib
|
|
89
109
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
timeline = bot.get_timeline(number=100)
|
|
110
|
+
client = yaylib.Client()
|
|
111
|
+
client.login(email="your_email", password="your_password")
|
|
93
112
|
|
|
94
|
-
|
|
95
|
-
print(post.user.nickname) # 投稿者名
|
|
96
|
-
print(post.text) # 本文
|
|
97
|
-
print(post.likes_count) # いいね数
|
|
98
|
-
print(post.reposts_count) # (´∀`∩)↑age↑の数
|
|
99
|
-
print(post.in_reply_to_post_count) # 返信の数
|
|
113
|
+
client.create_post("Hello with yaylib!")
|
|
100
114
|
```
|
|
101
115
|
|
|
102
|
-
#### ✨
|
|
116
|
+
#### ✨ 埋め込みリンクの投稿を作成する
|
|
103
117
|
|
|
104
118
|
```python
|
|
105
119
|
import yaylib
|
|
106
120
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
timeline = bot.get_timeline_by_keyword(
|
|
111
|
-
keyword='プログラミング',
|
|
112
|
-
number=15
|
|
113
|
-
)
|
|
121
|
+
client = yaylib.Client()
|
|
122
|
+
client.login(email="your_email", password="your_password")
|
|
114
123
|
|
|
115
|
-
|
|
116
|
-
bot.like(post.id)
|
|
124
|
+
client.create_post("Hello with yaylib!", shared_url="https://github.com/ekkx/yaylib")
|
|
117
125
|
```
|
|
118
126
|
|
|
119
127
|
#### ✨ 画像と一緒に投稿を作成する
|
|
@@ -121,87 +129,122 @@ for post in timeline.posts:
|
|
|
121
129
|
```python
|
|
122
130
|
import yaylib
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
client = yaylib.Client()
|
|
133
|
+
client.login(email="your_email", password="your_password")
|
|
126
134
|
|
|
127
135
|
# 画像のパスを指定
|
|
128
136
|
image_paths = [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
"./test1.jpg",
|
|
138
|
+
"./test2.jpg",
|
|
139
|
+
"./test3.jpg",
|
|
132
140
|
]
|
|
133
141
|
|
|
134
142
|
# 画像の使い道を指定
|
|
135
|
-
image_type = yaylib.ImageType.
|
|
143
|
+
image_type = yaylib.ImageType.post
|
|
136
144
|
|
|
137
145
|
# サーバー上にアップロード
|
|
138
|
-
attachments =
|
|
146
|
+
attachments = client.upload_image(image_paths, image_type)
|
|
139
147
|
|
|
140
148
|
# サーバー上のファイル名を指定する
|
|
141
149
|
# attachmentsが一つ飛ばしなのはオリジナル品質の画像のみを指定するため
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
client.create_post(
|
|
151
|
+
"Hello with yaylib!",
|
|
144
152
|
attachment_filename=attachments[0].filename,
|
|
145
153
|
attachment_2_filename=attachments[2].filename,
|
|
146
154
|
attachment_3_filename=attachments[4].filename,
|
|
147
155
|
)
|
|
148
156
|
```
|
|
149
157
|
|
|
158
|
+
#### ✨ タイムラインを 100 件取得する
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
import yaylib
|
|
162
|
+
|
|
163
|
+
client = yaylib.Client()
|
|
164
|
+
|
|
165
|
+
timeline = client.get_timeline(number=100)
|
|
166
|
+
|
|
167
|
+
for post in timeline.posts:
|
|
168
|
+
print(post.user.nickname) # 投稿者名
|
|
169
|
+
print(post.text) # 本文
|
|
170
|
+
print(post.likes_count) # いいね数
|
|
171
|
+
print(post.reposts_count) # (´∀`∩)↑age↑の数
|
|
172
|
+
print(post.in_reply_to_post_count) # 返信の数
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### ✨ タイムラインをキーワードで検索して「いいね」する
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
import yaylib
|
|
179
|
+
|
|
180
|
+
client = yaylib.Client()
|
|
181
|
+
client.login(email="your_email", password="your_password")
|
|
182
|
+
|
|
183
|
+
timeline = client.get_timeline_by_keyword(
|
|
184
|
+
keyword="プログラミング",
|
|
185
|
+
number=15
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
for post in timeline.posts:
|
|
189
|
+
client.like(post.id)
|
|
190
|
+
```
|
|
191
|
+
|
|
150
192
|
#### ✨ 新規ユーザーをフォローする
|
|
151
193
|
|
|
152
194
|
```python
|
|
153
195
|
import yaylib
|
|
154
196
|
|
|
155
|
-
|
|
156
|
-
|
|
197
|
+
client = yaylib.Client()
|
|
198
|
+
client.login(email="your_email", password="your_password")
|
|
157
199
|
|
|
158
|
-
new_users =
|
|
200
|
+
new_users = client.search_users(recently_created=True)
|
|
159
201
|
|
|
160
202
|
for new_user in new_users.users:
|
|
161
|
-
|
|
203
|
+
client.follow_user(new_user.id)
|
|
162
204
|
```
|
|
163
205
|
|
|
164
206
|
#### ✨ リアルタイムでチャットを取得する
|
|
165
207
|
|
|
166
208
|
```python
|
|
167
209
|
import yaylib
|
|
210
|
+
from yaylib import Message
|
|
168
211
|
|
|
169
|
-
class
|
|
170
|
-
|
|
171
|
-
print(
|
|
212
|
+
class MyBot(yaylib.Client):
|
|
213
|
+
def on_ready(self):
|
|
214
|
+
print("ボットがオンラインになりました!")
|
|
172
215
|
|
|
173
|
-
|
|
174
|
-
#
|
|
175
|
-
chat_requests =
|
|
216
|
+
def on_chat_request(self, total_count):
|
|
217
|
+
# チャットリクエストはすべて承認する
|
|
218
|
+
chat_requests = self.get_chat_requests()
|
|
176
219
|
for chat_room in chat_requests.chat_rooms:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
220
|
+
self.accept_chat_requests([chat_room.id])
|
|
221
|
+
|
|
222
|
+
# 最新のメッセージをon_message_create関数に送信
|
|
223
|
+
message = self.get_messages(chat_requests.chat_rooms[0].id)
|
|
224
|
+
self.on_message_create(message[0])
|
|
180
225
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
text='pong',
|
|
186
|
-
)
|
|
226
|
+
def on_message_create(self, message: Message):
|
|
227
|
+
# 「ping」というメッセージに対して「pong」と返信する
|
|
228
|
+
if message.text == "ping":
|
|
229
|
+
self.send_message(message.room_id, text="pong")
|
|
187
230
|
|
|
188
|
-
|
|
189
|
-
print(f
|
|
231
|
+
def on_chat_room_delete(self, room_id):
|
|
232
|
+
print(f"チャットルームが削除されました。ルームID: {room_id}")
|
|
190
233
|
|
|
191
234
|
intents = yaylib.Intents.none()
|
|
192
235
|
intents.chat_message = True
|
|
193
236
|
|
|
194
|
-
bot =
|
|
195
|
-
bot.run(
|
|
237
|
+
bot = MyBot(intents=intents)
|
|
238
|
+
bot.run("your_email", "your_password")
|
|
196
239
|
```
|
|
197
240
|
|
|
198
|
-
より詳しい使用例については、[
|
|
241
|
+
より詳しい使用例については、[こちら](https://github.com/ekkx/yaylib/blob/master/examples) を参照してください。
|
|
199
242
|
|
|
200
|
-
<
|
|
243
|
+
<p align="right">(<a href="#readme-top">トップに戻る</a>)</p>
|
|
201
244
|
|
|
202
245
|
<!-- yaylib で誕生したボットの一覧 -->
|
|
203
246
|
|
|
204
|
-
##
|
|
247
|
+
## :crown: yaylib で誕生したロボットたち
|
|
205
248
|
|
|
206
249
|
「yaylib」を用いて開発したロボットがある場合は、ぜひ教えてください!
|
|
207
250
|
|
|
@@ -234,27 +277,27 @@ bot.run('your_email', 'your_password')
|
|
|
234
277
|
</tbody>
|
|
235
278
|
</table>
|
|
236
279
|
|
|
237
|
-
<br>
|
|
238
|
-
|
|
239
280
|
<!-- 共同開発について -->
|
|
240
281
|
|
|
241
|
-
##
|
|
282
|
+
## :handshake: 共同開発について
|
|
242
283
|
|
|
243
|
-
|
|
284
|
+
私たちと開発することに興味を持っていただけているなら、ぜひ参加して頂きたいです!
|
|
244
285
|
|
|
245
|
-
|
|
286
|
+
- [プルリクエストを送信する](https://github.com/ekkx/yaylib/pulls)
|
|
287
|
+
- [Discord サーバーに参加する](https://discord.gg/MEuBfNtqRN)
|
|
288
|
+
- [nikola.desuga@gmail.com](mailto:nikola.desuga@gmail.com) にメールを送信する
|
|
289
|
+
|
|
290
|
+
のいずれかの方法で繋がりましょう。詳しくは[こちらから](https://github.com/ekkx/yaylib/blob/master/CONTRIBUTING.md)!
|
|
246
291
|
|
|
247
292
|
<!-- 免責事項 -->
|
|
248
293
|
|
|
249
|
-
##
|
|
294
|
+
## 免責事項
|
|
250
295
|
|
|
251
296
|
yaylib は、API の公式なサポートやメンテナンスを提供するものではありません。このクライアントを使用する場合、**利用者はリスクや責任を自己負担できるもの**とします。このクライアントによって提供される情報やデータの正確性、信頼性、完全性、適時性について、いかなる保証も行いません。また、このクライアントの使用によって生じた損害や不利益について、一切の責任を負いかねます。利用者は自己の責任において、このクライアントを使用し、API にアクセスするものとします。なお、この免責事項は予告なく変更される場合があります。
|
|
252
297
|
|
|
253
|
-
<br>
|
|
254
|
-
|
|
255
298
|
<!-- ライセンス -->
|
|
256
299
|
|
|
257
|
-
##
|
|
300
|
+
## ライセンス
|
|
258
301
|
|
|
259
302
|
<p align="center">
|
|
260
303
|
<a href="https://github.com/ekkx">
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
<br />
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://
|
|
10
|
+
<a href="https://github.com/othneildrew/Best-README-Template">
|
|
11
11
|
<img src="https://github.com/ekkx/yaylib/assets/77382767/45c45b21-d812-4cad-8f27-315ffef53201" alt="Logo" height="300px">
|
|
12
12
|
</a>
|
|
13
13
|
<h3 align="center">yaylib</h3>
|
|
@@ -21,78 +21,87 @@
|
|
|
21
21
|
</a>
|
|
22
22
|
<br />
|
|
23
23
|
<br />
|
|
24
|
-
<a href="https://
|
|
24
|
+
<a href="https://github.com/ekkx/yaylib/issues">Report Bug</a>
|
|
25
25
|
·
|
|
26
|
-
<a href="https://github.com/ekkx/yaylib/issues
|
|
26
|
+
<a href="https://github.com/ekkx/yaylib/issues">Request Feature</a>
|
|
27
27
|
·
|
|
28
|
-
<a href="https://discord.gg/MEuBfNtqRN">
|
|
28
|
+
<a href="https://discord.gg/MEuBfNtqRN">Join the discord</a>
|
|
29
29
|
</p>
|
|
30
30
|
</p>
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
<!-- TABLE OF CONTENTS -->
|
|
33
|
+
|
|
34
|
+
<details>
|
|
35
|
+
<summary>Table of Contents</summary>
|
|
36
|
+
<ol>
|
|
37
|
+
<li><a href="#buy-me-a-coffee">Buy me a coffee</a></li>
|
|
38
|
+
<li><a href="#-installation">インストール</a></li>
|
|
39
|
+
<li><a href="#-quick-example">使用例</a></li>
|
|
40
|
+
<li><a href="#crown-yaylib-で誕生したロボットたち">yaylib で誕生したロボットたち</a></li>
|
|
41
|
+
<li><a href="#handshake-共同開発について">共同開発について</a></li>
|
|
42
|
+
<li><a href="#免責事項">免責事項</a></li>
|
|
43
|
+
<li><a href="#利用許諾">利用許諾</a></li>
|
|
44
|
+
</ol>
|
|
45
|
+
</details>
|
|
46
|
+
|
|
47
|
+
<!-- Buy me a coffee -->
|
|
48
|
+
|
|
49
|
+
## Buy me a coffee
|
|
50
|
+
|
|
51
|
+
このライブラリが気に入っていただけたら、<a href="https://github.com/ekkx/yaylib/">**リポジトリにスターをお願いします</a>(⭐)**
|
|
52
|
+
また、Buy Me a Coffee からご支援いただけますと幸いです。
|
|
53
|
+
|
|
54
|
+
<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>
|
|
33
55
|
|
|
34
56
|
<!-- インストール -->
|
|
35
57
|
|
|
36
58
|
## [<img src="https://github.com/ekkx/yaylib/assets/77382767/2f632349-0cbc-4c81-bc19-11d24c8c142b" width="30" height="30" />](https://github.com/ekkx) Installation
|
|
37
59
|
|
|
38
|
-
|
|
60
|
+
**※ Python 3.10 以上のバージョンが必要です。**
|
|
61
|
+
|
|
62
|
+
「yaylib」をインストールするには、以下のコマンドをターミナル上で実行します:
|
|
39
63
|
|
|
40
64
|
```shell
|
|
41
65
|
pip install yaylib
|
|
42
66
|
```
|
|
43
67
|
|
|
44
|
-
> [!TIP]
|
|
45
|
-
> 動作条件は `Python 3.10` 以上からです。
|
|
46
|
-
|
|
47
68
|
<br>
|
|
48
69
|
|
|
49
|
-
|
|
70
|
+
> [!TIP]
|
|
71
|
+
> 開発環境をインストールする場合は、以下の手順を実行します:
|
|
50
72
|
|
|
51
|
-
|
|
73
|
+
```shell
|
|
74
|
+
git clone https://github.com/ekkx/yaylib.git
|
|
52
75
|
|
|
53
|
-
|
|
76
|
+
cd yaylib
|
|
54
77
|
|
|
55
|
-
|
|
56
|
-
|
|
78
|
+
make up
|
|
79
|
+
```
|
|
57
80
|
|
|
58
|
-
|
|
59
|
-
bot.login('your_email', 'your_password')
|
|
81
|
+
<!-- 使用例 -->
|
|
60
82
|
|
|
61
|
-
|
|
62
|
-
```
|
|
83
|
+
## [<img src="https://github.com/ekkx/yaylib/assets/77382767/dc7dcea0-c581-4039-8fc2-3994884d2ba3" width="30" height="30" />](https://github.com/ekkx) Quick Example
|
|
63
84
|
|
|
64
|
-
#### ✨
|
|
85
|
+
#### ✨ 投稿を作成する
|
|
65
86
|
|
|
66
87
|
```python
|
|
67
88
|
import yaylib
|
|
68
89
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
timeline = bot.get_timeline(number=100)
|
|
90
|
+
client = yaylib.Client()
|
|
91
|
+
client.login(email="your_email", password="your_password")
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
print(post.user.nickname) # 投稿者名
|
|
75
|
-
print(post.text) # 本文
|
|
76
|
-
print(post.likes_count) # いいね数
|
|
77
|
-
print(post.reposts_count) # (´∀`∩)↑age↑の数
|
|
78
|
-
print(post.in_reply_to_post_count) # 返信の数
|
|
93
|
+
client.create_post("Hello with yaylib!")
|
|
79
94
|
```
|
|
80
95
|
|
|
81
|
-
#### ✨
|
|
96
|
+
#### ✨ 埋め込みリンクの投稿を作成する
|
|
82
97
|
|
|
83
98
|
```python
|
|
84
99
|
import yaylib
|
|
85
100
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
timeline = bot.get_timeline_by_keyword(
|
|
90
|
-
keyword='プログラミング',
|
|
91
|
-
number=15
|
|
92
|
-
)
|
|
101
|
+
client = yaylib.Client()
|
|
102
|
+
client.login(email="your_email", password="your_password")
|
|
93
103
|
|
|
94
|
-
|
|
95
|
-
bot.like(post.id)
|
|
104
|
+
client.create_post("Hello with yaylib!", shared_url="https://github.com/ekkx/yaylib")
|
|
96
105
|
```
|
|
97
106
|
|
|
98
107
|
#### ✨ 画像と一緒に投稿を作成する
|
|
@@ -100,87 +109,122 @@ for post in timeline.posts:
|
|
|
100
109
|
```python
|
|
101
110
|
import yaylib
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
client = yaylib.Client()
|
|
113
|
+
client.login(email="your_email", password="your_password")
|
|
105
114
|
|
|
106
115
|
# 画像のパスを指定
|
|
107
116
|
image_paths = [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
"./test1.jpg",
|
|
118
|
+
"./test2.jpg",
|
|
119
|
+
"./test3.jpg",
|
|
111
120
|
]
|
|
112
121
|
|
|
113
122
|
# 画像の使い道を指定
|
|
114
|
-
image_type = yaylib.ImageType.
|
|
123
|
+
image_type = yaylib.ImageType.post
|
|
115
124
|
|
|
116
125
|
# サーバー上にアップロード
|
|
117
|
-
attachments =
|
|
126
|
+
attachments = client.upload_image(image_paths, image_type)
|
|
118
127
|
|
|
119
128
|
# サーバー上のファイル名を指定する
|
|
120
129
|
# attachmentsが一つ飛ばしなのはオリジナル品質の画像のみを指定するため
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
client.create_post(
|
|
131
|
+
"Hello with yaylib!",
|
|
123
132
|
attachment_filename=attachments[0].filename,
|
|
124
133
|
attachment_2_filename=attachments[2].filename,
|
|
125
134
|
attachment_3_filename=attachments[4].filename,
|
|
126
135
|
)
|
|
127
136
|
```
|
|
128
137
|
|
|
138
|
+
#### ✨ タイムラインを 100 件取得する
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import yaylib
|
|
142
|
+
|
|
143
|
+
client = yaylib.Client()
|
|
144
|
+
|
|
145
|
+
timeline = client.get_timeline(number=100)
|
|
146
|
+
|
|
147
|
+
for post in timeline.posts:
|
|
148
|
+
print(post.user.nickname) # 投稿者名
|
|
149
|
+
print(post.text) # 本文
|
|
150
|
+
print(post.likes_count) # いいね数
|
|
151
|
+
print(post.reposts_count) # (´∀`∩)↑age↑の数
|
|
152
|
+
print(post.in_reply_to_post_count) # 返信の数
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### ✨ タイムラインをキーワードで検索して「いいね」する
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
import yaylib
|
|
159
|
+
|
|
160
|
+
client = yaylib.Client()
|
|
161
|
+
client.login(email="your_email", password="your_password")
|
|
162
|
+
|
|
163
|
+
timeline = client.get_timeline_by_keyword(
|
|
164
|
+
keyword="プログラミング",
|
|
165
|
+
number=15
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
for post in timeline.posts:
|
|
169
|
+
client.like(post.id)
|
|
170
|
+
```
|
|
171
|
+
|
|
129
172
|
#### ✨ 新規ユーザーをフォローする
|
|
130
173
|
|
|
131
174
|
```python
|
|
132
175
|
import yaylib
|
|
133
176
|
|
|
134
|
-
|
|
135
|
-
|
|
177
|
+
client = yaylib.Client()
|
|
178
|
+
client.login(email="your_email", password="your_password")
|
|
136
179
|
|
|
137
|
-
new_users =
|
|
180
|
+
new_users = client.search_users(recently_created=True)
|
|
138
181
|
|
|
139
182
|
for new_user in new_users.users:
|
|
140
|
-
|
|
183
|
+
client.follow_user(new_user.id)
|
|
141
184
|
```
|
|
142
185
|
|
|
143
186
|
#### ✨ リアルタイムでチャットを取得する
|
|
144
187
|
|
|
145
188
|
```python
|
|
146
189
|
import yaylib
|
|
190
|
+
from yaylib import Message
|
|
147
191
|
|
|
148
|
-
class
|
|
149
|
-
|
|
150
|
-
print(
|
|
192
|
+
class MyBot(yaylib.Client):
|
|
193
|
+
def on_ready(self):
|
|
194
|
+
print("ボットがオンラインになりました!")
|
|
151
195
|
|
|
152
|
-
|
|
153
|
-
#
|
|
154
|
-
chat_requests =
|
|
196
|
+
def on_chat_request(self, total_count):
|
|
197
|
+
# チャットリクエストはすべて承認する
|
|
198
|
+
chat_requests = self.get_chat_requests()
|
|
155
199
|
for chat_room in chat_requests.chat_rooms:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
200
|
+
self.accept_chat_requests([chat_room.id])
|
|
201
|
+
|
|
202
|
+
# 最新のメッセージをon_message_create関数に送信
|
|
203
|
+
message = self.get_messages(chat_requests.chat_rooms[0].id)
|
|
204
|
+
self.on_message_create(message[0])
|
|
159
205
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
text='pong',
|
|
165
|
-
)
|
|
206
|
+
def on_message_create(self, message: Message):
|
|
207
|
+
# 「ping」というメッセージに対して「pong」と返信する
|
|
208
|
+
if message.text == "ping":
|
|
209
|
+
self.send_message(message.room_id, text="pong")
|
|
166
210
|
|
|
167
|
-
|
|
168
|
-
print(f
|
|
211
|
+
def on_chat_room_delete(self, room_id):
|
|
212
|
+
print(f"チャットルームが削除されました。ルームID: {room_id}")
|
|
169
213
|
|
|
170
214
|
intents = yaylib.Intents.none()
|
|
171
215
|
intents.chat_message = True
|
|
172
216
|
|
|
173
|
-
bot =
|
|
174
|
-
bot.run(
|
|
217
|
+
bot = MyBot(intents=intents)
|
|
218
|
+
bot.run("your_email", "your_password")
|
|
175
219
|
```
|
|
176
220
|
|
|
177
|
-
より詳しい使用例については、[
|
|
221
|
+
より詳しい使用例については、[こちら](https://github.com/ekkx/yaylib/blob/master/examples) を参照してください。
|
|
178
222
|
|
|
179
|
-
<
|
|
223
|
+
<p align="right">(<a href="#readme-top">トップに戻る</a>)</p>
|
|
180
224
|
|
|
181
225
|
<!-- yaylib で誕生したボットの一覧 -->
|
|
182
226
|
|
|
183
|
-
##
|
|
227
|
+
## :crown: yaylib で誕生したロボットたち
|
|
184
228
|
|
|
185
229
|
「yaylib」を用いて開発したロボットがある場合は、ぜひ教えてください!
|
|
186
230
|
|
|
@@ -213,27 +257,27 @@ bot.run('your_email', 'your_password')
|
|
|
213
257
|
</tbody>
|
|
214
258
|
</table>
|
|
215
259
|
|
|
216
|
-
<br>
|
|
217
|
-
|
|
218
260
|
<!-- 共同開発について -->
|
|
219
261
|
|
|
220
|
-
##
|
|
262
|
+
## :handshake: 共同開発について
|
|
221
263
|
|
|
222
|
-
|
|
264
|
+
私たちと開発することに興味を持っていただけているなら、ぜひ参加して頂きたいです!
|
|
223
265
|
|
|
224
|
-
|
|
266
|
+
- [プルリクエストを送信する](https://github.com/ekkx/yaylib/pulls)
|
|
267
|
+
- [Discord サーバーに参加する](https://discord.gg/MEuBfNtqRN)
|
|
268
|
+
- [nikola.desuga@gmail.com](mailto:nikola.desuga@gmail.com) にメールを送信する
|
|
269
|
+
|
|
270
|
+
のいずれかの方法で繋がりましょう。詳しくは[こちらから](https://github.com/ekkx/yaylib/blob/master/CONTRIBUTING.md)!
|
|
225
271
|
|
|
226
272
|
<!-- 免責事項 -->
|
|
227
273
|
|
|
228
|
-
##
|
|
274
|
+
## 免責事項
|
|
229
275
|
|
|
230
276
|
yaylib は、API の公式なサポートやメンテナンスを提供するものではありません。このクライアントを使用する場合、**利用者はリスクや責任を自己負担できるもの**とします。このクライアントによって提供される情報やデータの正確性、信頼性、完全性、適時性について、いかなる保証も行いません。また、このクライアントの使用によって生じた損害や不利益について、一切の責任を負いかねます。利用者は自己の責任において、このクライアントを使用し、API にアクセスするものとします。なお、この免責事項は予告なく変更される場合があります。
|
|
231
277
|
|
|
232
|
-
<br>
|
|
233
|
-
|
|
234
278
|
<!-- ライセンス -->
|
|
235
279
|
|
|
236
|
-
##
|
|
280
|
+
## ライセンス
|
|
237
281
|
|
|
238
282
|
<p align="center">
|
|
239
283
|
<a href="https://github.com/ekkx">
|