Table of Contents
- The bot
- chat (data) event
- plainchat (message) event
- ccstart event
- addCloop (command, rate) function
- removeCloop (index) function
- clearCloops () function
- runCommand (name, uuid, text, prefix) function
- printHelp (uuid, prefix, lang) function
- printCmdHelp (uuid, cmd, lang, color) function
- advanceccq () function
- tellraw (uuid, message) function
- info (message) function
- chat (message) function
- findUUID (name) function
- findRealName (name) function
- add_sc_task (name, failTask, chatCommand, startFailed) function
- Utils (util folder)
- chatparse_1204 (data) function
- chatparse_console (data) function
- chatparse_plain (data) function
- Command (uuid, user, nick, cmd, prefix, bot, verify, lang = settings.defaultLang) class
- ConsoleCommand (cmd, index2) class
- hashcheck (cmd) function
- lang.getMessage (l, msg, with2) function
- lang.timeFormat (time, language) function
- usergen (legal) function
- Index.js
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 sendermessage
: The message being sent, if it can be parsedusername
: 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 commanduuid
: UUID running the commandtext
: Command textprefix
: Prefix used to run the command
printHelp (uuid, prefix, lang)
function
Shows the help command to somebody.
uuid
: UUID running the commandprefix
: Prefix used to run the commandlang
: 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 commandcmd
: Command to display information aboutlang
: The language that the player has selected (not implemented) or the bot's defaultcolor
: 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 tomessage
: 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 addedfailTask
: Command to run when failed is truechatCommand
: Whether to run failTask in chat rather than in command blockstartFailed
: 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 UUIDuser
: Player user namenick
: Player nicknamecmd
: Command being calledprefix
: Prefix used to run the commandbot
: Bot on the server the command is being run fromverify
: Permission level determined from the hash or lack thereoflang
: 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 JSONtext
: 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 calledindex2
: Index of the bot in the bot array where the command is being run (running commands likesay *
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
: Alwaysdde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console
. Hard-coded because the console does not have a UUID.username
: AlwaysOwner
. Hard-coded because the console does not have a username.nickname
: AlwaysConsole
. Hard-coded because the console does not have a nickname.cmd
: Command being calledprefix
: 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 commandindex
: Always theindex2
value. Hard-coded because the console does not have a bot ID.args
: Arguments of the commandverify
: Always3
. 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
: Always3
. Hard-coded because the console does not have a server port. Displays as:3
in commands such asnetmsg
.lang
: The bot's default languagecolors
: 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
.
usergen (legal)
function
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.