Skip to content

Commit

Permalink
feat: emojiに関するモデルを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Feb 8, 2024
1 parent cb8ffa6 commit e29b495
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 2 deletions.
86 changes: 85 additions & 1 deletion mipac/models/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING

from mipac.models.lite.emoji import PartialCustomEmoji
from mipac.types.emoji import ICustomEmoji
from mipac.types.emoji import ICustomEmoji, IEmojiDetailed, IEmojiSimple

if TYPE_CHECKING:
from mipac.client import ClientManager
Expand Down Expand Up @@ -41,3 +41,87 @@ def __eq__(self, __value: object) -> bool:

def __ne__(self, __value: object) -> bool:
return not self.__eq__(__value)


class EmojiSimple:
def __init__(self, raw_emoji_simple: IEmojiSimple, *, client: ClientManager):
self.__raw_emoji_simple: IEmojiSimple = raw_emoji_simple
self.__client: ClientManager = client

@property
def aliaces(self) -> list[str]:
return self.__raw_emoji_simple["aliaces"]

@property
def name(self) -> str:
return self.__raw_emoji_simple["name"]

@property
def category(self) -> str | None:
return self.__raw_emoji_simple["category"]

@property
def url(self) -> str:
return self.__raw_emoji_simple["url"]

@property
def is_sensitive(self) -> bool:
return self.__raw_emoji_simple.get("is_sensitive", False)

@property
def role_ids_that_can_be_used_this_emoji_as_reaction(self) -> list[str]:
return self.__raw_emoji_simple.get("role_ids_that_can_be_used_this_emoji_as_reaction", [])

def __eq__(self, __value: object) -> bool:
return isinstance(__value, EmojiSimple) and self.name == __value.name

def __ne__(self, __value: object) -> bool:
return not self.__eq__(__value)


class EmojiDetailed:
def __init__(self, raw_emoji_detailed: IEmojiDetailed, *, client: ClientManager):
self.__raw_emoji_detailed: IEmojiDetailed = raw_emoji_detailed
self.__client: ClientManager = client

@property
def id(self) -> str:
return self.__raw_emoji_detailed["id"]

@property
def aliaces(self) -> list[str]:
return self.__raw_emoji_detailed["aliaces"]

@property
def name(self) -> str:
return self.__raw_emoji_detailed["name"]

@property
def category(self) -> str | None:
return self.__raw_emoji_detailed["category"]

@property
def host(self) -> str | None:
return self.__raw_emoji_detailed["host"]

@property
def url(self) -> str:
return self.__raw_emoji_detailed["url"]

@property
def is_sensitive(self) -> bool:
return self.__raw_emoji_detailed["is_sensitive"]

@property
def local_only(self) -> bool:
return self.__raw_emoji_detailed["local_only"]

@property
def role_ids_that_can_be_used_this_emoji_as_reaction(self) -> list[str]:
return self.__raw_emoji_detailed["role_ids_that_can_be_used_this_emoji_as_reaction"]

def __eq__(self, __value: object) -> bool:
return isinstance(__value, EmojiDetailed) and self.id == __value.id

def __ne__(self, __value: object) -> bool:
return not self.__eq__(__value)
22 changes: 21 additions & 1 deletion mipac/types/emoji.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, TypedDict
from typing import NotRequired, Optional, TypedDict

__all__ = ("EmojiPayload", "ICustomEmojiLite", "ICustomEmoji")

Expand Down Expand Up @@ -27,3 +27,23 @@ class EmojiPayload(TypedDict):
host: str | None
url: str | None
license: str | None # v13 only

class IEmojiSimple(TypedDict):
aliaces: list[str]
name: str
category: str | None
url: str
is_sensitive: NotRequired[bool]
role_ids_that_can_be_used_this_emoji_as_reaction: NotRequired[list[str]]

class IEmojiDetailed(TypedDict):
id: str
aliaces: list[str]
name: str
category: str | None
host: str | None
url: str
license: str | None
is_sensitive: bool
local_only: bool
role_ids_that_can_be_used_this_emoji_as_reaction: list[str]

0 comments on commit e29b495

Please sign in to comment.