How to use SCAPI
import
statement:
pip
(pip install pyyaml
)Flag | Erklärung |
---|---|
username | The user name of the bot |
token | The token (password) of the bot |
host | Remote server where the bot should connect to |
port | The port of the remote server |
enable_user_input | Activate message input within the console (Also available as a flag) |
print_recv_msg | Output received messages to the bot logs (console) (Also available as a flag) |
Flag | Explanation |
---|---|
print_recv_msg | Output received messages to the bot logs (console) |
enable_user_input | Activate message input within the console |
log_msg | Change the format of the log messages |
@commands
Module)Commands
.
This part explains how to write a command using the command moduleFor the other method, you can check out this documentation sectionCode | Explanation |
---|---|
name | Stands for the command name, which is then added to the registry. You can then call up the command using the prefix and then the name (e.g. !test ) |
arg_count | Number of arguments that the command accepts and requires as a minimum. A lower number can also be specified and more arguments can still be accepted |
required_permissions | Required authorization for the command. A value of the Scapi class must be transferred here. Scapi.Bot.PermissionLevel.CUSTOM for the custom list that you have defined here |
username | The user name of the user who executed the command |
args | The arguments that were passed when the command was executed. Is saved in a list (["first", "second", "third"] ) |
send_message(...) | Function to send a message |
on_message
events to accept & process pure messages.
on_ready
.
This event is called when you start the bot. You only have to pass the on_ready
function as an argument to the Bot.run()
function.
An on_ready
event can look like this:
on_message
events to accept and process pure messages.
This method is called Original
Flag | Erklärung |
---|---|
username | The user name of the bot |
token | The token (password) of the bot |
host | Remote server where the bot should connect to |
prefix | The prefix of the bot to which it should listen (e.g. !help ) |
port | The port of the remote server |
enable_user_input | Activate message input within the console (Also available as a flag) |
print_recv_msg | Output received messages to the bot logs (console) (Also available as a flag) |
json | Activates or deactivates the compatibility mode for old servers |
json
is only available since Scapi v0.12.1prefix
is only available since Scapi v0.13.1b2Flag | Explanation |
---|---|
print_recv_msg | Output received messages to the bot logs (console) |
enable_user_input | Activate message input within the console |
log_msg | Change the format of the log messages |
ignore_capitalization | Activates or deactivates the ignoring of capital letters for the on_message method (only available from Scapi v0.13) |
Commands
.
This part explains how to write a command using the command module.The older method is deprecated since Scapi v0.12.1 and should therefore no longer be usedCode | Explanation |
---|---|
name | Stands for the command name, which is then added to the registry. You can then call up the command using the prefix and then the name (e.g. !test ) |
arg_count | Number of arguments that the command accepts and requires as a minimum. A lower number can also be specified and more arguments can still be accepted |
required_permissions | Required authorization for the command. A value of the Scapi class must be transferred here. Scapi.Bot.PermissionLevel.CUSTOM for the custom list that you have defined here |
username | The user name of the user who executed the command |
args | The arguments that were passed when the command was executed. Is saved in a list (["first", "second", "third"] ) |
send_message(...) | Function to send a message |
Direct messages
Leave the chat
@on_message
method (since v0.13). If functionality is missing, please open an Issue on our GitHubIf you still want to use this method for whatever reason, please have a look at this part of the documentation@on_message
method is more restricted.The following functions could not be implemented so far (but could appear in a different form in the future):on_ready
function as an argument to the Bot.run()
function.
An on_ready
event can look like this:
@json-communication
/@main
) here.
The following piece of code shows you how to make a simple bot with Scapi (stbmv2)
json
to False
will enable the compatibility mode. Note that this is not yet fully developed