Skip to content
This repository was archived by the owner on May 28, 2022. It is now read-only.

Commit 5551a02

Browse files
committed
Merge branch 'release/v2.0.0'
2 parents 2e9ff60 + f00053a commit 5551a02

24 files changed

+135
-432
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [v1.0.3] 2021-12-29
11+
12+
### Added
13+
14+
- `commands.mention_command` を追加しました MP-8
15+
- `get_replies` and `get_note` method to `Class` class MP-10 MP-9
16+
- `get_replies` method to `Note` class MP-10 MP-9
17+
- `get_replies` and `get_note` method to `NoteActions` class MP-10 MP-9
18+
19+
20+
### Removed
21+
22+
- **BREAKING CHANGE**: removed core.py and context.py MP-8
23+
- **BREAKING CHANGE**: Cogに関連する多くのクラスを削除しました MP-8
24+
- **BREAKING CHANGE**: `commands.command` デコレータを削除しました MP-8
25+
1026
## [v1.0.3] 2021-12-27
1127

1228
### Added
@@ -162,7 +178,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
162178

163179
- `conn.py``get_followers` `get_user` `fetch_user` 関数が追加されました
164180
- `commandFrameWork` に関する多くのものを追加
165-
- `commandFrameWork``listener` `commands` デコレーターを追加
181+
- `commandFrameWork``listener` `commands` デコレータを追加
166182
- `Drive` クラスの `upload` メソッドで url から画像をアップロードできるように `url` 引数を追加
167183
- `utils.py``check_multi_arg` `remove_dict_empty` 関数を追加
168184
- `upper_to_lower` 関数に `replace_list` 引数を追加

README-ja.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
# Mi.py
22

33
[![CodeFactor](https://www.codefactor.io/repository/github/yupix/mi.py/badge)](https://www.codefactor.io/repository/github/yupix/mi.py)
4-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f5acd9da804d4a11b031d36dbd398067)](https://www.codacy.com/gh/yupix/Mi.py/dashboard?utm_source=github.com&utm_medium=referral&utm_content=yupix/Mi.py&utm_campaign=Badge_Grade)
4+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f5acd9da804d4a11b031d36dbd398067)](https://www.codacy.com/gh/yupix/Mi.py/dashboard?utm_source=github.com&utm_medium=referral&utm_content=yupix/Mi.py&utm_campaign=Badge_Grade)
55
[![buddy pipeline](https://app.buddy.works/yupi0982/mi-py/pipelines/pipeline/345007/badge.svg?token=b304dd68d3eeb7917d453a2d2102621123ae4f05e0b659dde59cad486e2984b3 "buddy pipeline")](https://app.buddy.works/yupi0982/mi-py/pipelines/pipeline/345007)
66
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fyupix%2FMi.py.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fyupix%2FMi.py?ref=badge_shield)
77
[![Build Status](https://ci.akarinext.org/api/badges/yupix/Mi.py/status.svg)](https://ci.akarinext.org/yupix/Mi.py)
88

99
## 概要
1010

11-
Mi.pyは[Discord.py](https://github.com/Rapptz/discord.py)
12-
ライクな書き方ができるように作っているMisskeyApi wrapperです 現在動作を確認しているMisskeyは本家Misskey v12の最新です。
13-
`Ayuskey` での動作確認も一応行っていますが、 11/5時点でAyuskeyそのものの動作が怪しいため現在はテストを行っていません。
11+
Mi.py は[Discord.py](https://github.com/Rapptz/discord.py)
12+
ライクな書き方ができるように作っている MisskeyApi wrapper です
13+
14+
# サポートしているMisskey
15+
16+
- [Misskey Official v12](https://github.com/misskey-dev/misskey)
17+
- [Ayuskey latest](https://gtihub.com/teamblackcrystal/misskey)
1418

1519
## 使い方
1620

17-
様々な使い方を書くにあたってREADMEから変更しました[こちら](examples)からご覧ください。 その他のメソッドなどについては[ドキュメント](https://yupix.github.io/Mi.py) をご覧ください
21+
様々な使い方を書くにあたって README から変更しました[こちら](examples)からご覧ください。 その他のメソッドなどについては[ドキュメント](https://yupix.github.io/Mi.py) をご覧ください
1822

1923
## 注意点
2024

21-
グローバルタイムラインに接続したりする際に使う以下の様なコードがあるとホームタイムラインとグローバルタイムラインの2つを受信したことになりon_messageが2回動作します。 これは接続するチャンネルを増やすごとに増えていく形になります
25+
グローバルタイムラインに接続したりする際に使う以下の様なコードがあるとホームタイムラインとグローバルタイムラインの 2 つを受信したことになり on_message が 2 回動作します。 これは接続するチャンネルを増やすごとに増えていく形になります
2226

2327
```python
2428
await Router(ws).connect_channel(['home', 'global'])
@@ -57,9 +61,9 @@ await Router(ws).connect_channel(['home', 'global'])
5761
### Libraries
5862

5963
- [Discord.py](https://github.com/Rapptz/discord.py)
60-
- 一部や仕組みを参考にさせてもらっています。実際にコードも利用しています
64+
- 一部や仕組みを参考にさせてもらっています。実際にコードも利用しています
6165

62-
最後にこのプロジェクトを作るきっかけになり、一部のコードを使用させていただいているDiscord.pyがArchivedになりました。 作者であるDannyさんや全てのコラボレーターに最大限の感謝申し上げます
66+
最後にこのプロジェクトを作るきっかけになり、一部のコードを使用させていただいている Discord.py が Archived になりました。 作者である Danny さんや全てのコラボレーターに最大限の感謝申し上げます
6367

6468
# LICENSE
6569

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Mi.py
22

33
[![CodeFactor](https://www.codefactor.io/repository/github/yupix/mi.py/badge)](https://www.codefactor.io/repository/github/yupix/mi.py)
4-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f5acd9da804d4a11b031d36dbd398067)](https://www.codacy.com/gh/yupix/Mi.py/dashboard?utm_source=github.com&utm_medium=referral&utm_content=yupix/Mi.py&utm_campaign=Badge_Grade)
4+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f5acd9da804d4a11b031d36dbd398067)](https://www.codacy.com/gh/yupix/Mi.py/dashboard?utm_source=github.com&utm_medium=referral&utm_content=yupix/Mi.py&utm_campaign=Badge_Grade)
55
[![buddy pipeline](https://app.buddy.works/yupi0982/mi-py/pipelines/pipeline/345007/badge.svg?token=b304dd68d3eeb7917d453a2d2102621123ae4f05e0b659dde59cad486e2984b3 "buddy pipeline")](https://app.buddy.works/yupi0982/mi-py/pipelines/pipeline/345007)
66
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fyupix%2FMi.py.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fyupix%2FMi.py?ref=badge_shield)
77
[![Build Status](https://ci.akarinext.org/api/badges/yupix/Mi.py/status.svg)](https://ci.akarinext.org/yupix/Mi.py)
@@ -10,13 +10,17 @@
1010

1111
## Overview
1212

13-
Mi.py is a Misskey API Wrapper that is designed to be written in a [Discord.py](https://github.com/Rapptz/discord.py)-like way. The only Misskey currently tested is the latest version of Misskey v12. We have also tested it with `Ayuskey`, but as of 11/5, Ayuskey itself is not working properly, so we are not testing it now.
13+
Mi.py is a Misskey API Wrapper that is designed to be written in a [Discord.py](https://github.com/Rapptz/discord.py)-like way
14+
15+
## Supported Misskey
16+
17+
- [Misskey Official v12](https://github.com/misskey-dev/misskey)
18+
- [Ayuskey latest](https://gtihub.com/teamblackcrystal/misskey)
1419

1520
## How to use
1621

1722
Changed from README to [here](examples) in writing various usages. For other methods, etc., please see [Documentation](https://yupix.github.io/Mi.py/en/).
1823

19-
2024
## warning
2125

2226
If you connect to the home timeline while connected to the global timeline, the `on_message` event will work twice for one message, because the same message is received on two channels. This is not a bug, but normal behavior.
@@ -58,7 +62,7 @@ These are the people who contributed to the development
5862
### Libraries
5963

6064
- [Discord.py](https://github.com/Rapptz/discord.py)
61-
- I am using some of the mechanisms as a reference. We also use the actual code.
65+
- I am using some of the mechanisms as a reference. We also use the actual code.
6266

6367
Finally, Discord.py, which inspired me to create this project and for which I use some of the code, is now Archived. Many thanks to Danny and all the collaborators.
6468

mi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__copyright__ = "Copyright 2021-present yupix"
55
__author_email__ = "[email protected]"
66
__url__ = "https://github.com/yupix/Mi.py"
7-
__version__ = "1.0.3"
7+
__version__ = "2.0.0"
88

99
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1010

mi/abc/ext/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
from .bot import *
2-
from .context import *
3-
from .core import *

mi/abc/ext/bot.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,8 @@
55

66
from aiohttp.client_ws import ClientWebSocketResponse
77

8-
from mi.abc.ext.core import AbstractGroupMixin
9-
from .context import AbstractContext
10-
11-
12-
class AbstractBotBase(AbstractGroupMixin):
13-
@abstractmethod
14-
async def can_run(self, ctx: AbstractContext, *, call_once: bool = False) -> bool:
15-
pass
16-
17-
@abstractmethod
18-
async def invoke(self, ctx: AbstractContext, *args: Tuple[Any], **kwargs: Dict[Any, Any]):
19-
pass
20-
21-
@abstractmethod
22-
async def get_context(self, message, *, cls: Any = AbstractContext):
23-
pass
24-
25-
@abstractmethod
26-
async def process_commands(self, message):
27-
pass
288

9+
class AbstractBotBase:
2910
@abstractmethod
3011
async def _on_message(self, message):
3112
pass

mi/abc/ext/context.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

mi/abc/ext/core.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

mi/client.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None, **options:
4141
self.ws: MisskeyWebSocket = None
4242

4343
def _get_state(self, **options: Any) -> ConnectionState:
44-
return ConnectionState(dispatch=self.dispatch, http=self.http, loop=self.loop, **options)
44+
return ConnectionState(dispatch=self.dispatch, http=self.http, loop=self.loop, client=self, **options)
4545

4646
async def on_ready(self, ws: ClientWebSocketResponse):
4747
"""
@@ -150,14 +150,19 @@ async def _run_event(
150150
except asyncio.CancelledError:
151151
pass
152152

153-
async def _on_message(self, message):
154-
await self.dispatch("message", message)
155-
156153
@staticmethod
157154
async def __on_error(event_method: str) -> None:
158155
print(f"Ignoring exception in {event_method}", file=sys.stderr)
159156
traceback.print_exc()
160157

158+
async def progress_command(self, message):
159+
for key, command in self.all_commands.items():
160+
if re.search(command.regex, message.content):
161+
await command.invoke(message)
162+
163+
async def on_mention(self, message):
164+
await self.progress_command(message)
165+
161166
async def on_error(self, err):
162167
await self.event_dispatch("error", err)
163168

@@ -374,6 +379,12 @@ async def get_announcements(self, limit: int, with_unreads: bool, since_id: str,
374379
return await self._connection.get_announcements(limit=limit, with_unreads=with_unreads, since_id=since_id,
375380
until_id=until_id)
376381

382+
async def get_note(self, note_id: str) -> Note:
383+
return await self._connection.get_note(note_id=note_id)
384+
385+
async def get_replies(self, note_id: str, since_id: Optional[str] = None, until_id: Optional[str] = None, limit: int = 1) -> List[Note]:
386+
return await self._connection.get_replies(note_id=note_id, limit=limit, since_id=since_id, until_id=until_id)
387+
377388
async def login(self, token):
378389

379390
data = await self.http.static_login(token)
@@ -408,9 +419,9 @@ async def start(self, url: str, token: str, *, debug: bool = False, reconnect: b
408419
if _origin_uri := re.search(r"wss?://(.*)/streaming", url):
409420
origin_uri = (
410421
_origin_uri.group(0)
411-
.replace("wss", "https")
412-
.replace("ws", "http")
413-
.replace("/streaming", "")
422+
.replace("wss", "https")
423+
.replace("ws", "http")
424+
.replace("/streaming", "")
414425
)
415426
else:
416427
origin_uri = url

mi/exception.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
"NotExistRequiredData"
2323
)
2424

25+
2526
class NotExistRequiredData(Exception):
2627
"""
2728
必要なデータが存在しない場合に発生する例外
2829
"""
2930

31+
3032
class NotFoundError(Exception):
3133
"""
3234
http アクセス時に404が帰ってきた際の例外

0 commit comments

Comments
 (0)