-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Introduce functions related to chatting
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,64 @@ | ||
import { CurrentUserAttributes, User } from "./user.js"; | ||
|
||
export type ChannelType = | ||
"PUBLIC" | | ||
"PRIVATE" | | ||
"MULTIPLAYER" | | ||
"SPECTATOR" | | ||
"TEMPORARY" | | ||
"PRIVATE" | | ||
"PM" | | ||
"GROUP" | | ||
"ANNOUNCE"; | ||
import { User } from "./user.js"; | ||
|
||
/** | ||
* Expected from api.keepChatAlive() | ||
*/ | ||
export interface UserSilence { | ||
id: number | ||
user_id: number | ||
} | ||
|
||
/** | ||
* Expected from api.sendChatPrivateMessage(), api.createChatPrivateChannel() | ||
*/ | ||
export interface ChatChannel { | ||
channel_id: number | ||
name: string | ||
description: string | null | ||
icon: string | null | ||
type: ChannelType | ||
type: "PUBLIC" | "PRIVATE" | "MULTIPLAYER" | "SPECTATOR" | "TEMPORARY" | "PRIVATE" | "PM" | "GROUP" | "ANNOUNCE" | ||
moderated: boolean | ||
uuid: string | null | ||
current_user_attributes?: CurrentUserAttributes | null | ||
last_message_id?: number | null | ||
users?: number[] | null | ||
} | ||
|
||
/** | ||
* Expected from api.joinChatChannel(), api.getChatChannel() | ||
*/ | ||
export interface ChatChannelWithDetails extends ChatChannel { | ||
current_user_attributes: { | ||
can_message: boolean | ||
/** | ||
* The reason why messages can't be sent in this channel | ||
* @remarks Is null if messages can be sent | ||
*/ | ||
can_message_error: string | null | ||
/** | ||
* @remarks Is null if no message has been read (I think) | ||
*/ | ||
last_read_id: number | null | ||
} | ||
last_message_id: number | ||
/** | ||
* The ids of the users that are in the channel | ||
* @remarks Is empty for public channels | ||
*/ | ||
users: number[] | ||
} | ||
|
||
/** | ||
* Expected from api.sendChatPrivateMessage(), api.getChatMessages(), api.sendChatMessage() | ||
*/ | ||
export interface ChatMessage { | ||
channel_id: number | ||
content: string | ||
is_action: boolean | ||
message_id: number | ||
sender_id: number | ||
timestamp: Date | ||
/** | ||
* Like "action", "markdown", "plain" | ||
*/ | ||
type: string | ||
uuid: string | null | ||
sender?: User | ||
uuid?: string | null | ||
sender: User | ||
} |