Update chatterino.d.ts to match plugin-meta.lua (#5792)

This commit is contained in:
Mm2PL
2025-01-19 15:09:45 +01:00
committed by GitHub
parent 1ec1377c08
commit a2ad19df37
4 changed files with 121 additions and 115 deletions
+3
View File
@@ -1,6 +1,9 @@
trailingComma: es5 trailingComma: es5
endOfLine: auto endOfLine: auto
overrides: overrides:
- files: "*.ts"
options:
tabWidth: 4
- files: "*.md" - files: "*.md"
options: options:
proseWrap: preserve proseWrap: preserve
+108 -109
View File
@@ -1,133 +1,132 @@
/** @noSelfInFile */ /** @noSelfInFile */
declare module c2 { declare module c2 {
enum LogLevel { enum LogLevel {
Debug, Debug,
Info, Info,
Warning, Warning,
Critical, Critical,
} }
class CommandContext { class CommandContext {
words: String[]; words: string[];
channel: Channel; channel: Channel;
} }
enum Platform { enum ChannelType {
Twitch, None,
} Direct,
enum ChannelType { Twitch,
None, TwitchWhispers,
Direct, TwitchWatching,
Twitch, TwitchMentions,
TwitchWhispers, TwitchLive,
TwitchWatching, TwitchAutomod,
TwitchMentions, Misc,
TwitchLive, }
TwitchAutomod,
Irc,
Misc,
}
interface IWeakResource { interface IWeakResource {
is_valid(): boolean; is_valid(): boolean;
} }
interface ISharedResource {} interface ISharedResource {}
class RoomModes { class RoomModes {
unique_chat: boolean; unique_chat: boolean;
subscriber_only: boolean; subscriber_only: boolean;
emotes_only: boolean; emotes_only: boolean;
follower_only: null | number; follower_only: null | number;
slow_mode: null | number; slow_mode: null | number;
} }
class StreamStatus { class StreamStatus {
live: boolean; live: boolean;
viewer_count: number; viewer_count: number;
uptime: number; uptime: number;
title: string; title: string;
game_name: string; game_name: string;
game_id: string; game_id: string;
} }
class Channel implements IWeakResource { class Channel implements IWeakResource {
is_valid(): boolean; is_valid(): boolean;
get_name(): string; get_name(): string;
get_type(): ChannelType; get_type(): ChannelType;
get_display_name(): string; get_display_name(): string;
send_message(message: string, execute_commands: boolean): void;
add_system_message(message: string): void;
is_twitch_channel(): boolean; send_message(message: string, execute_commands: boolean): void;
send_message(message: string): void;
get_room_modes(): RoomModes; add_system_message(message: string): void;
get_stream_status(): StreamStatus;
get_twitch_id(): string;
is_broadcaster(): boolean;
is_mod(): boolean;
is_vip(): boolean;
static by_name(name: string, platform: Platform): null | Channel; is_twitch_channel(): boolean;
static by_twitch_id(id: string): null | Channel;
}
enum HTTPMethod { get_room_modes(): RoomModes;
Get, get_stream_status(): StreamStatus;
Post, get_twitch_id(): string;
Put, is_broadcaster(): boolean;
Delete, is_mod(): boolean;
Patch, is_vip(): boolean;
}
class HTTPResponse implements ISharedResource { static by_name(name: string): null | Channel;
data(): string; static by_twitch_id(id: string): null | Channel;
status(): number | null; }
error(): string;
}
type HTTPCallback = (res: HTTPResponse) => void; enum HTTPMethod {
class HTTPRequest implements ISharedResource { Get,
on_success(callback: HTTPCallback): void; Post,
on_error(callback: HTTPCallback): void; Put,
finally(callback: () => void): void; Delete,
Patch,
}
set_timeout(millis: number): void; class HTTPResponse implements ISharedResource {
set_payload(data: string): void; data(): string;
set_header(name: string, value: string): void; status(): number | null;
error(): string;
}
execute(): void; type HTTPCallback = (res: HTTPResponse) => void;
class HTTPRequest implements ISharedResource {
on_success(callback: HTTPCallback): void;
on_error(callback: HTTPCallback): void;
finally(callback: () => void): void;
// might error set_timeout(millis: number): void;
static create(method: HTTPMethod, url: string): HTTPRequest; set_payload(data: string): void;
} set_header(name: string, value: string): void;
function log(level: LogLevel, ...data: any[]): void; execute(): void;
function register_command(
name: String,
handler: (ctx: CommandContext) => void
): boolean;
class CompletionEvent { // might error
query: string; static create(method: HTTPMethod, url: string): HTTPRequest;
full_text_content: string; }
cursor_position: number;
is_first_word: boolean;
}
class CompletionList { function log(level: LogLevel, ...data: any[]): void;
values: String[]; function register_command(
hide_others: boolean; name: string,
} handler: (ctx: CommandContext) => void
): boolean;
enum EventType { class CompletionEvent {
CompletionRequested = "CompletionRequested", query: string;
} full_text_content: string;
cursor_position: number;
is_first_word: boolean;
}
type CbFuncCompletionsRequested = (ev: CompletionEvent) => CompletionList; class CompletionList {
type CbFunc<T> = T extends EventType.CompletionRequested values: string[];
? CbFuncCompletionsRequested hide_others: boolean;
: never; }
function register_callback<T>(type: T, func: CbFunc<T>): void; enum EventType {
function later(callback: () => void, msec: number): void; CompletionRequested = "CompletionRequested",
}
type CbFuncCompletionsRequested = (ev: CompletionEvent) => CompletionList;
type CbFunc<T> = T extends EventType.CompletionRequested
? CbFuncCompletionsRequested
: never;
function register_callback<T>(type: T, func: CbFunc<T>): void;
function later(callback: () => void, msec: number): void;
} }
+2
View File
@@ -70,6 +70,8 @@ c2.ChannelType = {
---@field subscriber_only boolean ---@field subscriber_only boolean
---@field unique_chat boolean You might know this as r9kbeta or robot9000. ---@field unique_chat boolean You might know this as r9kbeta or robot9000.
---@field emotes_only boolean Whether or not text is allowed in messages. Note that "emotes" here only means Twitch emotes, not Unicode emoji, nor 3rd party text-based emotes ---@field emotes_only boolean Whether or not text is allowed in messages. Note that "emotes" here only means Twitch emotes, not Unicode emoji, nor 3rd party text-based emotes
---@field follower_only number? Time in minutes you need to follow to chat or nil.
---@field slow_mode number? Time in seconds you need to wait before sending messages or nil.
-- End src/providers/twitch/TwitchChannel.hpp -- End src/providers/twitch/TwitchChannel.hpp
+8 -6
View File
@@ -115,24 +115,26 @@ public:
*/ */
bool emoteOnly = false; bool emoteOnly = false;
/**
* @lua@field follower_only number? Time in minutes you need to follow to chat or nil.
*/
/** /**
* @brief Number of minutes required for users to be followed before typing in chat * @brief Number of minutes required for users to be followed before typing in chat
* *
* Special cases: * Special cases:
* -1 = follower mode off * -1 = follower mode off
* 0 = follower mode on, no time requirement * 0 = follower mode on, no time requirement
* */
* @lua@field follower_only number? Time in minutes you need to follow to chat or nil.
**/
int followerOnly = -1; int followerOnly = -1;
/**
* @lua@field slow_mode number? Time in seconds you need to wait before sending messages or nil.
*/
/** /**
* @brief Number of seconds required to wait before typing emotes * @brief Number of seconds required to wait before typing emotes
* *
* 0 = slow mode off * 0 = slow mode off
* */
* @lua@field slow_mode number? Time in seconds you need to wait before sending messages or nil.
**/
int slowMode = 0; int slowMode = 0;
}; };