Module graia.application.message.elements

Expand source code
import abc
from typing import Any
from pydantic import BaseModel


class Element(BaseModel):
    def __hash__(self):
        return hash((type(self),) + tuple(self.__dict__.values()))


class InternalElement(Element, abc.ABC):
    def toExternal(self) -> "ExternalElement":
        """可以为异步方法"""
        pass

    @abc.abstractclassmethod
    def fromExternal(cls, external_element) -> "InternalElement":
        """可以为异步方法"""
        pass

    def asDisplay(self) -> str:
        return ""

    def asSerializationString(self) -> str:
        return ""


class ExternalElement(Element):
    pass


class ShadowElement(Element):
    pass


def isShadowElement(any_instance: Any) -> bool:
    """检查实例是否为 Shadow Element

    Args:
        any_instance (Any): 欲检查的实例

    Returns:
        bool: 是否为 Shadow Element
    """
    return isinstance(any_instance, ShadowElement)

Sub-modules

graia.application.message.elements.external
graia.application.message.elements.internal

Functions

def isShadowElement(any_instance: Any) ‑> bool

检查实例是否为 Shadow Element

Args

any_instance : Any
欲检查的实例

Returns

bool
是否为 Shadow Element
Expand source code
def isShadowElement(any_instance: Any) -> bool:
    """检查实例是否为 Shadow Element

    Args:
        any_instance (Any): 欲检查的实例

    Returns:
        bool: 是否为 Shadow Element
    """
    return isinstance(any_instance, ShadowElement)

Classes

class Element (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class Element(BaseModel):
    def __hash__(self):
        return hash((type(self),) + tuple(self.__dict__.values()))

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Subclasses

class ExternalElement (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class ExternalElement(Element):
    pass

Ancestors

  • Element
  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Subclasses

class InternalElement (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class InternalElement(Element, abc.ABC):
    def toExternal(self) -> "ExternalElement":
        """可以为异步方法"""
        pass

    @abc.abstractclassmethod
    def fromExternal(cls, external_element) -> "InternalElement":
        """可以为异步方法"""
        pass

    def asDisplay(self) -> str:
        return ""

    def asSerializationString(self) -> str:
        return ""

Ancestors

  • Element
  • pydantic.main.BaseModel
  • pydantic.utils.Representation
  • abc.ABC

Subclasses

Static methods

def fromExternal(external_element) ‑> InternalElement

可以为异步方法

Expand source code
@abc.abstractclassmethod
def fromExternal(cls, external_element) -> "InternalElement":
    """可以为异步方法"""
    pass

Methods

def asDisplay(self) ‑> str
Expand source code
def asDisplay(self) -> str:
    return ""
def asSerializationString(self) ‑> str
Expand source code
def asSerializationString(self) -> str:
    return ""
def toExternal(self) ‑> ExternalElement

可以为异步方法

Expand source code
def toExternal(self) -> "ExternalElement":
    """可以为异步方法"""
    pass
class ShadowElement (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class ShadowElement(Element):
    pass

Ancestors

  • Element
  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Subclasses