cyan.model.channel module

class cyan.model.channel.AppChannel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.channel.Channel

应用子频道。

property app_channel_type: Union[cyan.model.channel.AppChannelType, int]

应用子频道类型。

当类型值在 AppChannelType 中时为对应 AppChannelType; 否则为指示当前应用子频道类型的 int 值。

class cyan.model.channel.AppChannelType(value)[源代码]

基类:enum.Enum

应用子频道类型。

CODM = 1000070

CoDM 开黑大厅。

GAME = 1000001

互动小游戏。

GAME_FOR_PEACE = 1010000

和平精英开黑大厅。

HONOR_OF_KINGS = 1000000

王者开黑大厅。

QQ_SPEED = 1000051

QQ 飞车开黑大厅。

SCHEDULE = 1000050

日程提醒。

VOTE = 1000010

腾讯投票。

class cyan.model.channel.Channel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.Model, cyan.model.renovatable.AsyncRenovatable[Channel]

子频道。

async add_operator(member: cyan.model.member.Member) None[源代码]

异步添加管理员到当前子频道。

参数:
  • member: 将要添加到当前子频道的成员

property bot: cyan.bot.Bot

Model 所属机器人。

async get_owner() Optional[cyan.model.member.Member][源代码]

异步获取子频道所有者。

返回:

当存在子频道所有者时,返回以 Member 类型表示的当前子频道所有者; 若不存在,则返回 None

async get_parent() cyan.model.channel.ChannelGroup[源代码]

异步获取子频道附属的子频道组。

返回:

Channel 类型表示的当前子频道附属的子频道组。

property guild: cyan.model.guild.Guild

子频道附属频道。

property identifier: str

Model ID。

is_child_of(parent: cyan.model.channel.ChannelGroup) bool[源代码]

判断当前子频道是否为指定子频道组的成员。

参数:
  • parent: 将要用于判断是否为附属子频道的指定子频道组

返回:

如果当前子频道为指定子频道组的成员,返回 True;否则,返回 False

property name: str

子频道名。

property permission: cyan.model.channel.ChannelPermission

子频道权限。

async remove_operator(member: cyan.model.member.Member) None[源代码]

异步从当前子频道移除指定管理员。

参数:
  • member: 将要从当前子频道移除的管理员

async renovate() cyan.model.channel.Channel[源代码]

获取更新的实例。

property visibility: cyan.model.channel.ChannelVisibility

子频道可见性。

class cyan.model.channel.ChannelGroup(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.Model, cyan.model.renovatable.AsyncRenovatable[ChannelGroup]

子频道组。

property bot: cyan.bot.Bot

Model 所属机器人。

async get_children() List[cyan.model.channel.Channel][源代码]

获取子频道组的成员。

返回:

Channel 类型表示成员子频道的 list 集合。

async get_owner() Optional[cyan.model.member.Member][源代码]

获取子频道组所有者。

返回:

当存在子频道组所有者时,返回以 Member 类型表示的当前子频道所有者; 若不存在,则返回 None

property guild: cyan.model.guild.Guild

子频道组附属频道。

property identifier: str

Model ID。

property name: str

子频道组名。

async renovate() cyan.model.channel.ChannelGroup[源代码]

获取更新的实例。

property visibility: cyan.model.channel.ChannelVisibility

子频道组可见性。

class cyan.model.channel.ChannelPermission(value)[源代码]

基类:enum.Enum

子频道权限。

APOINTEE = 2

所有者、管理员及指定人员。

DEFAULT = 0

默认。

EVERYONE = 1

所有人。

class cyan.model.channel.ChannelVisibility(value)[源代码]

基类:enum.Enum

子频道可见性。

ADMINISTRATOR = 1

所有者及管理员。

APOINTEE = 2

所有者、管理员及指定人员。

EVERYONE = 0

所有人。

class cyan.model.channel.ForumChannel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.channel.Channel

论坛子频道。

class cyan.model.channel.LiveChannel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.channel.Channel

直播子频道。

class cyan.model.channel.ScheduleChannel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.channel.AppChannel

日程子频道。

async create_schedule(name: str, start_time: datetime.datetime, end_time: datetime.datetime, remind_type: cyan.model.schedule.RemindType = RemindType.SILENT, description: str = '', destination: Optional[cyan.model.channel.Channel] = None) cyan.model.schedule.Schedule[源代码]

异步在当前子频道创建日程。

参数:
  • name: 日程名称

  • start_time: 日程开始时间

  • end_time: 日程结束时间

  • remind_type: 提醒类型

  • description: 日程描述

  • destination: 日程指向目标子频道

返回:

Schedule 类型表示的日程。

static from_app_channel(channel: cyan.model.channel.AppChannel) cyan.model.channel.ScheduleChannel[源代码]

转换 AppChannel 实例为 ScheduleChannel 实例。

参数:
  • channel: 所需转换的应用子频道(应用子频道类型必须为日程提醒)

返回:

ScheduleChannel 类型表示等效于被转换应用子频道的日程子频道。

async get_schedule(identifier: str) cyan.model.schedule.Schedule[源代码]

异步获取子频道的指定 ID 日程。

参数:
  • identifier: 日程 ID

返回:

Schedule 类型表示的日程。

async get_schedules() List[cyan.model.schedule.Schedule][源代码]

异步获取子频道当天日程列表。

返回:

Schedule 类型表示日程的 list 集合。

class cyan.model.channel.TextChannel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.channel.Channel, cyan.model.ChattableModel[cyan.model.message.message.ChannelMessage]

文字子频道。

class MessageAuditInfo(bot: cyan.bot.Bot, props: Dict[str, Any])

基类:cyan.model.Model

消息审核信息。

property bot: cyan.bot.Bot

Model 所属机器人。

async get_channel() TextChannel

异步获取当前消息审核信息所属子频道。

async get_guild() cyan.model.guild.Guild

异步获取当前消息审核信息所属频道。

property identifier: str

Model ID。

class MessageContent(iterable=(), /)

基类:List[cyan.model.message.MessageElement]

消息内容。

extract_plain_text() str

提取纯文本。

返回:

str 类型表示消息内容的所有纯文本。

to_dict() Dict[str, Any]

转换为可被 API 解析的字典。

返回:

可被 API 解析的当前实例的等效字典。

Sendable

alias of Union[cyan.model.message.MessageElement, str, cyan.model.message.Message[Any], Iterable[cyan.model.message.MessageElement]]

async announce(message: cyan.model.message.message.ChannelMessage) cyan.model.announcement.Announcement[源代码]

异步在当前子频道公告指定消息。

参数:
  • message: 将要在当前子频道公告的消息

返回:

Announcement 类型表示的公告。

async get_message(identifier: str) cyan.model.message.message.ChannelMessage[源代码]

异步获取指定 ID 消息。

参数:
  • identifier: 消息 ID

返回:

Message 类型表示的消息。

async recall_announcement() None[源代码]

异步撤销当前子频道的公告。

async reply(target: cyan.model.message.message.ChannelMessage, *message: Union[cyan.model.message.MessageElement, str, cyan.model.message.Message[Any], Iterable[cyan.model.message.MessageElement]]) cyan.model.message.message.ChannelMessage[源代码]

异步回复指定消息。

参数:
  • target: 将要被回复的消息

  • message: 回应消息

返回:

返回表示以 Message 类型表示的所发送消息。

async send(*message: Union[cyan.model.message.MessageElement, str, cyan.model.message.Message[Any], Iterable[cyan.model.message.MessageElement]]) Union[cyan.model.message.MessageAuditInfo, cyan.model.message.message.ChannelMessage][源代码]

异步发送消息。

参数:
  • message: 将要发送的消息

返回:

当消息需被审核时返回以 MessageAuditInfo 类型表示的消息审核信息; 否则,返回表示以 Message 类型表示的所发送消息。

property text_channel_type: Union[cyan.model.channel.TextChannelType, int]

文字子频道类型。

当类型值在 TextChannelType 中时为对应 TextChannelType; 否则为指示当前文字子频道类型的 int 值。

class cyan.model.channel.TextChannelType(value)[源代码]

基类:enum.Enum

文字子频道类型。

ANNOUNCEMENT = 1

公告。

CHAT = 0

闲聊。

GAME = 3

开黑。

STRATEGY = 2

攻略。

class cyan.model.channel.UnknownChannel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.channel.Channel

未知子频道。

property channel_type: int

子频道类型。

class cyan.model.channel.VoiceChannel(bot: cyan.bot.Bot, guild: cyan.model.guild.Guild, props: Dict[str, Any])[源代码]

基类:cyan.model.channel.Channel

语音子频道。

async cyan.model.channel.parse(bot: cyan.bot.Bot, _dict: Dict[str, Any], guild: Optional[cyan.model.guild.Guild] = None) Union[cyan.model.channel.Channel, cyan.model.channel.ChannelGroup][源代码]

解析子频道信息字典为 ChannelChannelGroup 类型。

参数:
  • _dict: 将用于解析的字典

  • guild: 目标的附属频道

返回:

当子频道类型为子频道组时返回以 ChannelGroup 类型表示的子频道组,否则返回以 Channel 类型表示的子频道。