Want to write your own Kobun commands? Here's a quick rundown.
The easiest way to get started using Kobun, is through the online editor. You’ll need to login with your Discord account if you use the editor for the first time and register an username, make sure that it’s all lowercase or else it won’t work.
After registration you should see a screen similar to this:
Now you’re ready to get started.
Creating your first script is as easy as picking a name in lowercase for your script and clicking . If you script was successfully created, you should see the editor change to the default script as seen here:
You can now already run this script if you copy the command shown in line 3. It will always have the format
@Kobun run followed by your
/scriptname. Run that command in a Discord server that you are the administrator of and somewhere Kobun can read and write messages. You should now see Kobun respond like this:
If Kobun doesn’t respond, he might not be able to read or write messages, in this case you should check the Discord channel permissions or give Kobun administrative rights.
As you can see from the response, Kobun will show anything that you’ve written to
stdout, via functions like
Now try to change that response to anything you like and see if Kobun responds differently, don’t forget to save your script before calling it again using the button in the top right corner.
If you’ve played around a bit with your script, you’ll likely get tired of pasting the long command all the time. That’s where linking your script to a custom command comes in handy. To do this however, you first have to set your script to Unlisted (private) or Published (public) in the top right dropdown menu and save it. Afterwards you can link your script by sending
@Kobun link <command> <username>/<scriptname>, replacing
<command> with the command you want and
<scriptname> with your chosen user name and script name.
Now try linking your first script to
.test for easy access in the next steps, it should look something like this:
If Kobun says script not found, check the spelling and see if it’s saved as unlisted or published.
Making static commands can be fine for some applications but sometimes you need some user input. Getting this input is as easy as calling
sys.stdin.read(). With this we can create a simple echo script that shows us the user input, just modify your script to look like this:
#!/usr/bin/python3 import sys inp = sys.stdin.read() print(inp)
If you now send
.test Hello! Kobun should respond with:
If Kobun doesn’t respond make sure you have linked your script to
.test as seen in the previous step.
You always need to separate your chosen command and input with space, this space will not be part of the input that gets read.
Kobun provides each user with a limited amount of private storage located at
/mnt/private, where you can store anything you’d like.
To access this storage outside of your scripts you need to set a password first, by clicking next to your user name in the editor and scroll down to the password fields. After you’ve set your password you can log onto
https://storage.kobun.company via any WebDAV client like WinSCP using your user name and chosen password.
Kobun provides easy access to some Discord services as seen in the documentation. To make a call to these services you first have to import the library
k4 like this:
import sys sys.path.insert(0, "/usr/lib/k4") import k4
You can now get the client object with
client = k4.Client() where the Services are located. Examples for
client.NetworkInfo can be found in the script kornclown/services.
Demonstrates: Linking an image with comments explaining step-by-step.
Demonstrates: Uploading an image with comments explaining step-by-step.
Demonstrates: Parsing input, random numbers, sending output.
Demonstrates: Parsing a tagged user, mentioning a user in reply.
Demonstrates: Multiple commands, simple point based database for “reputation” system, tagging users, leaderboard.
Demonstrates: Lottery system, implementing admin-only commands.
Demonstrates: Sending requests to external services (Google API for time) and loading results .
Demonstrates: Sending requests to external services (Google API for images) and showing the results.
Demonstrates: Parsing input as tokens (each word), shitty memes.
Demonstrates: How to use
Output.SetFormat(format="rich") for custom Discord rich embeds.