infrabot-io.github.io

Documentation

Documentation for infrabot


plugin.json file


plugin.json file is a main definition file of the plugin, where are all parameters of the plugin located.

Minimal file structure is shown below:

			        		
{
    "command_starts_with": "/sayhello",
    "command_data_id": [
        2
    ],
    "command_execute_file": "sayhello.ps1",
    "command_help_manual": "Says hello. Write `/sayhello John` to say hello",
    "command_help_short": "Says hello",
    "command_author": "infrabot.io",
    "command_version": "1.0.0.0",
    "command_website": "https://infrabot-io.github.io",
    "command_default_error": "Saying hello to `{DATA}` was not succeded! Unexpected error! Result was: {RESULT}",
    "command_execute_type": 3,
    "command_allowed_users_id": [],
    "command_show_in_get_commands_list": true,
    "command_execute_results": [
        {
            "result_value": "0",
            "result_output": "User `{DATA}` was not disabled! User name was not sent as an argument to script",
            "result_checktype": 1
        }
    ]
}
							
			        	

In the table below shown parameters and their descriptions and how to properly to configure them. You can use Plugin Editor to easily manipulate with such type files.

Parameter Type Description
command_starts_with String If command in chat starts with the specified value, then command will be executed. This is NOT case sensitive! It is recommended to begin all commands with / character.
command_data_id Array of Integers Defines which parts of your command contains data which will be sent to Script or your Executable. First number is 1 (not 0 !!).
Examples:
  • If your command is like /restart fridge01, then number 1 specified here will be equal to "restart" and 2 will be equal to "fridge01". So if you want to pass only "fridge01" to your script or executable, you have to set only one value here which will be 2.
  • If your command is like /restart fridge01 cluster01, then number 1 specified here will be equal to "restart" and 2 will be equal to "fridge01" and 3 will be equal to "cluster01". So if you want to pass 2 parameters "fridge01" and "cluster01" to your script or executable, you have to set values here which will be 2, 3.
  • If your command is like /restart fridge01 cluster01, then number 1 specified here will be equal to "restart" and 2 will be equal to "fridge01" and 3 will be equal to "cluster01". So if you want to pass 2 parameters "fridge01" and "cluster01" to your script or executable but in a different order, you have to set values according to your order and it will be like 3, 2.
  • There may be any numbers of arguments of your command. It is essential to determine right position and order!
command_execute_file String Path to your Script or Executable file (depends on command_execute_type parameter). If script or executable is in plugin`s root directory just specifiy file name. If it is in a directory specify path like some_folder\script.ps1
command_help_manual String Full help manual of your command if you send to Bot /your_command ? command.
command_help_short String Short description of your command which will be shown near your command when /getcommands requested.
command_author String Name of the Author of the plugin.
command_version String Version of the plugin.
command_website String Web site page address of the author or plugin
command_default_error String Default error for your command if none of the cases specified in command_execute_results matches. {DATA} - specified in this string will be replaced with all arguments which have been sent to command. {RESULT} - will be replaced with output received from your script or executable. Example: Server with name `{DATA}` was not restarted! Unexpected error is : {RESULT}!
command_execute_type Integer Specifies command execute type (1,2,3,4):
  • 1 - My Custom Application with custom result answers with sending arguments to it
  • 2 - My Custom Application with ignoring all output result and forwarding it directly to you without sending arguments to it
  • 3 - PowerShell with custom result answers with sending arguments to script
  • 4 - PowerShell with ignoring result all output and forwarding it directly to you without sending arguments to script
command_allowed_users_id Array of Integers List of Telegram Users` ids from whom Bot can accept this command and execute it. This parameter is checked before command_allowed_chats_id.
command_allowed_chats_id Array of Integers List of Telegram Group Chats or private Chat with Bot ids from where Bot can accept accept this command and execute it. This parameter is checked before command_allowed_users_id.
command_show_in_get_commands_list Boolean Specifies if will show information about this command in /getcommands list. By using this parameter you can hide available commands from other members of your team.
command_execute_results Array of Results Specifies list of specific answers to results to which Bot should send answer.
Example:
  • Imagine that you have command /restart, which accepts SERVER_NAME as second parameter. So full command will be like /restart server01. Command command_execute_type has been set to 3 so, you will have some PowerShell script which restarts specified server using accepted argument as server name. You decided to return 1 from your script if server restart succeeded, and 0 if not. So if you want to show success message when 1 returned, or error message when 0 returned you will have to configure command_execute_results for all return values.
  • If "4 - PowerShell with ignoring result all output and forwarding it directly to you" or "2 - My Custom Application with ignoring all output result and forwarding it directly to you" have been specified, specifying command_execute_type is useless, because in the specified cases all the result from script or executable will be returned directly to chat.


Execute results Parameters

In the table below shown Execute Results parameters` descriptions and how to properly to configure them. You can use GUI tool to configure Execute Results.

Parameter Type Description
result_value String Expected Result value from Script or Executable
result_output String What to show if result received from Script or Executable matches result_value value. {DATA} - specified in this string will be replaced with all arguments which have been sent to command. {RESULT} - will be replaced with output received from your script or executable.
result_checktype Integer Determines how to match result got from Script or Executable with result_value parameter. Accepted values are 1,2,3,4
  • 1 - if result from Script or Executable Equals to result_value
  • 2 - if result from Script or Executable Contains result_value
  • 3 - if result from Script or Executable Starts With result_value
  • 4 - if result from Script or Executable Ends With result_value