Guruh boshqaruvi
unbanChatMember
Banni olib tashlaydi (odam yana qo'shila oladi).
POST
https://api.zamin.app/bot<TOKEN>/unbanChatMemberGET 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
| Parametr | Turi | Majburiy | Cheklov | Izoh |
|---|---|---|---|---|
chat_id | Integer yoki String | Majburiy | manfiy id yoki @username | Bot a'zo bo'lgan guruh: manfiy id yoki ochiq guruhning @username'i. Kanal uchun ishlamaydi. |
user_id | Integer | Majburiy | β | Bot ko'rgan psevdonim id (message.from.id, new_chat_members[].id β¦). Bot hali ko'rmagan odamning id'si β user not found. |
only_if_banned | Boolean | Ixtiyoriy | β | true β faqat ban qilingan bo'lsa amal qiladi, a'zoga tegmaydi. Tavsiya etiladi. |
Javob
Natija (result): true
JSON
{"ok": true, "result": true}Xatolar
| Kod | Tavsif | Sabab va yechim |
|---|---|---|
| 400 | Bad Request: chat not found | Bunday chat yo'q, bot unda a'zo emas yoki bu shaxsiy chat id'si. Hammasi uchun javob bir xil (atayin). |
| 400 | Bad Request: method is not available for channel chats | Bu metod faqat guruhlar uchun. |
| 400 | Bad Request: not enough rights to restrict/unrestrict chat member | Bot admin emas yoki unda "Foydalanuvchilarni cheklash" (can_restrict_members) huquqi yo'q. |
| 400 | Bad Request: user not found | user_id bot ko'rgan psevdonim id emas (yoki odam guruhda emas). |
| 400 | Bad Request: can't remove chat owner | Guruh egasiga admin amallari qo'llanmaydi. |
| 400 | Bad Request: user is an administrator of the chat | Adminlarga ham qo'llanmaydi. |
| 400 | Bad Request: can't restrict self | user_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}'