Методы SDK
Сигнатуры методов pykodaribot 0.5.2. Это справочные записи: каждый метод нужно вызывать с await внутри async-функции. Ошибки API приходят как BotError.
Профиль бота
bot.get_me() -> User
bot.set_my_commands(commands: list[BotCommand]) -> bool
bot.get_my_commands() -> list[BotCommand]
bot.set_my_name(name: str) -> bool
bot.set_my_description(description: str) -> bool
bot.set_my_short_description(short_description: str) -> bool
Сообщения
bot.send_message(chat_id, text, reply_to_message_id=None, reply_markup=None, message_thread_id=None) -> Message
bot.send_photo(chat_id, media, caption=None, reply_to_message_id=None, message_thread_id=None) -> Message
bot.send_video(chat_id, media, caption=None, reply_to_message_id=None, message_thread_id=None) -> Message
bot.send_audio(chat_id, media, caption=None, reply_to_message_id=None, message_thread_id=None) -> Message
bot.send_document(chat_id, media, caption=None, reply_to_message_id=None, message_thread_id=None) -> Message
bot.edit_message_text(chat_id, message_id, text, reply_markup=None) -> Message
bot.delete_message(chat_id, message_id) -> bool
media принимает путь str или Path, bytes, открытый файл и временный файловый объект. send_document сохраняет тип документа, даже если передано изображение.
Обновления
bot.get_updates(offset=0, timeout=20, limit=100) -> list[Update]
bot.answer_callback_query(callback_query_id: str) -> bool
Вебхуки
bot.set_webhook(url, secret_token=None, allowed_updates=None, drop_pending_updates=False) -> bool
bot.delete_webhook(drop_pending_updates=False) -> bool
bot.get_webhook_info() -> WebhookInfo
Настройка и приём событий. Методы SDK покрывают все 52 серверных метода Bot API.
Чаты и участники
bot.get_chat(chat_id) -> Chat
bot.get_chat_member(chat_id, user_id) -> ChatMember
bot.get_chat_member_count(chat_id) -> int
bot.get_chat_administrators(chat_id) -> list[ChatMember]
bot.resolve_user(user_id) -> dict
bot.get_or_create_chat(student_id, id_city=None) -> dict
Топики
bot.get_forum_topics(chat_id) -> list[ForumTopic]
bot.get_forum_topic(chat_id, message_thread_id) -> ForumTopic
bot.create_forum_topic(chat_id, name, icon_color=None, icon_emoji=None) -> ForumTopic
bot.edit_forum_topic(chat_id, message_thread_id, name=None, icon_color=None, icon_emoji=None) -> bool
bot.close_forum_topic(chat_id, message_thread_id) -> bool
bot.reopen_forum_topic(chat_id, message_thread_id) -> bool
bot.delete_forum_topic(chat_id, message_thread_id) -> bool
Параметр message_thread_id поддерживается отправкой текста и медиа. unpin_message(chat_id, message_id) снимает одно закрепление, вызов без message_id снимает все.
Настройки чата
bot.set_chat_title(chat_id, title) -> bool
bot.set_chat_description(chat_id, description) -> bool
bot.set_chat_photo(chat_id, media) -> bool
bot.delete_chat_photo(chat_id) -> bool
bot.set_chat_permissions(chat_id, permissions: ChatPermissions | dict) -> bool
bot.set_chat_slow_mode(chat_id, seconds: int) -> bool
Модерация
bot.ban_chat_member(chat_id, user_id, reason=None) -> bool
bot.unban_chat_member(chat_id, user_id) -> bool
bot.kick_chat_member(chat_id, user_id) -> bool
bot.promote_chat_member(chat_id, user_id, permissions, custom_title=None) -> bool
bot.demote_chat_member(chat_id, user_id) -> bool
bot.set_chat_administrator_custom_title(chat_id, user_id, custom_title) -> bool
Закрепления и ссылки
bot.pin_message(chat_id, message_id) -> bool
bot.unpin_message(chat_id, message_id=None) -> bool
bot.export_chat_invite_link(chat_id) -> str
bot.create_chat_invite_link(chat_id, name=None, expire_date=None, member_limit=None) -> ChatInviteLink
bot.revoke_chat_invite_link(chat_id, invite_link) -> bool
Журнал
bot.get_chat_admin_log(chat_id, limit=50, offset=0) -> list[ChatAdminLogEntry]
Служебное
bot.close()
async with Bot(token) as bot: ...
Эти методы реализованы в Bot API. Пересылка проверяет доступ к исходнику и права отправки в целевом чате. Реакции поступают в message_reaction через polling и вебхуки.
Пересылка и реакции
bot.forward_message(chat_id, from_chat_id, message_id, message_thread_id=None) -> Message
bot.set_message_reaction(chat_id, message_id, emoji) -> bool
bot.get_pinned_messages(chat_id) -> list[PinnedMessage]
Повтор той же реакции снимает её, другой эмодзи заменяет. msg.forward_to(chat_id, message_thread_id=None) пересылает текущее сообщение. bot.unpin_message(chat_id, message_id) снимает одно закрепление, без ID снимает все.