Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Index

Properties

ctx

ctx: ApiCtx

Optional listener

listener: EventEmitter

Event emitter emitting incoming messages. Set by Api.listen() method. Possible event names are error, message, typ, presence and close.

Activation Methods

getAppState

  • Returns the AppState which can be saved and reused in future logins without needing the password.

    Returns AppState

isActive

  • isActive(): boolean
  • This value indicates whether the API listens for events and is able to send messages. This property is true if API.listen method was invoked.

    Returns boolean

listen

  • listen(): Promise<EventEmitter>
  • Establish the websocket connection and enables message sending and receiving. Possible event names are error, message, typ, presence and close.

    Returns Promise<EventEmitter>

    Event emitter emitting all incoming events.

stopListening

  • stopListening(): void
  • Closes the websocket connection and, consequently, disables message sending and receiving.

    Returns void

Customisation Methods

changeThreadColorTheme

  • changeThreadColorTheme(threadId: ThreadID, themeId: number): Promise<void>
  • Sets a custom colour theme to a thread with threadId. ⚠ Warning: threadId parameter will change to enum soon

    Parameters

    Returns Promise<void>

changeThreadEmoji

  • changeThreadEmoji(threadId: ThreadID, emoji: string): Promise<void>
  • Sets a custom emoji to a thread with threadId. If you want to keep the original Facebook "like", set the emoji argument as an empty string.

    Parameters

    Returns Promise<void>

Group management Methods

addUserToGroup

  • addUserToGroup(userIds: string | number | ThreadID[], threadId: ThreadID): Promise<void>
  • Adds one or more users to a group with id threadId.

    Parameters

    Returns Promise<void>

changeAdminStatus

  • changeAdminStatus(threadId: ThreadID, userId: ThreadID, isAdmin: boolean): Promise<void>
  • Marks a user as admin/non-admin in a group chat. If the user calling this function has insufficient permissions to raise admins in the group, nothing happens.

    Parameters

    Returns Promise<void>

changeGroupName

  • changeGroupName(threadId: ThreadID, newName: string): Promise<void>
  • Changes the group chat title. This works only on groups.

    Parameters

    Returns Promise<void>

changeGroupPhoto

  • changeGroupPhoto(threadId: ThreadID, photo: Readable): Promise<void>
  • Set a profile picture to a group with id threadId.

    example
    import fs from 'fs';
    api.changeGroupPhoto(9876543219876, fs.createReadableStream('path_to_picture'))
    

    Parameters

    Returns Promise<void>

leaveGroup

  • leaveGroup(threadId: ThreadID): Promise<void>

removeUserFromGroup

  • Removes one user from a group with id threadId.

    Parameters

    Returns Promise<void>

Messages Methods

clearMessageReaction

  • clearMessageReaction(threadId: ThreadID, messageId: string): Promise<void>
  • Parameters

    Returns Promise<void>

forwardMessage

  • forwardMessage(messageID: string, threadID: ThreadID): Promise<void>
  • Forwards a message with id messageID to thread threadId. You can use this method to send an attachment without uploading it again.

    Parameters

    Returns Promise<void>

markAsRead

  • markAsRead(threadId: ThreadID): Promise<void>
  • Marks a thread with given threadId as read.

    Parameters

    Returns Promise<void>

sendMessage

  • Sends a message to a given thread.

    Parameters

    • msg: OutgoingMessage

      Actual message object - can contain attachments, mentions, reply...

    • threadID: ThreadID

      ID of a thread to send the message to

    Returns Promise<void>

sendMessageReaction

  • sendMessageReaction(threadId: ThreadID, messageId: string, reaction: string): Promise<void>
  • Sends a reaction to a message with id messageId in a thread with threadId.

    Parameters

    • threadId: ThreadID
    • messageId: string
    • reaction: string

      An emoji to use in the reaction. The string must be exactly one emoji.

    Returns Promise<void>

sendTypingIndicator

  • sendTypingIndicator(threadID: ThreadID, isTyping: boolean, timeout?: number): Promise<void>
  • Sends a typing indicator to a thread with id threadId.

    Parameters

    • threadID: ThreadID

      the specified thread to send the indicator to

    • isTyping: boolean

      the actual state of typing indicator (typing or not typing)

    • timeout: number = 20000

      time in milliseconds after which to turn off the typing state if the state is set to true - default 20000 (20 seconds)

    Returns Promise<void>

unsendMessage

  • unsendMessage(messageID: string): Promise<void>
  • Unsends the message with given messageId, resulting in other participants not seeing the original content of the message.

    Parameters

    • messageID: string

    Returns Promise<void>

Other Methods

logout

  • logout(): Promise<void>

Threads Methods

getThreadHistory

  • Returns amount of thread messages before the timestamp (default undefined - last messages)

    Parameters

    • threadID: ThreadID
    • amount: number
    • Optional timestamp: number

    Returns Promise<ThreadHistory>

getThreadInfo

  • Returns all available information about a thread with threadId.

    Parameters

    Returns Promise<ThreadInfo>

Users Methods

getFriendsList

  • Returns all available information about all user's friends as an array of user objects.

    Returns Promise<UserInfo[]>

getUserInfo