Skip to content

Commit

Permalink
Merge pull request #23 from yupix/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
yupix authored Jul 26, 2023
2 parents 3e0978d + 69448e6 commit a139090
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- ## [Unreleased] -->

## [Unreleased]
## [0.3.0] 2023-04-25

### Added
### Changes by Package 📦

MiPACに破壊的変更を含む更新があるため、よくMiPACのCHANGELOGを読むことを推奨します。

- [MiPAC](https://github.com/yupix/MiPAC/releases)

### Changed

- None
- [@omg-xtao](https://github.com/omg-xtao) can cancel setup_logging when init client.

## [0.2.2] 2023-04-25

Expand Down
21 changes: 14 additions & 7 deletions mipa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,18 @@ async def __on_error(event_method: str) -> None:
async def on_error(self, err):
self.event_dispatch('error', err)

async def create_api_session(self, token: str, url: str) -> API:
self.core = API(url, token)
async def create_api_session(
self, token: str, url: str, log_level: LOGING_LEVEL_TYPE | None,
) -> API:
self.core = API(url, token, log_level=log_level)
return self.core

async def setup_hook(self) -> None:
...

async def login(self, token: str, url: str):
async def login(
self, token: str, url: str, log_level: LOGING_LEVEL_TYPE | None
):
"""
ユーザーにログインし、ユーザー情報を取得します
Expand All @@ -223,9 +227,11 @@ async def login(self, token: str, url: str):
BOTにするユーザーのTOKEN
url : str
BOTにするユーザーがいるインスタンスのURL
log_level : LOGING_LEVEL_TYPE
The log level to use for logging. Defaults to ``INFO``.
"""

core = await self.create_api_session(token, url)
core = await self.create_api_session(token, url, log_level)
await core.http.login()
self.user = await core.api.get_me()
await self.setup_hook()
Expand Down Expand Up @@ -278,7 +284,7 @@ async def start(
reconnect: bool = True,
timeout: int = 60,
is_ayuskey: bool = False,
log_level: LOGING_LEVEL_TYPE = 'INFO',
log_level: LOGING_LEVEL_TYPE | None = 'INFO',
):
"""
Starting Bot
Expand All @@ -296,7 +302,8 @@ async def start(
timeout: int, default 60
Time until websocket times out
"""
setup_logging(level=log_level)
if log_level is not None:
setup_logging(level=log_level)
self.token = token
url = url[:-1] if url[-1] == '/' else url
split_url = url.split('/')
Expand All @@ -315,5 +322,5 @@ async def start(
url = '/'.join(split_url)
self.url = url.replace('https', 'wss').replace('http', 'ws')
self.origin_url = origin_url
await self.login(token, origin_url)
await self.login(token, origin_url, log_level)
await self.connect(reconnect=reconnect, timeout=timeout)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
aiohttp==3.8.4
mipac==0.4.3
mipac==0.5.0
versioneer

0 comments on commit a139090

Please sign in to comment.