README.md

April 7, 2023 · View on GitHub

Kagami

C# License

A demo bot that can lead you to create your
own bot with Konata.Core quickly.

Commands

CommandDescription
/statusPrint the status such as build, version, memory usage..etc
/dbg <code>Enable the debug output of your REPL expression
any user-defined command start with '/'/

Triggers

TriggerExampleDescription
Githubhttps://github.com/KonataDev/KagamiParse the GitHub repo image.

REPL Feature

Kagami offers a modern C# (Currently C# 11) interactive terminal,
type any valid C# expressions in the group then run the code.

Example

Benefited from the REPL feature, Kagami supports user-defined commands.
You can define your command like the example below:

// define a command named 'example'
// it has 3 argument inputs a, b and c.
var example = string (int a, bool b, string c)
    => $"a is {a}, b is {b}, c is \"{c}\"";

After defined the command, you can send '/example 1 false Hello' in your group,
then Kagami will prints a "a is 1, b is False, c is Hello" string.

Script Presets

The script presets are stored in 'scripts' directory,
write down your code and save with '.cs' suffix name here and restart Kagami to take effect.

The normal output while Kagami starting:

[ *** ] REPL compiling script => scripts/ic.cs
[ *** ] REPL compiling script => scripts/help.cs
[ *** ] REPL compiling script => scripts/echo.cs
[ *** ] REPL compiling script => scripts/ping.cs
[ *** ] REPL compiling script => scripts/mute.cs
[ *** ] REPL scripts load finished.

See more examples in ScriptExample.

Sandbox Environment

Sandbox environment are defined in ReplEnvironment.cs,
Contains fields, classes and methods as the script runtime context.

NameDescription
BotThe Kagami bot instance, full access in REPL
CurrentGroupCurrent group uin
CurrentMemberCurrent member uin
JSONThe dynamic JSON parser, use JSON.Parse()
PrintPrint a string
CanIDoBot do something with a probability
WgetHttp request
RandomShared random

Known Issues

  • Sometimes offline.
  • Sometimes stuck on some internal tasks.
  • Stuck while the bot exit.
  • Bot can trigger the command which sends by itself. (LMFAO)

License

Licensed in GNU GPLv3 with ❤.