Skip to main content

Python library for https://karboai.com

Project description

KarboAI

Python library for KarboAI bot development.

Install

pip install karboai

Usage

import asyncio
from karboai import KarboAI, Router, bold

karbo = KarboAI(token="your-token", id="your-bot-id", enable_logging=True)
router = Router()

@router.command("/start")
async def start(ctx):
    await karbo.text(ctx.message.chat_id, bold("Welcome!"))

@router.on("message")
async def echo(ctx):
    await karbo.text(ctx.message.chat_id, ctx.message.content)

async def main():
    karbo.bind(router)
    await karbo.attach()
    try:
        await asyncio.Event().wait()
    finally:
        await karbo.close()

asyncio.run(main())

API

Method Description
me() Bot info
text(chat_id, content, reply_message_id?) Send text
image(chat_id, images, reply_message_id?) Send images
upload(buffer, file_name?) Upload image, returns URL
message(chat_id, message_id) Get message
members(chat_id, limit?, offset?) Chat members
user(user_id) User info
leave(chat_id) Leave chat
kick(chat_id, user_id) Kick user
attach(callback?) Connect to WebSocket
bind(*routers) Bind routers

Events

message, join, leave, voiceStart, voiceEnd, sticker

Text formatting

bold(), italic(), centralize(), code(), strikethrough(), underline(), hyperlink(text, url)

Error handling

from karboai import KarboError

try:
    await karbo.me()
except KarboError as e:
    print(e.status_code, e.name, e)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

karboai-1.0.9.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

karboai-1.0.9-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file karboai-1.0.9.tar.gz.

File metadata

  • Download URL: karboai-1.0.9.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for karboai-1.0.9.tar.gz
Algorithm Hash digest
SHA256 659071ab84f87d17de55c6782d350f20c662c9bb808707f2a58f355660a94f1f
MD5 4a7370e022e6917d5b0b110e72cb60ce
BLAKE2b-256 f1819a84c99ad75cf34b592dc3680400b8c9d76a8490f7cb30bce843c7f33c82

See more details on using hashes here.

File details

Details for the file karboai-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: karboai-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for karboai-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d56473ada647e5d6ecfbfb399e31b88e94958bc498e87a40042e0b93a3e6a419
MD5 bde6b847aed82c09f5dd3d17c58ba756
BLAKE2b-256 7856bb2d11068b69a6554bcf58237fbddfd91e87fedb0d3b9c70779c30ff34b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page