Official Python SDK for KarboAI Bot API
Project description
karbo
Official Python SDK for the KarboAI Bot API.
🇬🇧 English
📚 Full documentation
The complete, always up-to-date reference lives in two places:
- Source & changelog — github.com/KirbyRedius/karbo
- API & guides — docs.karboai.com
The snippets below are a quick taste. Refer to the docs for every endpoint, every field, error codes, rate limits, and the full inline- buttons reference.
Install
pip install -U karbo
Hello bot
import asyncio
import karbo
BOT_TOKEN = "your-bot-token"
async def main():
bot = karbo.KarboBot(BOT_TOKEN)
ws = karbo.KarboBotWS(BOT_TOKEN)
me = await bot.get_me()
print(f"Bot: {me.name} ({me.bot_id})")
@ws.on_message
async def on_message(message: karbo.Message):
if message.user_id == me.bot_id:
return
await bot.send_message(message.chat_id, f"Echo: {message.content}")
await ws.run_forever()
asyncio.run(main())
Inline buttons
Attach a List[List[Button]] to any message. Rows are the outer list,
columns within a row are the inner list. Up to 10 rows × 5 columns,
30 buttons total per message.
import karbo as k
await bot.send_message(
chat_id,
"Confirm payment?",
buttons=[
[
k.Button(
"pay", "Pay",
style=k.ButtonStyle(color="#22C55E", shape="capsule"),
animations=[k.Pulse(speed_ms=900)],
particles=k.SparkParticles(color="#FFD54F"),
),
k.Button(
"cancel", "Cancel",
style=k.ButtonStyle(color="#1F2937", shape="capsule"),
),
],
],
)
@ws.on_button_pressed
async def on_press(press: k.ButtonPress):
if press.button_id == "pay":
await bot.send_message(
press.chat_id, "Paid!", reply_to=press.message_id,
)
Available pieces (see docs.karboai.com for the full reference):
- Styles —
ButtonStyle,Gradient(horizontal / vertical / diagonal / radial), shapesrectangle/circle/capsule. - Interactions —
TapInteraction(default) orSwipeInteraction(text, fill_color)(drag-to-confirm). - Animations —
Pulse,Neon,Glitch,Outline(up to 4 per button, no duplicate kinds). - Particles —
SparkParticles,ConfettiParticles,HeartParticles,PixelParticles,SmokeParticles(one per button,color+intensity1-5).
Models & errors
BotInfo, Message, SentMessage, User, Member, Author,
AvatarFrame, MessageReaction, ButtonPress.
Exceptions all inherit from karbo.KarboError:
AuthenticationError, ForbiddenError, NotFoundError,
ValidationError, RateLimitError, APIError.
License
MIT
🇷🇺 Русский
📚 Полная документация
Актуальный и полный референс живёт в двух местах:
- Исходники и changelog — github.com/KirbyRedius/karbo
- API и гайды — docs.karboai.com
Здесь — только короткие примеры для старта. За полным списком эндпоинтов, описанием полей, кодами ошибок, лимитами и описанием inline-кнопок — иди в доку.
Установка
pip install -U karbo
Минимальный бот
import asyncio
import karbo
BOT_TOKEN = "your-bot-token"
async def main():
bot = karbo.KarboBot(BOT_TOKEN)
ws = karbo.KarboBotWS(BOT_TOKEN)
me = await bot.get_me()
print(f"Bot: {me.name} ({me.bot_id})")
@ws.on_message
async def on_message(message: karbo.Message):
if message.user_id == me.bot_id:
return
await bot.send_message(message.chat_id, f"Echo: {message.content}")
await ws.run_forever()
asyncio.run(main())
Inline-кнопки
Прикрепляются к сообщению как List[List[Button]]: внешний список —
строки, внутренний — кнопки в строке. До 10 строк × 5 колонок,
30 кнопок всего на одно сообщение.
import karbo as k
await bot.send_message(
chat_id,
"Подтвердить оплату?",
buttons=[
[
k.Button(
"pay", "Оплатить",
style=k.ButtonStyle(color="#22C55E", shape="capsule"),
animations=[k.Pulse(speed_ms=900)],
particles=k.SparkParticles(color="#FFD54F"),
),
k.Button(
"cancel", "Отмена",
style=k.ButtonStyle(color="#1F2937", shape="capsule"),
),
],
],
)
@ws.on_button_pressed
async def on_press(press: k.ButtonPress):
if press.button_id == "pay":
await bot.send_message(
press.chat_id, "Оплачено!", reply_to=press.message_id,
)
Доступные блоки (полный референс — на docs.karboai.com):
- Стили —
ButtonStyle,Gradient(horizontal/vertical/diagonal/radial), формыrectangle/circle/capsule. - Взаимодействия —
TapInteraction(по умолчанию) илиSwipeInteraction(text, fill_color)(свайп-подтверждение). - Анимации —
Pulse,Neon,Glitch,Outline(до 4 на кнопку, без дублей по kind). - Партиклы —
SparkParticles,ConfettiParticles,HeartParticles,PixelParticles,SmokeParticles(одна конфигурация на кнопку, параметры —colorиintensity1-5).
Модели и ошибки
BotInfo, Message, SentMessage, User, Member, Author,
AvatarFrame, MessageReaction, ButtonPress.
Все исключения наследуют от karbo.KarboError:
AuthenticationError, ForbiddenError, NotFoundError,
ValidationError, RateLimitError, APIError.
Лицензия
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file karbo-0.8.1.tar.gz.
File metadata
- Download URL: karbo-0.8.1.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8831314de82b6b6ee97d0dd92cbd039d51dcbc4f90e99d47da4d9317eab7608f
|
|
| MD5 |
78e95bde6c73bb84a1d0300181bd11f6
|
|
| BLAKE2b-256 |
8a91145da8140c9286405b82474cd03f9b5866ff39ff3ce0576c398e59996e3a
|
File details
Details for the file karbo-0.8.1-py3-none-any.whl.
File metadata
- Download URL: karbo-0.8.1-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e9b623dfa1ade59c05fb8481d8f0394975ee9f1492e1ded59e61e5cb08e36ec
|
|
| MD5 |
f7cb1fe14171b58ca9027572a5e2d0a7
|
|
| BLAKE2b-256 |
af14442b99a919c52356138c27f901e2de512cc857d771d8bff9040b1db71154
|