Skip to content

Commit

Permalink
🔖 version 0.1.0
Browse files Browse the repository at this point in the history
Signed-off-by: RF-Tar-Railt <3165388245@qq.com>
  • Loading branch information
RF-Tar-Railt committed Dec 6, 2023
1 parent a5a3d94 commit 1294e88
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 88 deletions.
106 changes: 23 additions & 83 deletions arclet/entari/session.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down Expand Up @@ -106,29 +101,20 @@ 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,
data: Channel,
) -> 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:
Expand All @@ -141,102 +127,68 @@ 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,
role: Role,
) -> 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,
Expand All @@ -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:
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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
)
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
[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",
]
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",
Expand Down

0 comments on commit 1294e88

Please sign in to comment.