🌙

Все методы Bot

Все методы класса Bot

Полный перечень сигнатур pykodaribot 0.3.0. Каждый метод — корутина, ошибки приходят как BotError.

Профиль бота

await bot.get_me() -> User
await bot.set_my_commands(commands: list[BotCommand]) -> bool
await bot.get_my_commands() -> list[BotCommand]
await bot.set_my_name(name: str) -> bool
await bot.set_my_description(description: str) -> bool
await bot.set_my_short_description(short_description: str) -> bool

Сообщения

await bot.send_message(chat_id, text, reply_to_message_id=None, reply_markup=None) -> Message
await bot.send_photo(chat_id, media, caption=None, reply_to_message_id=None) -> Message
await bot.send_video(chat_id, media, caption=None, reply_to_message_id=None) -> Message
await bot.send_audio(chat_id, media, caption=None, reply_to_message_id=None) -> Message
await bot.send_document(chat_id, media, caption=None, reply_to_message_id=None) -> Message
await bot.edit_message_text(chat_id, message_id, text, reply_markup=None) -> Message
await bot.delete_message(chat_id, message_id) -> bool

media принимает str, Path, bytes или открытый файл.

Обновления

await bot.get_updates(offset=0, timeout=20, limit=100) -> list[Update]
await bot.answer_callback_query(callback_query_id: str) -> bool

Чаты и участники

await bot.get_chat(chat_id) -> Chat
await bot.get_chat_member(chat_id, user_id) -> ChatMember
await bot.get_chat_member_count(chat_id) -> int
await bot.get_chat_administrators(chat_id) -> list[ChatMember]
await bot.resolve_user(user_id) -> dict
await bot.get_or_create_chat(student_id, id_city=None) -> dict

Настройки чата

await bot.set_chat_title(chat_id, title) -> bool
await bot.set_chat_description(chat_id, description) -> bool
await bot.set_chat_photo(chat_id, media) -> bool
await bot.delete_chat_photo(chat_id) -> bool
await bot.set_chat_permissions(chat_id, permissions: ChatPermissions | dict) -> bool
await bot.set_chat_slow_mode(chat_id, seconds: int) -> bool

Модерация

await bot.ban_chat_member(chat_id, user_id, reason=None) -> bool
await bot.unban_chat_member(chat_id, user_id) -> bool
await bot.kick_chat_member(chat_id, user_id) -> bool
await bot.promote_chat_member(chat_id, user_id, permissions, custom_title=None) -> bool
await bot.demote_chat_member(chat_id, user_id) -> bool
await bot.set_chat_administrator_custom_title(chat_id, user_id, custom_title) -> bool

Закрепления и ссылки

await bot.pin_message(chat_id, message_id) -> bool
await bot.unpin_message(chat_id) -> bool
await bot.export_chat_invite_link(chat_id) -> str
await bot.create_chat_invite_link(chat_id, name=None, expire_date=None, member_limit=None) -> ChatInviteLink
await bot.revoke_chat_invite_link(chat_id, invite_link) -> bool

Журнал

await bot.get_chat_admin_log(chat_id, limit=50, offset=0) -> list[ChatAdminLogEntry]

Служебное

await bot.close()          # закрыть HTTP-сессию
async with Bot(token) as bot: ...

Не работают на сервере

forward_message, set_message_reaction, get_pinned_messages — эндпоинтов нет, вызов даёт BotError(404). Подробнее — на странице Установка.

18 просмотров