matrix-appservice-kakaotalk/matrix_appservice_kakaotalk/kt/types/channel/meta.py

178 lines
4.3 KiB
Python

# matrix-appservice-kakaotalk - A Matrix-KakaoTalk puppeting bridge.
# Copyright (C) 2022 Tulir Asokan, Andrew Ferrazzutti
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Optional, Union
from attr import dataclass
from enum import Enum, IntEnum
from mautrix.types import SerializableAttrs, field
from ..bson import Long
class KnownChannelMetaType(IntEnum):
UNDEFINED = 0
NOTICE = 1
GROUP = 2
TITLE = 3
PROFILE = 4
TV = 5
PRIVILEGE = 6
TV_LIVE = 7
PLUS_BACKGROUND = 8
LIVE_TALK_INFO = 11
LIVE_TALK_COUNT = 12
OPEN_CHANNEL_CHAT = 13
BOT = 14
ChannelMetaType = Union[KnownChannelMetaType, int]
class ChannelClientMetaType(str, Enum):
UNDEFINED = "undefined"
NAME = "name"
IMAGE_PATH = "image_path"
FAVORITE = "favorite"
PUSH_SOUND = "push_sound"
CHAT_HIDE = "chat_hide"
FULL_IMAGE_URL = "full_image_url"
IMAGE_URL = "imageUrl"
@dataclass(kw_only=True)
class ChannelMetaStruct(SerializableAttrs):
type: ChannelMetaType
revision: Long
authorId: Optional[Long] = None
content: str
updatedAt: int
@dataclass(kw_only=True)
class ChannelClientMetaStruct(SerializableAttrs):
name: Optional[str] = None
image_path: Optional[str] = None
favourite: Optional[bool] = None
push_sound: Optional[bool] = None
chat_hide: Optional[bool] = None
fullImageUrl: Optional[str] = None
imageUrl: Optional[str] = None
@dataclass
class PrivilegeMetaContent(SerializableAttrs):
pin_notice: bool
@dataclass
class ProfileMetaContent(SerializableAttrs):
imageUrl: str
fullImageUrl: str
@dataclass
class TvMetaContent(SerializableAttrs):
url: str
@dataclass(kw_only=True)
class TvLiveMetaContent(SerializableAttrs):
url: str
live: Optional[str] = 'on'
@dataclass
class LiveTalkInfoOnMetaContent(SerializableAttrs):
liveon: bool
title: str
startTime: int
userId: Union[int, Long]
csIP: str
csIP6: str
csPort: int
callId: str
@dataclass(kw_only=True)
class LiveTalkInfoOffMetaContent(SerializableAttrs):
"""Substitute for LiveTalkInfoOffMetaContent extends Partial<LiveTalkInfoOffMetaContent>"""
liveon: bool = False
title: Optional[str] = None
startTime: Optional[int] = None
userId: Union[int, Long, None] = None
csIP: Optional[str] = None
csIP6: Optional[str] = None
csPort: Optional[int] = None
callId: Optional[str] = None
LiveTalkInfoMetaContent = Union[LiveTalkInfoOnMetaContent, LiveTalkInfoOffMetaContent]
@dataclass
class LiveTalkCountMetaContent(SerializableAttrs):
count: int
@dataclass
class GroupMetaContent(SerializableAttrs):
group_id: int
group_name: str
group_profile_thumbnail_url: str
group_profile_url: str
@dataclass
class BotCommandStruct(SerializableAttrs):
id: str
@dataclass
class BotAddCommandStruct(BotCommandStruct):
name: str
updatedAt: int
botId: Long
BotDelCommandStruct = BotCommandStruct
@dataclass(kw_only=True)
class BotMetaContent(SerializableAttrs):
add: Optional[list[BotAddCommandStruct]] = None
update: Optional[list[BotAddCommandStruct]] = None
full: Optional[list[BotAddCommandStruct]] = None
delete: Optional[list[BotDelCommandStruct]] = field(json="del", default=None)
__all__ = [
"KnownChannelMetaType",
"ChannelMetaType",
"ChannelClientMetaType",
"ChannelMetaStruct",
"ChannelClientMetaStruct",
"PrivilegeMetaContent",
"ProfileMetaContent",
"TvMetaContent",
"TvLiveMetaContent",
"LiveTalkInfoOnMetaContent",
"LiveTalkInfoOffMetaContent",
"LiveTalkInfoMetaContent",
"LiveTalkCountMetaContent",
"GroupMetaContent",
"BotCommandStruct",
"BotAddCommandStruct",
"BotDelCommandStruct",
"BotMetaContent",
]