Skip to content

fControl

Redwyn edited this page Aug 29, 2022 · 5 revisions

About

fControl is the primary "engine" that allows fTerm to interact with F-Chat's servers as a standalone client. For the sake of easy extensibility it has been designed with the ability to drop-in new client-modules that can be loaded on start up.

Usage

to use fControl is easy and simply requires the following lines of code to operate:

let client = new fControl(API_ROOT, API_ENDPOINTS, CREDENTIALS, CONSOLE_CALLBACK);

client.getTicket();

client.connect();

API_ROOT

API_ROOT refers to the root URL of the authorization server. by default this points to https://www.f-list.net but you can use undefined and fControl will automatically fallback to the integrated definitions.

In the future this may be reworked to allow you to define all parameters in pure JSON.

API_ENDPOINTS

API_ENDPOINTS, like API_ROOT can be replaced with undefined to make it fallback to it's integrated definitions. It is a JSON object as follows:

{
    "getApiTicket" : "URL",

    "bookmark_add" : "URL",

    "bookmark_list" : "URL",

    "bookmark_remove" : "URL",

    "character_data" : "URL",

    "character_list" : "URL",

    "group_list" : "URL",

    "ignore_list" : "URL",

    "info_list" : "URL",

    "kink_list" : "URL",

    "mapping_list" : "URL",

    "friend_list" : "URL",

    "friend_remove" : "URL",

    "request_accept" : "URL",

    "request_cancel" : "URL",

    request_deny"" : "URL",

    "request_list" : "URL",

    "request_pending" : "URL",

    "request_send" : "URL",

}

CREDENTIALS

Credentials is also a JSON object, it follows the F-List GetTicket.php request requirements as this is passed directly to the F-List server.

{
    "account" : "username",
    "password" : "password
}

Methods

Below is a list of methods within the fControl class. These can be called upon by loaded modules.

Safe for use by Modules Method Parameters Purpose
Yes addUser Username, Gender, Status, StatusMsg Adds a user to the list of online users.
No connect None initiates a connection with the server. getTicket must be called before using.
Yes getTime None Returns an array with the current time.
No getTicket None Grabs a ticket from the F-Chat servers.
Yes getUser Username Gets a user from the user table. Returns null if user doesn't exist.
Yes printLine channel (Optional), Message Prints a message to a specified channel, this is only visible to the user. While the channel parameter is first, it is still optional to specify.
Yes printDebug channel(Optional), Message The same as printLine but adds a DEBUG prefix to the message.
Yes printError channel(Optional), Message The same as printLine but adds an ERROR prefix to the message.
Yes printMessage channel, User, Message The same as printLine but adds the specified User as the prefix to the message. Channel is required and the User parameter is displayed as-is.
Yes printNotice channel(Optional), Message The same as printLine but adds a NOTICE prefix to the message. Primarily used for highlighting moderator/staff broadcasts.
Yes printWarning channel(Optional), Message The same as printLine but adds a WARNING prefix to the message.
Yes removeUser Username Removes a user from the usertable, if they exist.
Yes sendCommand identifier, payload(Optional) sends a command back to the server. the identifier should be a sring. If the payload is specified, it needs to be a JSON object.

Events

fControl produces the following events:

  • unknowncmd: Reports when a server-side command is unknown.
    • Reports: payload(JSON)

Clone this wiki locally