Created
August 24, 2020 14:33
-
-
Save alephalpha0/d11cc7a3391b073ff7c874569b0dccff to your computer and use it in GitHub Desktop.
Base Typings for the Chaturbate Script API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IChatHost { | |
//#region Methods | |
/** | |
* Changes the room subject. This function is only available to apps, not bots. | |
* | |
* @param {string} new_subject The new room subject | |
* @memberof IChatHost | |
*/ | |
changeRoomSubject(new_subject: string): void; | |
/** | |
* Send a message to the room | |
* | |
* @param {string} message The content of the message. You may use :emoticons in the notice. You can use a \n inside the message to send a multi-line notice. | |
* @param {string} [to_user] Recipient of the message. Set to an empty string to send a notice to the whole room | |
* @param {string} [background] Background color of the notice. Only HEX HTML code are supported. | |
* @param {string} [foreground] Foreground color of the notice. Only HEX HTML code are supported. | |
* @param {string} [weight] Font weight of the Notice. Accepted values: normal, bold, or bolder | |
* @param {string} [to_group] Use this parameter to send a message to a specific group of people. Check out Chaturbate's official Docs for more info. | |
* @memberof IChatHost | |
*/ | |
sendNotice(message: string, to_user?: string, background?: string, foreground?: string, weight?: string, to_group?: string): void; | |
/** | |
* Calls a function after timeout. It returns an id which can be used to cancel the timeout. | |
* | |
* @param {() => void} func The Function to be Called | |
* @param {number} interval Interval in milliseconds before the function call. | |
* @returns {*} | |
* @memberof IChatHost | |
*/ | |
setTimeout(func: () => void, interval: number): any; | |
/** | |
* Cancels the timeout identified by Id. use the Id returned from cb.setTimeout to cancel timeout. | |
* | |
* @param {*} id Id of the Timeout to cancel | |
* @memberof IChatHost | |
*/ | |
cancelTimeout(id: any): void | |
/** | |
* Requests that all users reload the panel (the HTML info area below the cam). The contents of the panel are controlled by cb.onDrawPanel(func). | |
* | |
* @memberof IChatHost | |
*/ | |
drawPanel(): void; | |
/** | |
* Adds a debug message to the chat. These log messages are broadcast to the chat room, but you must enable debug mode to see them. | |
* To enable or disable debug mode, type /debug into chat. | |
* | |
* @param {*} message | |
* @memberof IChatHost | |
*/ | |
log(message: any): void; | |
//#endregion | |
//#region Limit Cam Functionality | |
limitCam_start(message: string, allowed_users?: string[]): void; | |
limitCam_stop(): void; | |
limitCam_addUsers(allowed_users: string[]): void; | |
limitCam_removeUsers(removed_users: string[]): void; | |
limitCam_removeAllUsers(): void; | |
limitCam_userHasAccess(username: string): boolean; | |
limitCam_allUsersWithAccess(): string[]; | |
limitCam_isRunning(): boolean | |
//#endregion Limit Cam Functionality | |
//#region Chat Events | |
/** | |
* Return data needed to display the info panel for a user. | |
* | |
* @param {(user: IUser) => IDrawPanelSettings} func function creating the object | |
* @memberof IChatHost | |
*/ | |
onDrawPanel(func: (user: IUser) => IDrawPanelSettings): void; | |
/** | |
* Receive a notification when a registered member enters the room. | |
* | |
* @param {(user: IUser) => void} func | |
* @memberof IChatHost | |
*/ | |
onEnter(func: (user: IUser) => void): void; | |
/** | |
* Receive a notification when a registered member leaves the room. | |
* | |
* @param {(user: IUser) => void} func | |
* @memberof IChatHost | |
*/ | |
onLeave(func: (user: IUser) => void): void; | |
/** | |
* Receive a notification when a message is sent. Your app can manipulate the message. You must return the original message object. | |
* | |
* @param {(message: IMessage) => IMessage} func | |
* @memberof IChatHost | |
*/ | |
onMessage(func: (message: IMessage) => IMessage): void | |
/** | |
* Receive a notification when a tip is sent. | |
* | |
* @param {(tip: ITip) => ITip} func | |
* @memberof IChatHost | |
*/ | |
onTip(func: (tip: ITip) => ITip): void; | |
//#endregion Chat Events | |
//#region PanCam Functionality | |
/** | |
* Moves the camera. | |
* | |
* @param {("up" | "down" | "left" | "right" | "in" | "out")} direction The direction in which the camera should move | |
* @memberof IChatHost | |
*/ | |
panCam_move(direction: "up" | "down" | "left" | "right" | "in" | "out"): void; | |
/** | |
* Receive a notification when a PanCam button is clicked. | |
* This function is required to make a PanCam Move call when a user clicks from the panel. | |
* You can validate a users ability to move the cam before calling cb.pancam_move(direction). | |
* | |
* @param {*} func | |
* @memberof IChatHost | |
*/ | |
panCam_onPanelButtonClicked(func: any): void; | |
/** | |
* Check if string is a valid direction. . | |
* | |
* @param {string} direction | |
* @returns {boolean} Returns true if direction in ["up","down","left","right","in","out"] | |
* @memberof IChatHost | |
*/ | |
panCam_isValidDirection(direction: string): boolean; | |
//#endregion | |
/** | |
* A variable that contains the name of the current room | |
* | |
* @type {string} | |
* @memberof IChatHost | |
*/ | |
room_slug: string; | |
settings_choices: ISetting[]; | |
settings: ISettingObject; | |
} | |
interface ISettingObject extends Object { | |
[name: string]: Object | |
} | |
interface IUser { | |
user: string; | |
in_fanclub: boolean; | |
has_tokens: boolean; | |
is_mod: boolean; | |
tipped_recently: boolean; | |
tipped_alot_recently: boolean; | |
tipped_tons_recently: boolean; | |
gender: string; | |
} | |
interface IMessage extends IUser { | |
c: string; | |
m: string; | |
f: string; | |
background: string; | |
} | |
interface ITip { | |
amount: string; | |
message: string; | |
to_user: string; | |
from_user: string; | |
from_user_in_fanclub: boolean; | |
from_user_has_tokens: boolean; | |
from_user_is_mod: boolean; | |
from_user_tipped_recently: boolean; | |
from_user_tipped_alot_recently: boolean; | |
from_user_tipped_tons_recently: boolean; | |
from_user_gender: string; | |
} | |
interface ISetting { | |
name: string; | |
type: string; | |
required?: boolean; | |
label?: string; | |
minValue?: number; | |
maxValue?: number; | |
minLength?: number; | |
maxLength?: number; | |
defaultValue?: any; | |
} | |
interface ITipOptions { | |
options: ITipOption[]; | |
label: string; | |
} | |
interface ITipOption { | |
label: string; | |
} | |
interface IChatUtils { | |
arrayContains<T>(array: T[], element: T): boolean; | |
arrayRemove<T>(array: T[], element: T): void; | |
} | |
interface ITipper { | |
Tokens: number; | |
User: string; | |
} | |
interface IDrawPanelSettings { | |
template: string; | |
row1_label?: string; | |
row2_label?: string; | |
row3_label?: string; | |
row1_value?: string; | |
row2_value?: string; | |
row3_value?: string; | |
} | |
type OnDrawPanelCallback = () => void; | |
declare var cb: IChatHost; | |
declare var cbjs: IChatUtils; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment