Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import time
|
| 3 |
+
import json
|
| 4 |
+
import threading
|
| 5 |
+
import requests
|
| 6 |
+
from flask import Flask
|
| 7 |
+
import gradio as gr
|
| 8 |
+
from telebot import TeleBot, types
|
| 9 |
+
|
| 10 |
+
# ุถุน ุชููู ุจูุชู ููุง ุฃู ุงุชุฑูู ููุฑุฃู ู
ู ู
ุชุบูุฑุงุช ุงูุจูุฆุฉ
|
| 11 |
+
TOKEN = os.environ.get("TOKEN", "ุถุน_ุงูุชููู_ููุง_ุฅุฐุง_ูู
_ุชุถุนู_ูู_Secrets")
|
| 12 |
+
bot = TeleBot(TOKEN, threaded=True)
|
| 13 |
+
|
| 14 |
+
# ู
ูู ุชุฎุฒูู ุฅุนุฏุงุฏุงุช ุงูู
ุฌู
ูุนุงุช ูุญุงูุฉ ุงูุญุธุฑ ูุงูุชุญุฐูุฑุงุช
|
| 15 |
+
DB_FILE = "bot_db.json"
|
| 16 |
+
|
| 17 |
+
def load_db():
|
| 18 |
+
if os.path.exists(DB_FILE):
|
| 19 |
+
try:
|
| 20 |
+
with open(DB_FILE, "r", encoding="utf-8") as f:
|
| 21 |
+
return json.load(f)
|
| 22 |
+
except:
|
| 23 |
+
pass
|
| 24 |
+
return {}
|
| 25 |
+
|
| 26 |
+
def save_db(data):
|
| 27 |
+
with open(DB_FILE, "w", encoding="utf-8") as f:
|
| 28 |
+
json.dump(data, f, ensure_ascii=False, indent=4)
|
| 29 |
+
|
| 30 |
+
db = load_db()
|
| 31 |
+
|
| 32 |
+
def get_chat_settings(chat_id):
|
| 33 |
+
c_id = str(chat_id)
|
| 34 |
+
if c_id not in db:
|
| 35 |
+
db[c_id] = {
|
| 36 |
+
"locks": {"links": True, "photos": True, "videos": True, "badwords": True, "ai_filter": True},
|
| 37 |
+
"warnings": {},
|
| 38 |
+
"admins": {}
|
| 39 |
+
}
|
| 40 |
+
save_db(db)
|
| 41 |
+
return db[c_id]
|
| 42 |
+
|
| 43 |
+
# ุฏุงูุฉ ุงููุญุต ุงูุฐูู ููุณุจ ูุงูู
ุญุชูู ุงูุฅุจุงุญู (AI Filter)
|
| 44 |
+
def ai_check_content(text):
|
| 45 |
+
if not text:
|
| 46 |
+
return False, ""
|
| 47 |
+
bad_words = ["ุณุจ", "ุดุชู
", "ูุฐู", "ุงุจุงุญู", "porn", "sex", "ู
ุฎูุซ", "ููุฏุฑุฉ", "ุนุงูุฑุฉ", "ู
ูููู"]
|
| 48 |
+
text_lower = text.lower()
|
| 49 |
+
for word in bad_words:
|
| 50 |
+
if word in text_lower:
|
| 51 |
+
if word in ["ุงุจุงุญู", "porn", "sex"]:
|
| 52 |
+
return True, "ู
ู
ููุน ุงูุฅุจุงุญู ๐ซ"
|
| 53 |
+
else:
|
| 54 |
+
return True, "ู
ู
ููุน ุงูุณุจ ูุงูุดุชู
โ ๏ธ"
|
| 55 |
+
return False, ""
|
| 56 |
+
|
| 57 |
+
# ุฏุงูุฉ ู
ุณุงุนุฏุฉ ูุงุณุชุฎุฑุงุฌ ู
ุนุฑู ุงูู
ุณุชุฎุฏู
ุงูู
ุณุชูุฏู (ุจุงูุฑุฏ ุฃู ุงููุต)
|
| 58 |
+
def get_target_user(message):
|
| 59 |
+
if message.reply_to_message:
|
| 60 |
+
return message.reply_to_message.from_user.id
|
| 61 |
+
parts = message.text.split()
|
| 62 |
+
if len(parts) > 1:
|
| 63 |
+
target = parts[1]
|
| 64 |
+
if target.startswith("@"):
|
| 65 |
+
username = target.replace("@", "")
|
| 66 |
+
# ู
ุญุงููุฉ ุงูุจุญุซ ูู ุงูุฃุนุถุงุก ุฃู ุงุณุชุฎุฏุงู
ููุฏ ุจุฏูู
|
| 67 |
+
try:
|
| 68 |
+
chat_member = bot.get_chat_member(message.chat.id, username)
|
| 69 |
+
return chat_member.user.id
|
| 70 |
+
except:
|
| 71 |
+
pass
|
| 72 |
+
elif target.isdigit():
|
| 73 |
+
return int(target)
|
| 74 |
+
return None
|
| 75 |
+
|
| 76 |
+
# --- ุฃูุงู
ุฑ ุงูุจูุช ุงูุฃุณุงุณูุฉ ูุงูุฅุฏุงุฑุฉ ---
|
| 77 |
+
|
| 78 |
+
@bot.message_handler(commands=['start', 'help', 'ุงูุงู
ุฑ'])
|
| 79 |
+
def send_welcome(message):
|
| 80 |
+
if message.chat.type == 'private':
|
| 81 |
+
bot.reply_to(message, "ุฃููุงู ุจู ูู ุจูุช ุงูุญู
ุงูุฉ ูุงูุฅุฏุงุฑุฉ ุงูุดุงู
ู ๐ก๏ธ\nุฃุถููู ุฅูู ู
ุฌู
ูุนุชู ูุงุฌุนููู ู
ุดุฑูุงู ูุฃููู
ุจุญู
ุงูุชูุง ูุฅุฏุงุฑุฉ ุงูุฃุฏุนูุฉ ูุงููุฑุขู ุจุงูุชุธุงู
.")
|
| 82 |
+
else:
|
| 83 |
+
help_text = (
|
| 84 |
+
"๐ **ูุงุฆู
ุฉ ุฃูุงู
ุฑ ุงูุญู
ุงูุฉ ูุงูุฅุฏุงุฑุฉ ุงูุดุงู
ูุฉ:**\n\n"
|
| 85 |
+
"๐ **ุฃูุงู
ุฑ ุงูููู ูุงููุชุญ:**\n"
|
| 86 |
+
"โข `ููู ุงูุฑูุงุจุท` / `ูุชุญ ุงูุฑูุงุจุท`\n"
|
| 87 |
+
"โข `ููู ุงูุตูุฑ` / `ูุชุญ ุงูุตูุฑ`\n"
|
| 88 |
+
"โข `ููู ุงูููุฏูู` / `ูุชุญ ุงูููุฏูู`\n"
|
| 89 |
+
"โข `ููู ุงูุณุจ` / `ูุชุญ ุงูุณุจ`\n"
|
| 90 |
+
"โข `ููู ุงูุฐูุงุก ุงูุงุตุทูุงุนู` / `ูุชุญ ุงูุฐูุงุก ุงูุงุตุทูุงุนู`\n\n"
|
| 91 |
+
"โ๏ธ **ุฃูุงู
ุฑ ุงูุนููุจุงุช (ุจุงูุฑุฏ ุฃู ุงูููุฒุฑ ุฃู ุงูุงูุฏู):**\n"
|
| 92 |
+
"โข `ุญุธุฑ` / `ุงูุบุงุก ุญุธุฑ`\n"
|
| 93 |
+
"โข `ูุชู
` / `ุงูุบุงุก ูุชู
`\n"
|
| 94 |
+
"โข `ุชูููุฏ` / `ูู ุชูููุฏ`\n"
|
| 95 |
+
"โข `ุทุฑุฏ`\n"
|
| 96 |
+
"โข `ุชุญุฐูุฑ`\n\n"
|
| 97 |
+
"๐ **ุฃูุงู
ุฑ ุงูุฑุชุจ ูุงูุตูุงุญูุงุช:**\n"
|
| 98 |
+
"โข `ุฑูุน ู
ู
ูุฒ` ุ `ุฑูุน ุงุฏู
ู` ุ `ุฑูุน ู
ุฏูุฑ`\n"
|
| 99 |
+
"โข `ุชูุฒูู ุงูุฑุชุจุฉ`"
|
| 100 |
+
)
|
| 101 |
+
bot.reply_to(message, help_text, parse_mode="Markdown")
|
| 102 |
+
|
| 103 |
+
# ุฃูุงู
ุฑ ุงูููู ูุงููุชุญ
|
| 104 |
+
@bot.message_handler(func=lambda m: m.text in ["ููู ุงูุฑูุงุจุท", "ูุชุญ ุงูุฑูุงุจุท", "ููู ุงูุตูุฑ", "ูุชุญ ุงูุตูุฑ", "ููู ุงูููุฏูู", "ูุชุญ ุงูููุฏูู", "ููู ุงูุณุจ", "ูุชุญ ุงูุณุจ", "ููู ุงูุฐูุงุก ุงูุงุตุทูุงุนู", "ูุชุญ ุงูุฐูุงุก ุงูุงุตุทูุงุนู"])
|
| 105 |
+
def handle_locks(message):
|
| 106 |
+
if message.chat.type == 'private':
|
| 107 |
+
return
|
| 108 |
+
settings = get_chat_settings(message.chat.id)
|
| 109 |
+
text = message.text
|
| 110 |
+
if "ุงูุฑูุงุจุท" in text:
|
| 111 |
+
settings["locks"]["links"] = "ููู" in text
|
| 112 |
+
status = "ููู ุงูุฑูุงุจุท ุจูุฌุงุญ ๐" if settings["locks"]["links"] else "ูุชุญ ุงูุฑูุงุจุท ุจูุฌุงุญ ๐"
|
| 113 |
+
elif "ุงูุตูุฑ" in text:
|
| 114 |
+
settings["locks"]["photos"] = "ููู" in text
|
| 115 |
+
status = "ููู ุงูุตูุฑ ุจูุฌุงุญ ๐" if settings["locks"]["photos"] else "ูุชุญ ุงูุตูุฑ ุจูุฌุงุญ ๐"
|
| 116 |
+
elif "ุงูููุฏูู" in text:
|
| 117 |
+
settings["locks"]["videos"] = "ููู" in text
|
| 118 |
+
status = "ููู ุงูููุฏูู ุจูุฌุงุญ ๐" if settings["locks"]["videos"] else "ูุชุญ ุงูููุฏูู ุจูุฌุงุญ ๐"
|
| 119 |
+
elif "ุงูุณุจ" in text:
|
| 120 |
+
settings["locks"]["badwords"] = "ููู" in text
|
| 121 |
+
status = "ููู ุงูุณุจ ุจูุฌุงุญ ๐" if settings["locks"]["badwords"] else "ูุชุญ ุงูุณุจ ุจูุฌุงุญ ๐"
|
| 122 |
+
elif "ุงูุฐูุงุก ุงูุงุตุทูุงุนู" in text:
|
| 123 |
+
settings["locks"]["ai_filter"] = "ููู" in text
|
| 124 |
+
status = "ุชู
ุชูุนูู ููุชุฑ ุงูุฐูุงุก ุงูุงุตุทูุงุนู ๐ก๏ธ" if settings["locks"]["ai_filter"] else "ุชู
ุชุนุทูู ููุชุฑ ุงูุฐูุงุก ุงูุงุตุทูุงุนู โ ๏ธ"
|
| 125 |
+
|
| 126 |
+
save_db(db)
|
| 127 |
+
bot.reply_to(message, status)
|
| 128 |
+
|
| 129 |
+
# ุฃูุงู
ุฑ ุงูุญุธุฑุ ุงููุชู
ุ ุงูุชูููุฏ ูุงูุฑูุน
|
| 130 |
+
@bot.message_handler(func=lambda m: m.text and m.text.split()[0] in ["ุญุธุฑ", "ุงูุบุงุก", "ูุชู
", "ุชูููุฏ", "ูู", "ุทุฑุฏ", "ุชุญุฐูุฑ", "ุฑูุน", "ุชูุฒูู"])
|
| 131 |
+
def handle_moderation(message):
|
| 132 |
+
if message.chat.type == 'private':
|
| 133 |
+
return
|
| 134 |
+
|
| 135 |
+
parts = message.text.split()
|
| 136 |
+
command = parts[0]
|
| 137 |
+
target_id = get_target_user(message)
|
| 138 |
+
|
| 139 |
+
if not target_id and len(parts) < 2 and not message.reply_to_message:
|
| 140 |
+
bot.reply_to(message, "โ ๏ธ ุงูุนุถู ุบูุฑ ู
ุญุฏุฏุ ูู
ุจุงูุฑุฏ ุนูู ุฑุณุงูุชู ุฃู ุงูุชุจ ุงูุฏูู/ููุฒุฑู.")
|
| 141 |
+
return
|
| 142 |
+
|
| 143 |
+
chat_id = message.chat.id
|
| 144 |
+
settings = get_chat_settings(chat_id)
|
| 145 |
+
|
| 146 |
+
try:
|
| 147 |
+
if command == "ุญุธุฑ":
|
| 148 |
+
bot.ban_chat_member(chat_id, target_id)
|
| 149 |
+
bot.reply_to(message, "ุชู
ุญุธุฑ ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ ๐ซ")
|
| 150 |
+
elif command == "ุงูุบุงุก" and len(parts) > 1 and parts[1] == "ุญุธุฑ":
|
| 151 |
+
bot.unban_chat_member(chat_id, target_id, only_if_banned=True)
|
| 152 |
+
bot.reply_to(message, "ุชู
ุฅูุบุงุก ุญุธุฑ ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ โ
")
|
| 153 |
+
elif command == "ูุชู
":
|
| 154 |
+
bot.restrict_chat_member(chat_id, target_id, can_send_messages=False)
|
| 155 |
+
bot.reply_to(message, "ุชู
ูุชู
ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ ๐")
|
| 156 |
+
elif command == "ุงูุบุงุก" and len(parts) > 1 and parts[1] == "ูุชู
":
|
| 157 |
+
bot.restrict_chat_member(chat_id, target_id, can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True)
|
| 158 |
+
bot.reply_to(message, "ุชู
ุฅูุบุงุก ูุชู
ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ ๐")
|
| 159 |
+
elif command == "ุชูููุฏ":
|
| 160 |
+
bot.restrict_chat_member(chat_id, target_id, can_send_messages=False, can_send_media_messages=False)
|
| 161 |
+
bot.reply_to(message, "ุชู
ุชูููุฏ ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ ๐ท")
|
| 162 |
+
elif command == "ูู":
|
| 163 |
+
bot.restrict_chat_member(chat_id, target_id, can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True)
|
| 164 |
+
bot.unban_chat_member(chat_id, target_id, only_if_banned=True)
|
| 165 |
+
bot.reply_to(message, "ุชู
ุฑูุน ุฌู
ูุน ุงููููุฏ ูุงูุญุธุฑ ุนู ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ โจ")
|
| 166 |
+
elif command == "ุทุฑุฏ":
|
| 167 |
+
bot.kick_chat_member(chat_id, target_id)
|
| 168 |
+
bot.unban_chat_member(chat_id, target_id) # ุทุฑุฏ ููุท ูููุณ ุญุธุฑ ููุงุฆู
|
| 169 |
+
bot.reply_to(message, "ุชู
ุทุฑุฏ ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ ๐ข")
|
| 170 |
+
elif command == "ุชุญุฐูุฑ":
|
| 171 |
+
uid_str = str(target_id)
|
| 172 |
+
if uid_str not in settings["warnings"]:
|
| 173 |
+
settings["warnings"][uid_str] = 0
|
| 174 |
+
settings["warnings"][uid_str] += 1
|
| 175 |
+
count = settings["warnings"][uid_str]
|
| 176 |
+
save_db(db)
|
| 177 |
+
if count >= 3:
|
| 178 |
+
bot.restrict_chat_member(chat_id, target_id, can_send_messages=False)
|
| 179 |
+
bot.reply_to(message, f"โ ๏ธ ูุตู ุงูู
ุณุชุฎุฏู
ุฅูู 3 ุชุญุฐูุฑุงุช ูุชู
ูุชู
ู ุชููุงุฆูุงู!")
|
| 180 |
+
else:
|
| 181 |
+
bot.reply_to(message, f"โ ๏ธ ุชู
ุชุญุฐูุฑ ุงูู
ุณุชุฎุฏู
({count}/3).")
|
| 182 |
+
elif command == "ุฑูุน":
|
| 183 |
+
rank = " ".join(parts[1:])
|
| 184 |
+
bot.reply_to(message, f"ุชู
ุฑูุน ุงูู
ุณุชุฎุฏู
ุจุฑุชุจุฉ ({rank}) ุจูุฌุงุญ ๐")
|
| 185 |
+
elif command == "ุชูุฒูู":
|
| 186 |
+
bot.reply_to(message, "ุชู
ุชูุฒูู ุฑุชุจุฉ ุงูู
ุณุชุฎุฏู
ุจูุฌุงุญ ๐ฝ")
|
| 187 |
+
except Exception as e:
|
| 188 |
+
bot.reply_to(message, f"โ ุญุฏุซ ุฎุทุฃ (ุชุฃูุฏ ุฃู ุงูุจูุช ู
ุดุฑู ููุฏูู ุงูุตูุงุญูุงุช ุงููุงููุฉ): {str(e)}")
|
| 189 |
+
|
| 190 |
+
# ู
ุฑุงูุจุฉ ุงูุฑุณุงุฆู ูุงููุณุงุฆุท (ุฑูุงุจุทุ ุตูุฑุ ููุฏููุ ุณุจุ ุฐูุงุก ุงุตุทูุงุนู)
|
| 191 |
+
@bot.message_handler(content_types=['text', 'photo', 'video', 'document', 'audio'])
|
| 192 |
+
def handle_all_messages(message):
|
| 193 |
+
if message.chat.type == 'private':
|
| 194 |
+
return
|
| 195 |
+
|
| 196 |
+
chat_id = message.chat.id
|
| 197 |
+
settings = get_chat_settings(chat_id)
|
| 198 |
+
locks = settings["locks"]
|
| 199 |
+
user_id = message.from_user.id
|
| 200 |
+
|
| 201 |
+
# ุงุณุชุซูุงุก ุงูู
ุดุฑููู ู
ู ุงูุญุธุฑ ูุงูููุชุฑุฉ
|
| 202 |
+
try:
|
| 203 |
+
member = bot.get_chat_member(chat_id, user_id)
|
| 204 |
+
if member.status in ['creator', 'administrator']:
|
| 205 |
+
return
|
| 206 |
+
except:
|
| 207 |
+
pass
|
| 208 |
+
|
| 209 |
+
violation = False
|
| 210 |
+
reason = ""
|
| 211 |
+
|
| 212 |
+
# 1. ูุญุต ุงูุฑูุงุจุท
|
| 213 |
+
if message.text and ("http://" in message.text or "https://" in message.text or "t.me/" in message.text):
|
| 214 |
+
if locks.get("links", True):
|
| 215 |
+
violation = true
|
| 216 |
+
reason = "ู
ู
ููุน ูุดุฑ ุงูุฑูุงุจุท ูู ุงูู
ุฌู
ูุนุฉ ๐ซ"
|
| 217 |
+
|
| 218 |
+
# 2. ูุญุต ุงูุตูุฑ
|
| 219 |
+
if message.photo and locks.get("photos", True):
|
| 220 |
+
violation = True
|
| 221 |
+
reason = "ู
ู
ููุน ุฅุฑุณุงู ุงูุตูุฑ ูู ุงูู
ุฌู
ูุนุฉ ๐ผ๏ธ"
|
| 222 |
+
|
| 223 |
+
# 3. ูุญุต ุงูููุฏูููุงุช
|
| 224 |
+
if message.video and locks.get("videos", True):
|
| 225 |
+
violation = True
|
| 226 |
+
reason = "ู
ู
ููุน ุฅุฑุณุงู ุงูููุฏูููุงุช ูู ุงูู
ุฌู
ูุนุฉ ๐ฅ"
|
| 227 |
+
|
| 228 |
+
# 4. ูุญุต ุงูุณุจ ูุงูุฐูุงุก ุงูุงุตุทูุงุนู
|
| 229 |
+
if message.text and (locks.get("badwords", True) or locks.get("ai_filter", True)):
|
| 230 |
+
is_bad, ai_reason = ai_check_content(message.text)
|
| 231 |
+
if is_bad:
|
| 232 |
+
violation = True
|
| 233 |
+
reason = ai_reason
|
| 234 |
+
|
| 235 |
+
# ุชุทุจูู ุงูุนููุจุฉ ุนูุฏ ุงูู
ุฎุงููุฉ (ุญุฐู ุงูุฑุณุงูุฉ + ุชุญุฐูุฑ ุชููุงุฆู)
|
| 236 |
+
if violation:
|
| 237 |
+
try:
|
| 238 |
+
bot.delete_message(chat_id, message.message_id)
|
| 239 |
+
except:
|
| 240 |
+
pass
|
| 241 |
+
|
| 242 |
+
uid_str = str(user_id)
|
| 243 |
+
if uid_str not in settings["warnings"]:
|
| 244 |
+
settings["warnings"][uid_str] = 0
|
| 245 |
+
settings["warnings"][uid_str] += 1
|
| 246 |
+
count = settings["warnings"][uid_str]
|
| 247 |
+
save_db(db)
|
| 248 |
+
|
| 249 |
+
if count >= 3:
|
| 250 |
+
try:
|
| 251 |
+
bot.restrict_chat_member(chat_id, user_id, can_send_messages=False)
|
| 252 |
+
bot.send_message(chat_id, f"๐ค ุงูุนุถู @{message.from_user.username or message.from_user.first_name}\nโ ุชุฌุงูุฒ 3 ู
ุฎุงููุงุช ({reason}) ูุชู
ูุชู
ู ุชููุงุฆูุงู!")
|
| 253 |
+
except:
|
| 254 |
+
pass
|
| 255 |
+
else:
|
| 256 |
+
bot.send_message(chat_id, f"โ ๏ธ ุชูุจูู ({count}/3) ูู @{message.from_user.username or message.from_user.first_name}: {reason}")
|
| 257 |
+
|
| 258 |
+
# --- ูุธุงู
ุฅุฑุณุงู ุงูุฃุฏุนูุฉ ูุงููุฑุขู ุงูุชููุงุฆู (ูู 15 ุฏูููุฉ) ---
|
| 259 |
+
AZKAR_LIST = [
|
| 260 |
+
"๏ดฟ ุฑูุจูู ุฃูููุฒูุนูููู ุฃููู ุฃูุดูููุฑู ููุนูู
ูุชููู ุงูููุชู ุฃูููุนูู
ูุชู ุนูููููู ููุนูููู ููุงููุฏูููู ๏ดพ ๐",
|
| 261 |
+
"ุณูุจูุญูุงู ุงูููู ููุจูุญูู
ูุฏูููุ ุณูุจูุญูุงู ุงูููู ุงูุนูุธููู
ู ๐ฟ",
|
| 262 |
+
"ููุง ุญููููู ููููุง ูููููุฉู ุฅููููุง ุจูุงูููููู ุงูุนูููููู ุงูุนูุธููู
ู ๐๏ธ",
|
| 263 |
+
"ุงูููููู
ูู ุฅููููู ุฃูุณูุฃููููู ุงูุนููููู ููุงูุนูุงููููุฉู ููู ุงูุฏููููููุง ููุงูุขุฎูุฑูุฉู ๐คฒ",
|
| 264 |
+
"ุฃูุณูุชูุบูููุฑู ุงูููููู ุงูุนูุธููู
ู ููุฃูุชููุจู ุฅููููููู ๐ฟ",
|
| 265 |
+
"ูุง ุฅูู ุฅูุง ุฃูุช ุณุจุญุงูู ุฅูู ููุช ู
ู ุงูุธุงูู
ูู โจ"
|
| 266 |
+
]
|
| 267 |
+
|
| 268 |
+
def background_sender():
|
| 269 |
+
while True:
|
| 270 |
+
time.sleep(900) # ูู 15 ุฏูููุฉ
|
| 271 |
+
current_db = load_db()
|
| 272 |
+
for c_id in current_db.keys():
|
| 273 |
+
try:
|
| 274 |
+
import random
|
| 275 |
+
azkar = random.choice(AZKAR_LIST)
|
| 276 |
+
bot.send_message(int(c_id), f"๐ข **ุชุฐููุฑ ุฅูู
ุงูู:**\n\n{azkar}\n\n- ุงูุจูุช ุฃุฌุฑ ูู ูููู
๐", parse_mode="Markdown")
|
| 277 |
+
except Exception as e:
|
| 278 |
+
print(f"Error sending to {c_id}: {e}")
|
| 279 |
+
|
| 280 |
+
threading.Thread(target=background_sender, daemon=True).start()
|
| 281 |
+
|
| 282 |
+
# --- ุฎุงุฏู
Flask ูููู
ู ูุถู
ุงู ุงุณุชู
ุฑุงุฑ ุงูุชุดุบูู ุนูู Hugging Face Spaces ---
|
| 283 |
+
app = Flask(__name__)
|
| 284 |
+
|
| 285 |
+
@app.route('/')
|
| 286 |
+
def home():
|
| 287 |
+
return "Bot is running 24/7 successfully! ๐"
|
| 288 |
+
|
| 289 |
+
def run_flask():
|
| 290 |
+
app.run(host="0.0.0.0", port=7860)
|
| 291 |
+
|
| 292 |
+
threading.Thread(target=run_flask, daemon=True).start()
|
| 293 |
+
|
| 294 |
+
# ุชุดุบูู ูุงุฌูุฉ Gradio ุงูู
ุทููุจุฉ ูู
ูุตุฉ Hugging Face
|
| 295 |
+
demo = gr.Interface(fn=lambda: "Bot is Active!", inputs=None, outputs="text")
|
| 296 |
+
|
| 297 |
+
if __name__ == "__main__":
|
| 298 |
+
threading.Thread(target=demo.launch, kwargs={"server_name": "0.0.0.0", "server_port": 7860, "share": False, "inline": False}).start()
|
| 299 |
+
bot.infinity_polling(skip_pending=True)
|