Custom commands

From StealthBot Wiki Backup
Jump to: navigation, search

The internal custom command system has been removed in v2.7 in favor of the more powerful scripting system. The Custom Command Xystem (CCX) is a script, which replaces the old system and provides more features as well as lots of new functions. It is an intelligent flexible parsing system/custom command system. CCX can allow more advanced users to create complex dynamic commands quickly without having to create separate scripts, while still keeping the simplicity of the old custom command system.

Snap is currently working on the conversion from plugin to script. For now, you can download the the current version of the CCX script here: http://www.stealthbot.net/forum/index.php?showtopic=806 (Note: You need an account for the forums to view the topic and download the attachment.)

Installation

Quick Guide

  1. Go to the link above.
  2. Save the attachment to your scripts folder.
  3. Reload your scripts.

Detailed Instructions

1. Go to the link above.

  • If you get the following error message, you have to log in:
[#103139] You do not have permission to view this forum.
  • If you do not have an account yet, you must create one.

2. Save the attachment to your scripts folder.

  • If the script is being opened in your browser, either save the page or go back to the topic and right click on the attachment and then choose "Save link/target as..." (the exact text might differ depending on your browser).
  • Either download the file directly to the scripts folder or download it to a temporary folder and move it to the scripts folder afterwards.
  • You have to put the file in the scripts folder of your current profile (Scripting > Open Script Folder). Do not put it in the Default/scripts folder of your StealthBot installation path as this will have no effect on your current profile.

3. Reload your scripts.

  • Either use the menu Scripting > Reload Scripts or the respective hot key CTRL + R.
  • You might get a pop-up informing you that CCX has been updated and asking if you want to see the changelog.
  • If you see the following message, the script was installed successfully and you are able to add custom commands now:
CCX: Custom Command Xystem Loaded with -1 CC's

General Features

Overview

CommandDescriptionSyntaxExample
addccAdds a custom command.<trigger>addcc <command name> <access/flags> <command response>/addcc example 10/M This is an example!
appendccAppends a custom command.<trigger>appendcc <command name> <additional text>/appendcc example Or is it a test?
setccChanges the required access/flags of a custom command.<trigger>setcc <command name> <new access/flags>/setcc example 20
editccChanges the output of a custom command.<trigger>editcc <command name> <new command response>/editcc example This is a test!
renameccRenames a custom command.<trigger>renamecc <command name> <new command name>/renamecc example test
listccShows a list of available custom commands.<trigger>listcc/listcc
findccFinds available custom commands.<trigger>findcc <search string>/findcc te
showccShows the code of a custom command.<trigger>showcc <command name>/showcc test
delccDeletes a custom command.<trigger>delcc <command name>/delcc test
sortccSorts the list of custom commands (console only)./sortcc/sortcc
Other (more advanced) commands
testccTests the code of a custom command.<trigger>testcc <CCX code to test>/testcc 1& 2& 3
reloadccReloads custom commands from the text file.<trigger>reloadcc/reloadcc
clipccCopies the code of a custom command to the bot owner's clipboard.<trigger>clipcc <command name>/clipcc test
rfunctionsShows a list of registered functions.<trigger>rfunctions/rfunctions


Note: A more detailed documentation can be found at http://snapnjacks.com/CCXDoc.php. Visit this site for more complex examples and an overview of the new functions provided by CCX.

Adding commands

To add custom commands to your bot you have to use the addcc command. You can also use the alias addcmd (like the old version). The command cmdadd (also from the old version) will not work though.

The syntax for adding commands is as follows:

<trigger>addcc <name> <access/flags> <command response>

In the old version the order of the command name and the required access were interchanged. Except for this minor change the commands behave exactly the same. Remember that, when you try to add commands from inside the bot, you have to use the bot's internal trigger "/".

A new feature of CCX is that you can assign flags to custom commands now as well. You have the possibility to assign flags only, access only or both combined.

You are able to use arguments, which represent parameters passed to the command. There are unlimited arguments, number them accordingly. Argument 1 would be %1, Argument 2 is %2 and so on. The code %rest stands for all remaining arguments. The code %0 (also %user in CCX) represents the person issuing the command.

You can define another line by using "& " in your command. Please note that there must be a space after the "&".

Example 1
Command

/addcc argtest 50 Argument 1: %1& Argument 2: %2& Argument 3: %3

Usage

<Stealth> .argtest First Second Third

Output

<StealthBot> Argument 1: First
<StealthBot> Argument 2: Second
<StealthBot> Argument 3: Third

Example 2
Command

/addcc serve 50/M /me pours a refreshing glass of %rest& /me hands the glass to %1, compliments of %0 :)

Usage

<Stealth> .serve Mad Pepsi One

Output

<StealthBot pours a refreshing glass of Pepsi One>
<StealthBot hands the glass to Mad, compliments of Stealth :)>

Meaning

  • The command is accessible for users with 50+ access or flags M.
  • %0 is the user who executed the command: Stealth.
  • %1 is the first argument, in this case the person being served: Mad.
  • %rest is the rest of the message, after the highest-numbered argument you used in making the custom command. In this case what you want to serve to them (argument 2 and 3 combined): Pepsi One.


You can use Battle.net commands in custom commands (as shown with /me in example 2). Simply put the code in front of the command. For example, if you want to whisper the command response to the person who issued the command, you have to add /w %0 (or /w %user respectively) in front of the command response. Note that built-in commands (like shitlist, safeadd, etc.) do not work.

Example 3
Command

/addcc rules 50 /w %0 1) You do not talk about Fight Club.& /w %0 2) You DO NOT talk about Fight Club!& /w %0 ...

Usage

<Stealth> .rules

Output

<To Stealth> You do not talk about Fight Club.
<To Stealth> You DO NOT talk about Fight Club!
<To Stealth> ...

When you add a command whose name is already taken, the bot will respond accordingly and add the command with a different name (e.g. "rules1" if "rules" is already taken).

Editing commands

You can change the output of an existing custom command using the editcc command. Example:

/editcc rules There are no rules yet.

If you just want to add additional text to the end of an existing command, you can use the command appendcc. Example:

/appendcc rules Stay tuned for updates!

If you want to change the required access or flags for a custom command, you have to use the setcc command. Example:

/setcc rules 20

With the showcc command you can look at the code of a custom command. It will show what you typed to create the command. Example:

/showcc rules

You can also rename custom commands using the renamecc command. Example:

/renamecc rules1 newrules


All custom commands are saved in the ccx_CC.txt file, which is located in the plugins folder of your bot's profile. Theoretically you could manually edit the custom commands in the file. However, this is not recommended. You are supposed to use the respective CCX commands.

Deleting commands

To delete a custom command use the delcc command. Alternatively you can use its alias delcmd. Example:

/delcc newrules

Listing commands

Users can use the listcc command to list all custom commands they have access to. Alternatively they can use the aliases cclist and cmdlist (as known from the old system). The commands are listed in the order they were created. The bot owner can use the sortcc command from inside the bot to sort them alphabetically.

If you are looking for a certain command, you can use the findcc command to search for it. Example:

/findcc rule

This will list all commands that contain the phrase "rule" and that you have access to.

Upgrade from StealthBot v2.6R3

CCX can automatically convert your old custom commands from your StealthBot v2.6R3 to the new format. To do so, simply put the commands.dat file from your old StealthBot folder into the profile folder of your StealthBot v2.7+ with CCX installed. You have to reload your scripts if you did it while the bot was opened.

Issues

If you have problems installing the CCX script or if you get any errors while installing or using CCX, please make a topic in the Scripting forum.