-
Notifications
You must be signed in to change notification settings - Fork 1
/
chatterino.d.ts
133 lines (112 loc) · 2.81 KB
/
chatterino.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/** @noSelfInFile */
declare module c2 {
enum LogLevel {
Debug,
Info,
Warning,
Critical,
}
class CommandContext {
words: string[];
channel: Channel;
}
enum Platform {
Twitch,
}
enum ChannelType {
None,
Direct,
Twitch,
TwitchWhispers,
TwitchWatching,
TwitchMentions,
TwitchLive,
TwitchAutomod,
Irc,
Misc,
}
interface IWeakResource {
is_valid(): boolean;
}
interface ISharedResource {}
class RoomModes {
unique_chat: boolean;
subscriber_only: boolean;
emotes_only: boolean;
follower_only: null | number;
slow_mode: null | number;
}
class StreamStatus {
live: boolean;
viewer_count: number;
uptime: number;
title: string;
game_name: string;
game_id: string;
}
class Channel implements IWeakResource {
is_valid(): boolean;
get_name(): string;
get_type(): ChannelType;
get_display_name(): string;
send_message(message: string, execute_commands: boolean): void;
add_system_message(message: string): void;
is_twitch_channel(): boolean;
get_room_modes(): RoomModes;
get_stream_status(): StreamStatus;
get_twitch_id(): string;
is_broadcaster(): boolean;
is_mod(): boolean;
is_vip(): boolean;
static by_name(this: void, name: string, platform: Platform): null | Channel;
static by_twitch_id(this: void, 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,
handler: (ctx: CommandContext) => void
): boolean;
class CompletionEvent {
query: string;
full_text_content: string;
cursor_position: number;
is_first_word: boolean;
}
class CompletionList {
values: string[];
hide_others: boolean;
}
enum EventType {
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;
}