1 Welcome to the Wiki
7cc5c4f330d47060 edited this page 2024-08-02 04:07:18 -04:00

I have no idea what I'm doing

The bot

chat (data) event

Gets called whenever a message is received. data format is as follows:

  • json: The raw JSON of the message.
  • type: The type of message (player, profileless, system, legacy)
  • uuid: The UUID of the message's sender
  • message: The message being sent, if it can be parsed
  • username: The username sending the message, if it can be parsed

plainchat (message) event

Gets called whenever a message is received. message is an already parsed message without any colors in any format.

ccstart event

Gets called whenever the command core is ready to be used.

addCloop (command, rate) function

A function to create a command loop of command command at rate rate.

removeCloop (index) function

This removes the cloop of index index.

clearCloops () function

This removes all command loops.

runCommand (name, uuid, text, prefix) function

Executes a command.

  • name: Username running the command
  • uuid: UUID running the command
  • text: Command text
  • prefix: Prefix used to run the command

printHelp (uuid, prefix, lang) function

Shows the help command to somebody.

  • uuid: UUID running the command
  • prefix: Prefix used to run the command
  • lang: The language that the player has selected (not implemented) or the bot's default

printCmdHelp (uuid, cmd, lang, color) function

Shows the help of a specific command to somebody.

  • uuid: UUID running the command
  • cmd: Command to display information about
  • lang: The language that the player has selected (not implemented) or the bot's default
  • color: The colors that the player has selected (not implemented) or the bot's default

advanceccq () function

Advances the queue of commands to run in command blocks. Takes no arguments.

tellraw (uuid, message) function

Displays JSON text to a player using tellraw.

  • uuid: UUID/name/@a to display the message to
  • message: JSON text component to send

info (message) function

Displays message to console. Used by the reconnect script.

chat (message) function

Pushes message to the chat queue.

findUUID (name) function

Determine a player's UUID from their real name (not nickname).

findRealName (name) function

Determine a player's real name from their display name.

add_sc_task (name, failTask, chatCommand, startFailed) function

Adds a selfcare task.

  • name: Name of the task being added
  • failTask: Command to run when failed is true
  • chatCommand: Whether to run failTask in chat rather than in command block
  • startFailed: Whether to run this task on login

Utils (util folder)

chatparse_1204 (data) function

Converts data to parsed JSON. If it already is parsed JSON, it passes it through.

chatparse_console (data) function

Parses a single chat message (data) to a format that can be displayed by a terminal in color.

chatparse_plain (data) function

Parses a single chat message (data) to a format that has no color formatting (useful for Discord or similar)

Command (uuid, user, nick, cmd, prefix, bot, verify, lang = settings.defaultLang) class

Internally used by the command handler. Converts the various arguments into a format which can be read by commands.

Inputs:

  • uuid: Player UUID
  • user: Player user name
  • nick: Player nickname
  • cmd: Command being called
  • prefix: Prefix used to run the command
  • bot: Bot on the server the command is being run from
  • verify: Permission level determined from the hash or lack thereof
  • lang: The language that the player has selected (not implemented) or the bot's default

Outputs:

  • send (text, uuid): Effectively just a tellraw wrapper.

    • text: The raw JSON of the message.
    • uuid: UUID/name/@a to display the message to
  • reply (text): Reply to a command with JSON

    • text: The raw JSON of the message.
  • uuid: Player UUID

  • username: Player user name

  • nickname: Player nickname

  • cmd: Command being called

  • prefix: Prefix used to run the command

  • bot: Bot on the server the command is being run from

  • type: Type of bot receiving the command

  • index: Index of the bot in the bot array

  • args: Arguments of the command

  • verify: Permission level determined from the hash or lack thereof

  • host: The server the command was sent from

  • port: The port of server the command was sent from

  • lang: The language that the player has selected (not implemented) or the bot's default

  • colors: The colors that the player has selected (not implemented) or the bot's default

  • ConsoleCommand (cmd, index2) class

Internally used by the command handler. Converts the various arguments into a format which can be read by commands.

Inputs:

  • cmd: Command being called
  • index2: Index of the bot in the bot array where the command is being run (running commands like say * will call this class several times)

Outputs:

  • send (): Stub function. Why do I still have this?
  • reply (text): Reply to a command with JSON (gets parsed by the console parser)
    • text: The raw JSON of the message.
  • uuid: Always dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console. Hard-coded because the console does not have a UUID.
  • username: Always Owner. Hard-coded because the console does not have a username.
  • nickname: Always Console. Hard-coded because the console does not have a nickname.
  • cmd: Command being called
  • prefix: Always an empty string. Hard-coded because the console does not have a prefix to run commands.
  • bot: Bot on the server the command is being run from (a stub with only the help functions if it does not require to be run as a bot)
  • type: Type of bot receiving the command
  • index: Always the index2 value. Hard-coded because the console does not have a bot ID.
  • args: Arguments of the command
  • verify: Always 3. Hard-coded because the console has permission level 3.
  • host: Always an empty string. Hard-coded because the console does not have a server host.
  • port: Always 3. Hard-coded because the console does not have a server port. Displays as :3 in commands such as netmsg.
  • lang: The bot's default language
  • colors: The bot's default colors

hashcheck (cmd) function

Checks cmd against the hashing system. If it matches, it returns a non-zero value corresponding to the level of hash that matched.

lang.getMessage (l, msg, with2) function

Gets a message (msg) in a certain language (l), and replaces all %s with the values in with2.

lang.timeFormat (time, language) function

Formats an amount of time in milliseconds (time) to the language language.

Generates a username for the bot to join the server with.

  • legal: Whether to generate a legal username

Index.js

bot array

An array of bots. Each one should be connected to a different server.

createBot (host, oldId) function

Creates a bot with the options specified by host, on id oldId if specified, otherwise added to the end of the bot array. Used internally by index.js itself as well as the reconnect script.