Introduce HTTP API for plugins (#5383)

This commit is contained in:
Mm2PL
2024-06-22 12:04:30 +02:00
committed by GitHub
parent 7dc80bc599
commit c980162656
19 changed files with 1166 additions and 11 deletions
+32
View File
@@ -32,6 +32,8 @@ declare module c2 {
is_valid(): boolean;
}
interface ISharedResource {}
class RoomModes {
unique_chat: boolean;
subscriber_only: boolean;
@@ -69,6 +71,36 @@ declare module c2 {
static by_twitch_id(id: string): null | Channel;
}
enum HTTPMethod {
Get,
Post,
Put,
Delete,
Patch,
}
class HTTPResponse implements ISharedResource {
data(): string;
status(): number | null;
error(): string;
}
type HTTPCallback = (res: HTTPResponse) => void;
class HTTPRequest implements ISharedResource {
on_success(callback: HTTPCallback): void;
on_error(callback: HTTPCallback): void;
finally(callback: () => void): void;
set_timeout(millis: number): void;
set_payload(data: string): void;
set_header(name: string, value: string): void;
execute(): void;
// might error
static create(method: HTTPMethod, url: string): HTTPRequest;
}
function log(level: LogLevel, ...data: any[]): void;
function register_command(
name: String,