StaticGramBot API

banChatMemberПоддерживается

Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

Особенности StaticGram

until_date normalised (<30 s / >366 d = forever); revoke_messages ignored (supergroups/channels always behave as revoke); owner / foreign admins rejected like api.telegram.org; chat_member + my_chat_member + left_chat_member produced

Параметры

chat_idInteger or Stringобязательный
Unique identifier for the target group or username of the target supergroup or channel in the format @username
user_idIntegerобязательный
Unique identifier of the target user
until_dateIntegerнеобязательный
Date when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
revoke_messagesBooleanнеобязательный
Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.

Пример запроса

curl
curl "https://api.staticgram.top/bot$TOKEN/banChatMember" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 123456789,
    "user_id": 123456789
  }'
aiogram 3
from aiogram import Bot
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.client.telegram import TelegramAPIServer

session = AiohttpSession(api=TelegramAPIServer.from_base("https://api.staticgram.top"))
bot = Bot(TOKEN, session=session)

result = await bot.ban_chat_member(chat_id=123456789, user_id=123456789)
JavaScript
const res = await fetch(`https://api.staticgram.top/bot${TOKEN}/banChatMember`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "chat_id": 123456789,
    "user_id": 123456789
  }),
});
const data = await res.json();

Ответ (True)

JSON
{
  "ok": true,
  "result": true
}

Описания методов и типов взяты из официальной документации Telegram Bot API (Bot API 10.3). Адрес API: https://api.staticgram.top