2022-02-25 02:22:50 -05:00
|
|
|
# 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/>.
|
2022-02-26 04:06:26 -05:00
|
|
|
from typing import Optional, Union
|
|
|
|
|
2022-02-25 02:22:50 -05:00
|
|
|
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
|
|
|
|
|
2022-02-26 04:06:26 -05:00
|
|
|
ChannelMetaType = Union[KnownChannelMetaType, int]
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2022-02-26 04:06:26 -05:00
|
|
|
authorId: Optional[Long] = None
|
2022-02-25 02:22:50 -05:00
|
|
|
content: str
|
|
|
|
updatedAt: int
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(kw_only=True)
|
|
|
|
class ChannelClientMetaStruct(SerializableAttrs):
|
2022-02-26 04:06:26 -05:00
|
|
|
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
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
@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
|
2022-02-26 04:06:26 -05:00
|
|
|
live: Optional[str] = 'on'
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class LiveTalkInfoOnMetaContent(SerializableAttrs):
|
|
|
|
liveon: bool
|
|
|
|
title: str
|
|
|
|
startTime: int
|
2022-02-26 04:06:26 -05:00
|
|
|
userId: Union[int, Long]
|
2022-02-25 02:22:50 -05:00
|
|
|
csIP: str
|
|
|
|
csIP6: str
|
|
|
|
csPort: int
|
|
|
|
callId: str
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(kw_only=True)
|
|
|
|
class LiveTalkInfoOffMetaContent(SerializableAttrs):
|
|
|
|
"""Substitute for LiveTalkInfoOffMetaContent extends Partial<LiveTalkInfoOffMetaContent>"""
|
2022-02-26 04:06:26 -05:00
|
|
|
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
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
2022-02-26 04:06:26 -05:00
|
|
|
LiveTalkInfoMetaContent = Union[LiveTalkInfoOnMetaContent, LiveTalkInfoOffMetaContent]
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
@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):
|
2022-02-26 04:06:26 -05:00
|
|
|
add: Optional[list[BotAddCommandStruct]] = None
|
|
|
|
update: Optional[list[BotAddCommandStruct]] = None
|
|
|
|
full: Optional[list[BotAddCommandStruct]] = None
|
|
|
|
delete: Optional[list[BotDelCommandStruct]] = field(json="del", default=None)
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
"KnownChannelMetaType",
|
|
|
|
"ChannelMetaType",
|
|
|
|
"ChannelClientMetaType",
|
|
|
|
"ChannelMetaStruct",
|
|
|
|
"ChannelClientMetaStruct",
|
|
|
|
"PrivilegeMetaContent",
|
|
|
|
"ProfileMetaContent",
|
|
|
|
"TvMetaContent",
|
|
|
|
"TvLiveMetaContent",
|
|
|
|
"LiveTalkInfoOnMetaContent",
|
|
|
|
"LiveTalkInfoOffMetaContent",
|
|
|
|
"LiveTalkInfoMetaContent",
|
|
|
|
"LiveTalkCountMetaContent",
|
|
|
|
"GroupMetaContent",
|
|
|
|
"BotCommandStruct",
|
|
|
|
"BotAddCommandStruct",
|
|
|
|
"BotDelCommandStruct",
|
|
|
|
"BotMetaContent",
|
|
|
|
]
|