- Go to API references page
- Quick start with Kagami
Example code snippets
// Create a bot instance
var bot = BotFather.Create(config, device, keystore);
{
// Handle the captcha
bot.OnCaptcha += (bot, e) =>
{
if(e.Type == CaptchaType.Slider)
{
Console.WriteLine(e.SliderUrl);
bot.SubmitSliderTicket(Console.ReadLine());
}
else if(e.Type == CaptchaType.Sms)
{
Console.WriteLine(e.Phone);
bot.SubmitSmsCode(Console.ReadLine());
}
};
// Print the log
bot.OnLog += (_, e)
=> Console.WriteLine(e.EventMessage);
// Handle group messages
bot.OnGroupMessage += (_, e)
=> Console.WriteLine(e.Message);
// Handle friend messages
bot.OnFriendMessage += (_, e)
=> Console.WriteLine(e.Message);
// ... More handlers
}
// Do login
if(!await bot.Login())
{
Console.WriteLine("Login failed");
return;
}
Console.WriteLine("We got online!");
Messages | Support | Operations | Support | Events | Support |
---|---|---|---|---|---|
Images | π’ | Poke | π’ | Captcha | π’ |
Text / At | π’ | Recall | π‘[2] | BotOnline | π’ |
Records | π’ | Leave Group | π’ | BotOffline | π’ |
QFace | π’ | Special Title | π’ | Message | π‘[3] |
Json | π’ | Kick Member | π’ | Poke | π’ |
Xml | π’ | Mute Member | π’ | MessageRecall | π’ |
Forward | π‘[1] | Set Admin | π’ | GroupMemberDecrease | π’ |
Video | π΄ | Friend Request | π’ | GroupMemberIncrease | π’ |
Flash Image | π’ | Group Request | π’ | GroupPromoteAdmin | π’ |
Reply | π’ | Voice Call | π΄ | GroupInvite | π’ |
File | π΄ | Csrf Token | π’ | GroupRequestJoin | π’ |
Cookies | π΄ | FriendRequest | π’ | ||
FriendTyping | π’ | ||||
FriendVoiceCall | π΄ |
[1]: Not supported to forward messages between group and friend.
[2]: Not supported to recall messages sent from the bot.
[3]: Not supported temp messages.
Special thanks to JetBrains offers free open-source licenses for us!
Licensed in GNU GPLv3 with β€.