From 1294e88547c853b548a9c0a6b4e4b5bb5f8de722 Mon Sep 17 00:00:00 2001 From: RF-Tar-Railt <3165388245@qq.com> Date: Wed, 6 Dec 2023 16:12:09 +0800 Subject: [PATCH] :bookmark: version 0.1.0 Signed-off-by: RF-Tar-Railt <3165388245@qq.com> --- arclet/entari/session.py | 106 +++++++++------------------------------ pyproject.toml | 9 ++-- 2 files changed, 27 insertions(+), 88 deletions(-) diff --git a/arclet/entari/session.py b/arclet/entari/session.py index 3250078..a582263 100644 --- a/arclet/entari/session.py +++ b/arclet/entari/session.py @@ -1,10 +1,10 @@ from __future__ import annotations -from typing import Iterable +from collections.abc import Iterable +from satori.client.account import Account from satori.element import Element from satori.model import Channel, Event, Member, MessageObject, PageResult, Role, User -from satori.client.account import Account class ContextSession: @@ -63,9 +63,7 @@ async def update_message( if not self.context.message: raise RuntimeError("Event cannot update message") return await self.account.session.update_message( - self.context.channel, - self.context.message.id, - message + self.context.channel, self.context.message.id, message ) async def message_create( @@ -74,10 +72,7 @@ async def message_create( ) -> list[MessageObject]: if not self.context.channel: raise RuntimeError("Event cannot be replied to!") - return await self.account.session.message_create( - self.context.channel.id, - content - ) + return await self.account.session.message_create(self.context.channel.id, content) async def message_delete(self) -> None: if not self.context.channel: @@ -106,18 +101,12 @@ async def message_update( async def channel_create(self, data: Channel) -> Channel: if not self.context.guild: raise RuntimeError("Event cannot use to create channel!") - return await self.account.session.channel_create( - self.context.guild.id, - data - ) + return await self.account.session.channel_create(self.context.guild.id, data) async def channel_list(self, next_token: str | None = None) -> PageResult[Channel]: if not self.context.guild: raise RuntimeError("Event cannot use to list channel!") - return await self.account.session.channel_list( - self.context.guild.id, - next_token - ) + return await self.account.session.channel_list(self.context.guild.id, next_token) async def channel_update( self, @@ -125,10 +114,7 @@ async def channel_update( ) -> None: if not self.context.channel: raise RuntimeError("Event cannot use to update channel!") - return await self.account.session.channel_update( - self.context.channel.id, - data - ) + return await self.account.session.channel_update(self.context.channel.id, data) async def channel_delete(self) -> None: if not self.context.guild: @@ -141,91 +127,60 @@ async def user_channel_create(self) -> Channel: if not self.context.user: raise RuntimeError("Event cannot use to create user channel!") return await self.account.session.user_channel_create( - self.context.user.id, - self.context.guild.id if self.context.guild else None + self.context.user.id, self.context.guild.id if self.context.guild else None ) async def guild_member_list(self, next_token: str | None = None) -> PageResult[Member]: if not self.context.guild: raise RuntimeError("Event cannot use to list member!") - return await self.account.session.guild_member_list( - self.context.guild.id, - next_token - ) + return await self.account.session.guild_member_list(self.context.guild.id, next_token) async def guild_member_get(self, user_id: str | None = None) -> Member: if not self.context.guild: raise RuntimeError("Event cannot use to get member!") if user_id: - return await self.account.session.guild_member_get( - self.context.guild.id, - user_id - ) + return await self.account.session.guild_member_get(self.context.guild.id, user_id) if not self.context.user: raise RuntimeError("Event cannot use to get member!") - return await self.account.session.guild_member_get( - self.context.guild.id, - self.context.user.id - ) + return await self.account.session.guild_member_get(self.context.guild.id, self.context.user.id) async def guild_member_kick(self, user_id: str | None = None, permanent: bool = False) -> None: if not self.context.guild: raise RuntimeError("Event cannot use to kick member!") if user_id: - return await self.account.session.guild_member_kick( - self.context.guild.id, - user_id, - permanent - ) + return await self.account.session.guild_member_kick(self.context.guild.id, user_id, permanent) if not self.context.user: raise RuntimeError("Event cannot use to kick member!") return await self.account.session.guild_member_kick( - self.context.guild.id, - self.context.user.id, - permanent + self.context.guild.id, self.context.user.id, permanent ) async def guild_member_role_set(self, role_id: str, user_id: str | None = None) -> None: if not self.context.guild: raise RuntimeError("Event cannot use to guild member role set!") if user_id: - return await self.account.session.guild_member_role_set( - self.context.guild.id, - user_id, - role_id - ) + return await self.account.session.guild_member_role_set(self.context.guild.id, user_id, role_id) if not self.context.user: raise RuntimeError("Event cannot use to guild member role set!") return await self.account.session.guild_member_role_set( - self.context.guild.id, - self.context.user.id, - role_id + self.context.guild.id, self.context.user.id, role_id ) async def guild_member_role_unset(self, role_id: str, user_id: str | None = None) -> None: if not self.context.guild: raise RuntimeError("Event cannot use to guild member role unset!") if user_id: - return await self.account.session.guild_member_role_unset( - self.context.guild.id, - user_id, - role_id - ) + return await self.account.session.guild_member_role_unset(self.context.guild.id, user_id, role_id) if not self.context.user: raise RuntimeError("Event cannot use to guild member role unset!") return await self.account.session.guild_member_role_unset( - self.context.guild.id, - self.context.user.id, - role_id + self.context.guild.id, self.context.user.id, role_id ) async def guild_role_list(self, next_token: str | None = None) -> PageResult[Role]: if not self.context.guild: raise RuntimeError("Event cannot use to list role!") - return await self.account.session.guild_role_list( - self.context.guild.id, - next_token - ) + return await self.account.session.guild_role_list(self.context.guild.id, next_token) async def guild_role_create( self, @@ -233,10 +188,7 @@ async def guild_role_create( ) -> Role: if not self.context.guild: raise RuntimeError("Event cannot use to create role!") - return await self.account.session.guild_role_create( - self.context.guild.id, - role - ) + return await self.account.session.guild_role_create(self.context.guild.id, role) async def guild_role_update( self, @@ -245,11 +197,7 @@ async def guild_role_update( ) -> None: if not self.context.guild: raise RuntimeError("Event cannot use to update role!") - return await self.account.session.guild_role_update( - self.context.guild.id, - role_id, - role - ) + return await self.account.session.guild_role_update(self.context.guild.id, role_id, role) async def guild_role_delete(self, role_id: str) -> None: if not self.context.guild: @@ -268,9 +216,7 @@ async def reaction_create( if not self.context.message: raise RuntimeError("Event cannot create reaction") return await self.account.session.reaction_create( - self.context.channel.id, - self.context.message.id, - emoji + self.context.channel.id, self.context.message.id, emoji ) async def reaction_delete( @@ -283,10 +229,7 @@ async def reaction_delete( if not self.context.message: raise RuntimeError("Event cannot delete reaction") return await self.account.session.reaction_delete( - self.context.channel.id, - self.context.message.id, - emoji, - user_id + self.context.channel.id, self.context.message.id, emoji, user_id ) async def reaction_clear( @@ -313,8 +256,5 @@ async def reaction_list( if not self.context.message: raise RuntimeError("Event cannot list reaction") return await self.account.session.reaction_list( - self.context.channel.id, - self.context.message.id, - emoji, - next_token + self.context.channel.id, self.context.message.id, emoji, next_token ) diff --git a/pyproject.toml b/pyproject.toml index 0c34967..a532322 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,15 @@ [project] name = "arclet-entari" version = "0.1.0" -description = "interact framework" +description = "Simple IM Framework based on satori-python" authors = [ {name = "RF-Tar-Railt",email = "rf_tar_railt@qq.com"}, ] dependencies = [ - "arclet-letoderea>=0.7.0", + "arclet-letoderea>=0.9.2", "arclet-alconna>=1.7.38", - "satori-python-core>=0.9.0", - "satori-python-client>=0.9.0", + "satori-python-core>=0.9.2", + "satori-python-client>=0.9.2", "arclet-alconna-tools>=0.6.8", "pygtrie>=2.5.0", ] @@ -17,7 +17,6 @@ requires-python = ">=3.9" readme = "README.md" license = {text = "MIT"} classifiers = [ - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11",