Skip to content

Repository files navigation

EL LEVERT JR


EL LEVERT

Romanian version of Leveret by Neeve

CommandsExampleAPIConfigImportingAmogus

Warning

This project only supports Node.js 20.x and 21.x.

Node.js 21.7.3 is the final supported version.

Node.js 22 and newer are not supported.

Use Node.js 20.19.6 if you plan on enabling the inspector features.

Features

  • Tags
  • JS eval
  • Permission system
  • Reminders
  • Message previews
  • ...and more!

Updating the bot

Run the following commands to update the bot with the latest code:

git fetch origin
git reset --soft origin/main

TODO

  • Extract responses into a lang file
  • Rewrite vm2 runner
  • Add cabal (banning)
  • Add the option to save tag attachments locally
  • Add support for slash commands (perhaps)
  • Add support for other databases
  • Add support for reading the token from environment variables
  • Add caching
  • Add different behaviour when replying to messages

Commands

1. help

Sends the list of base commands.

2. version

Displays the bot version.

3. tag/tag (name) [args]

Execute tag (name), receiving tag.args = args.

Subcommands:

  • add (name) [type] (body) - Adds the tag (name). If body contains a code block, it will be treated as a script tag. If an image file is attached, it will be added as a url. If a text file is attached, it will be added as a script. If the first argument is vm2 the tag will be added as a vm2 script.
  • alias (name) (alias_name) args - If tag (name) doesn't already exist, it will be created and aliased to (alias_name) with args being appended to tag.args. If (name) already exists and is owned by you, it will be updated to be an alias. Moderators can bypass ownership checks.
  • chown (name) (new_owner) - Transfers the tag to another user, specified either as a username, tag, mention or ID.
  • count [all/new/script/me/user] - Sends the number of tags that have been registered in total, by type or by the specified user.
  • delete (name) - Deletes tag (name) if it's owned by you or if you are a moderator.
  • dump [inline/full] [spaces] - Sends a list of all tags.
  • edit (name) [type] (new_body) - Edits tag (name) with a new body, same ownership and attachment rules as add.
  • fullsearch (query) [max_results=20 / all] - Searches tag bodies for (query). Terms are separated by ",".
  • info (name) [raw] - Sends the properties of tag (name). Moderator only.
  • leaderboard (count/size) [limit=20 <= 50] - Sends the tag leaderboard up to the specified limit.
  • list (user) - Lists all of your tags. If user is specified, their tags will be listed instead.
  • owner (name) - Sends the owner of tag (name).
  • quota - Sends your quota, affected by add, alias, chown, delete and edit. If your quota reaches the limit, you will not be able to add any more tags until you free up some space.
  • random (prefix) - Searches for all tags that either match the given text exactly or are followed by a number and picks one at random.
  • raw (name) - Sends the text or source code of tag (name).
  • rename (name) (new_name) - Renames tag (name) to (new_name) if it's owned by you or if you are a moderator.
  • search (name) [max_results=20 / all] - Searches the tags list for tags matching (name). Matches are approximated, suspicious results are to be expected.
  • set_type (name) (type)/[version] - Sets the type or version properties of tag (name). Moderator only.

4. eval (script)

Evaluates specified script. See the API section for more information.

Subcommands:

  • langs - Sends the list of enabled languages.
  • vm2 (script) - Eval script with the VM2 backend. See API/vm2 for more information.
  • c, cpp, py (script) - Eval script with the external VM backend, quite slow.

By default, only the default JS eval is enabled. The other eval contexts can be enabled in the config. VM2 eval only works under Linux/WSL and the external VM backend needs judge0 to be installed and configured.

5. perm/p

Root command for the permission manager. Can be executed by anyone. For this feature to work properly, set the owner field in auth.json.

Subcommands:

  • add (group_name) (user) - Add (user) to (group_name). Can be executed by admin and above. Cannot add yourself to a group with a level higher than your own.
  • remove (group_name) (user) - Remove (user) from (group_name). Can be executed by admin and above.
  • remove_all (user) - Remove all of (user)'s permissions.
  • list - Sends registered permissions. Can be executed by anyone.
  • add_group (group_name) (level) - Adds (group_name) with the specified level.
  • remove_group (group_name) - Removes (group_name) from the group list and from the permission list of everyone added to it.
  • update_group (group_name) [new_name/unchanged] [new_level/unchanged] - Updates (group_name) with a new name and level.
  • check (user) - Sends permission details for (user). Can be executed by anyone.

The owner group is a special group which only contains the bot owner if configured. It can't be updated or removed and users can't be added or removed from it.

Default permission levels:

  • user: 0
  • moderator: 1 (tagModeratorLevel)
  • admin: 2 (permissionAdminLevel)
  • owner: 2147483647

These levels can be adjusted in the config file and commands can be locked to different levels by adding the allowed: level property.

6. oc (EU/t) (duration)

Calculates overclock EU, duration, and tier for the specified parameters.

7. reminder

Root command for the reminder manager.

Subcommands:

  • add (date) "message" - Adds a reminder for the specified date. The message must be enclosed in quotes.
  • list (user) - Lists all of your reminders. If user is specified, their reminders will be listed instead.
  • remove (index) - Removes reminder at the specified index in your list.
  • remove_all - Removes all reminders.

You will be reminded via a DM from the bot. Example message:

reminder

Command usage example

wet_rat

Other responses

1. Previews

The bot will respond to message links with an embed of the message and/or the first attachment when present. If the link's sender can't read the message, the bot won't respond, making it impossible to leak private channels. Previews will also be generated for message links in the output of tags.

Can be disabled using the enablePreviews config option.

Example:

preview

2. Sed replace

The following syntax:

sed/regex/replace/flags (optional)

Can be used to replace a pattern in a previous message with another pattern. When replying, only the referenced message is going to be replaced. Otherwise, the first matching message will be replaced. Match groups can be referenced in the output using $1, $2, etc.

Can be disabled using the enableSed config option.

Example:

sed

3. Reactions

The bot will react to certain words in a message with configured emojis. It will also react to mismatched brackets if the emoji IDs are set.

Needs to be enabled and configured in config/reactions.json.

Example:

reactions

Evaluation API

1. eval / pure JS API

Mirrors the API of Leveret; see Neeve's API documentation.

Main differences:

  • util.dumpTags can be called with true to recieve a full dump
  • msg.reply exits the script right away
  • util.fetchMessage(ch_id | null, msg_id) allows fetching a single message
  • util.fetchMessages accepts message fetch options
  • util.findUserById allows fetching a user that isn't necessarily in the same server as the bot

If the output is an object or an array, it will be automatically formatted into a string. If it is empty, Cannot send an empty message. will be sent instead.

Example:

reactions

When enableInspector is enabled and enableUserInspector is disabled, the console inspector operates in single-session mode. A DevTools link is printed to the console, scripts wait for the inspector to connect before executing, and the inspector server can be attached to via VS Code.

When both enableInspector and enableUserInspector are enabled, inspector use becomes explicit per command:

  • `%eval debug ```js ... ````
  • %t debug (tag_name) [tag_args]

The reply provides connection details for DevTools, JSON endpoints, and VS Code configurations (launch.json). In this mode, debug sessions are strictly isolated using UUID-scoped endpoints to prevent shared access.

2. vm2 / NodeJS API

Allows for more advanced scripts than the pure js API, allowing for async functions and importing internal and external libraries. Tags can use VM2 scripts by doing %t add (name) vm2 (script)

When not using reply, script output must be sent with return.

Internal module whitelist:

  • assert
  • buffer
  • crypto
  • events
  • path
  • querystring
  • url
  • util
  • zlib

Global scope:

  • tag - Similar to the tag object in pure js. Only available when executing from a tag.
  • msg - Similar to the msg object in pure js.
  • reply, request, fetchTag, dumpTags, findUsers - Async versions of their pure js counterparts.

Example:

%eval vm2 ```js
return "Amogus";
```

Config

config/auth.json must exist and contain the following lines:

{
    "token": "bot token",
    "owner": "your discord id"
}

config/reactions.json must contain at least "enableReacts": false. If enableReacts is set to true, the file must have the following structure:

{
    "enableReacts": true,
    "parens": {
        "left": [left parenthesis emoji ids],
        "right": [right parenthesis emoji ids]
    },
    "funnyWords": [
        {
            "word(s)": "word" or ["word1", "word2"],
            "react(s)": "emoji" or ["emoji1", "emoji2"]
        },
        ...
    ]
}

Startup

If running for the first time, run npm install and hope isolated-vm decides to actually install without 50 errors (rare occurrence). To start the bot, navigate to the root directory and run npm start. Logs will be printed both to the console and to files in the logs folder.

Importing

To download the tag database from the original bot, run %t fulldump or %eval JSON.stringify(util.dumpTags().map(x => util.fetchTag(x))) and download the resulting file. To import these tags, navigate to the root directory and run npm run importer -- -i "path-to-tags".

To check and fix the database, run npm run importer -- -x. To delete all imported tags, run npm run importer -- -1.

Amogus

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣤⣤⣤⣤⣤⣤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⡿⠛⠉⠙⠛⠛⠛⠛⠻⢿⣿⣷⣤⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠋⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⠈⢻⣿⣿⡄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⡏⠀⠀⠀⣠⣶⣾⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣄⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠁⠀⠀⢰⣿⣿⣯⠁⠀⠀⠀⠀⠀⠀⠀⠈⠙⢿⣷⡄⠀
⠀⠀⣀⣤⣴⣶⣶⣿⡟⠀⠀⠀⢸⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⠀
⠀⢰⣿⡟⠋⠉⣹⣿⡇⠀⠀⠀⠘⣿⣿⣿⣿⣷⣦⣤⣤⣤⣶⣶⣶⣶⣿⣿⠀
⠀⢸⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿
⠀⣸⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠉⠻⠿⣿⣿⣿⣿⡿⠿⠿⠛⢻⣿⡇⠀⠀
⠀⣿⣿⠁⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣧⠀⠀
⠀⣿⣿⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀
⠀⣿⣿⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀
⠀⢿⣿⡆⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀
⠀⠸⣿⣧⡀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠃⠀⠀
⠀⠀⠛⢿⣿⣿⣿⣿⣇⠀⠀⠀⠀⣰⣿⣿⣷⣶⣶⣶⣶⠶⠀⠀⢠⣿⣿⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⣿⣿⡇⠀⣽⣿⡏⠁⠀⠀⠀⢸⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⣿⣿⡇⠀⢹⣿⡆⠀⠀⠀⠀⣸⣿⠇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢿⣿⣦⣄⣀⣠⣴⣿⣿⠁⠀⠈⠻⣿⣿⣿⣿⡿⠏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠈⠛⠻⠿⠿⠿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Licensing

About

Romanian version of Leveret by Neeve

Topics

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages