ZaminDocs

Guruh boshqaruvi

unbanChatMember

Banni olib tashlaydi (odam yana qo'shila oladi).

POSThttps://api.zamin.app/bot<TOKEN>/unbanChatMember

GET ham ishlaydi. Parametrlar: query, JSON, form yoki multipart β€” batafsil.

Ban qilingan odamning taqiqini olib tashlaydi: u yana havola yoki taklif orqali kira oladi (avtomatik qaytarilmaydi). Botda can_restrict_members bo'lishi kerak.

Telegram'dagi kabi: odam ban qilinmagan, lekin hozir guruh a'zosi bo'lsa va only_if_banned berilmagan bo'lsa, u guruhdan chiqariladi (qaytib kira oladi). Buni xohlamasangiz, doim only_if_banned: true yuboring.

Parametrlar

ParametrTuriMajburiyCheklovIzoh
chat_idInteger yoki StringMajburiymanfiy id yoki @usernameBot a'zo bo'lgan guruh: manfiy id yoki ochiq guruhning @username'i. Kanal uchun ishlamaydi.
user_idIntegerMajburiyβ€”Bot ko'rgan psevdonim id (message.from.id, new_chat_members[].id …). Bot hali ko'rmagan odamning id'si β€” user not found.
only_if_bannedBooleanIxtiyoriyβ€”true β€” faqat ban qilingan bo'lsa amal qiladi, a'zoga tegmaydi. Tavsiya etiladi.

Javob

Natija (result): true

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

Xatolar

KodTavsifSabab va yechim
400Bad Request: chat not foundBunday chat yo'q, bot unda a'zo emas yoki bu shaxsiy chat id'si. Hammasi uchun javob bir xil (atayin).
400Bad Request: method is not available for channel chatsBu metod faqat guruhlar uchun.
400Bad Request: not enough rights to restrict/unrestrict chat memberBot admin emas yoki unda "Foydalanuvchilarni cheklash" (can_restrict_members) huquqi yo'q.
400Bad Request: user not founduser_id bot ko'rgan psevdonim id emas (yoki odam guruhda emas).
400Bad Request: can't remove chat ownerGuruh egasiga admin amallari qo'llanmaydi.
400Bad Request: user is an administrator of the chatAdminlarga ham qo'llanmaydi.
400Bad Request: can't restrict selfuser_id β€” botning o'zi.

Istalgan metodda bo'lishi mumkin: 401 Unauthorized, 403 Forbidden: bot is suspended, 429 Too Many Requests, 400 Bad Request: <maydon>: … β€” xato kodlari.

Misol

Python
import os
import requests

TOKEN = os.environ["ZAMIN_BOT_TOKEN"]
API = f"https://api.zamin.app/bot{TOKEN}"

GROUP_ID = int(os.environ["ZAMIN_GROUP_ID"])

r = requests.post(
    f"{API}/unbanChatMember",
    json={"chat_id": GROUP_ID, "user_id": 5203318874, "only_if_banned": True},
    timeout=15,
)
print(r.json())
curl
curl -s -X POST "https://api.zamin.app/bot$ZAMIN_BOT_TOKEN/unbanChatMember" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": -4012345678, "user_id": 5203318874, "only_if_banned": true}'