Spaces:
Running
Running
ok
Browse files
main.py
CHANGED
@@ -143,15 +143,30 @@ async def warn(client, message):
|
|
143 |
member = await client.get_chat_member(message.chat.id, message.from_user.id)
|
144 |
if member.status not in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
145 |
return await message.reply_text("β Hanya admin yang bisa memberikan peringatan!")
|
|
|
|
|
146 |
|
147 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
return await message.reply_text("GAK ADA USER ID NYA? GIMANA NARIK BOT KE GRUP LU?")
|
149 |
|
150 |
-
user_id = int(message.command[1])
|
151 |
if user_id == client.me.id:
|
152 |
return await message.reply_text("GAK BISA WARN BOT SENDIRI! GIMANA NARIK BOT KE GRUP LU?")
|
153 |
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
if member_admin.status in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
156 |
return await message.reply_text("GAK BISA WARN ADMIN! GIMANA NARIK BOT KE GRUP LU?")
|
157 |
|
@@ -214,16 +229,31 @@ async def delwarn(client, message):
|
|
214 |
if member.status not in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
215 |
return await message.reply_text("β Hanya admin yang bisa menghapus peringatan!")
|
216 |
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
-
user_id = int(message.command[1])
|
221 |
if user_id == client.me.id:
|
222 |
return await message.reply_text("GAK BISA HAPUS PERINGATAN BOT SENDIRI! GIMANA NARIK BOT KE GRUP LU?")
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
if member_admin.status in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
226 |
-
return await message.reply_text("GAK BISA HAPUS PERINGATAN ADMIN!
|
227 |
|
228 |
try:
|
229 |
warn_data = await db.warns.find_one({"chat_id": message.chat.id, "user_id": user_id})
|
@@ -231,15 +261,10 @@ async def delwarn(client, message):
|
|
231 |
return await message.reply_text("β οΈ Tidak ada peringatan untuk user ini.")
|
232 |
|
233 |
await db.warns.delete_one({"chat_id": message.chat.id, "user_id": user_id})
|
234 |
-
await message.reply_text(
|
235 |
-
"berhasil menghapus semua peringatan"
|
236 |
-
)
|
237 |
-
return
|
238 |
except Exception as e:
|
239 |
logging.error(f"Error removing all warnings: {e}")
|
240 |
-
await message.reply_text(
|
241 |
-
"GAGAL MENGHAPUS SEMUA PERINGATAN! CEK LAGI USER ID NYA!"
|
242 |
-
)
|
243 |
|
244 |
@bot.on_message(filters.command("start") & filters.private)
|
245 |
async def start_command(client, message):
|
|
|
143 |
member = await client.get_chat_member(message.chat.id, message.from_user.id)
|
144 |
if member.status not in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
145 |
return await message.reply_text("β Hanya admin yang bisa memberikan peringatan!")
|
146 |
+
|
147 |
+
user_id = None
|
148 |
|
149 |
+
if message.reply_to_message and message.reply_to_message.from_user:
|
150 |
+
user_id = message.reply_to_message.from_user.id
|
151 |
+
elif len(message.command) == 2:
|
152 |
+
try:
|
153 |
+
user_id = int(message.command[1])
|
154 |
+
except ValueError:
|
155 |
+
return await message.reply_text("GAK ADA USER ID NYA? GIMANA NARIK BOT KE GRUP LU?")
|
156 |
+
else:
|
157 |
return await message.reply_text("GAK ADA USER ID NYA? GIMANA NARIK BOT KE GRUP LU?")
|
158 |
|
|
|
159 |
if user_id == client.me.id:
|
160 |
return await message.reply_text("GAK BISA WARN BOT SENDIRI! GIMANA NARIK BOT KE GRUP LU?")
|
161 |
|
162 |
+
try:
|
163 |
+
get_user = await client.get_users(user_id)
|
164 |
+
except Exception:
|
165 |
+
return await message.reply_text("β User tidak ditemukan.")
|
166 |
+
|
167 |
+
member_admin = await client.get_chat_member(message.chat.id, get_user.id)
|
168 |
+
if member_admin.status == ChatMemberStatus.BANNED:
|
169 |
+
return await message.reply_text("GAK BISA WARN USER YANG SUDAH DI BANNED! GIMANA NARIK BOT KE GRUP LU?")
|
170 |
if member_admin.status in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
171 |
return await message.reply_text("GAK BISA WARN ADMIN! GIMANA NARIK BOT KE GRUP LU?")
|
172 |
|
|
|
229 |
if member.status not in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
230 |
return await message.reply_text("β Hanya admin yang bisa menghapus peringatan!")
|
231 |
|
232 |
+
user_id = None
|
233 |
+
|
234 |
+
if message.reply_to_message and message.reply_to_message.from_user:
|
235 |
+
user_id = message.reply_to_message.from_user.id
|
236 |
+
elif len(message.command) == 2:
|
237 |
+
try:
|
238 |
+
user_id = int(message.command[1])
|
239 |
+
except ValueError:
|
240 |
+
return await message.reply_text("β USER ID tidak valid.")
|
241 |
+
else:
|
242 |
+
return await message.reply_text("β Format salah. Balas pesan atau kirim /delwarn [user_id]")
|
243 |
|
|
|
244 |
if user_id == client.me.id:
|
245 |
return await message.reply_text("GAK BISA HAPUS PERINGATAN BOT SENDIRI! GIMANA NARIK BOT KE GRUP LU?")
|
246 |
+
|
247 |
+
try:
|
248 |
+
get_user = await client.get_users(user_id)
|
249 |
+
except Exception:
|
250 |
+
return await message.reply_text("β User tidak ditemukan.")
|
251 |
+
|
252 |
+
member_admin = await client.get_chat_member(message.chat.id, get_user.id)
|
253 |
+
if member_admin.status == ChatMemberStatus.BANNED:
|
254 |
+
return await message.reply_text("β GAK BISA HAPUS PERINGATAN USER YANG SUDAH DI BANNED!")
|
255 |
if member_admin.status in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
|
256 |
+
return await message.reply_text("β GAK BISA HAPUS PERINGATAN ADMIN!")
|
257 |
|
258 |
try:
|
259 |
warn_data = await db.warns.find_one({"chat_id": message.chat.id, "user_id": user_id})
|
|
|
261 |
return await message.reply_text("β οΈ Tidak ada peringatan untuk user ini.")
|
262 |
|
263 |
await db.warns.delete_one({"chat_id": message.chat.id, "user_id": user_id})
|
264 |
+
await message.reply_text("β
Berhasil menghapus semua peringatan.")
|
|
|
|
|
|
|
265 |
except Exception as e:
|
266 |
logging.error(f"Error removing all warnings: {e}")
|
267 |
+
await message.reply_text("β Gagal menghapus peringatan. Cek lagi user ID-nya.")
|
|
|
|
|
268 |
|
269 |
@bot.on_message(filters.command("start") & filters.private)
|
270 |
async def start_command(client, message):
|