async def chatBot_replies(e): sender = await e.get_sender() if not isinstance(sender, types.User): return key = udB.get_key("CHATBOT_USERS") or {} if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]: msg = await get_chatbot_reply(e.message.message) if msg: sleep = udB.get_key("CHATBOT_SLEEP") or 1.5 await asyncio.sleep(sleep) await e.reply(msg) chat = await e.get_chat() if e.is_group and not sender.bot: if sender.username: await uname_stuff(e.sender_id, sender.username, sender.first_name) elif e.is_private and not sender.bot: if chat.username: await uname_stuff(e.sender_id, chat.username, chat.first_name) if detector and is_profan(e.chat_id) and e.text: x, y = detector(e.text) if y: await e.delete()
async def checkprofan(e): chat = e.chat_id if is_profan(chat) and e.text: x, y = detector(e.text) if y: await e.delete()
async def checknsfw(e): chat = e.chat_id action = is_nsfw(chat) if action and udB.get("DEEP_API") and e.media: pic, name, nsfw = "", "", 0 try: pic = await e.download_media(thumb=-1) except BaseException: pass if e.file: name = e.file.name if name: x, y = detector(name) if y: nsfw += 1 if pic and not nsfw: r = requests.post( "https://api.deepai.org/api/nsfw-detector", files={ "image": open(pic, "rb"), }, headers={"api-key": udB["DEEP_API"]}, ) k = float((r.json()["output"]["nsfw_score"])) score = int(k * 100) if score > 45: nsfw += 1 os.remove(pic) if nsfw: await e.delete() if NWARN.get(e.sender_id): count = NWARN[e.sender_id] + 1 if count < 3: NWARN.update({e.sender_id: count}) return await ultroid_bot.send_message( chat, f"**NSFW Warn {count}/3** To [{e.sender.first_name}](tg://user?id={e.sender_id})\nDon't Send NSFW stuffs Here Or You will Be Get {action}", ) if "mute" in action: try: await ultroid_bot.edit_permissions(chat, e.sender_id, until_date=None, send_messages=False) await ultroid_bot.send_message( chat, f"NSFW Warn 3/3 to [{e.sender.first_name}](tg://user?id={e.sender_id})\n\n**Action Taken** : {action}", ) except BaseException: await ultroid_bot.send_message( chat, f"NSFW Warn 3/3 to [{e.sender.first_name}](tg://user?id={e.sender_id})\n\nCan't Able to {action}.", ) elif "ban" in action: try: await ultroid_bot.edit_permissions(chat, e.sender_id, view_messages=False) await ultroid_bot.send_message( chat, f"NSFW Warn 3/3 to [{e.sender.first_name}](tg://user?id={e.sender_id})\n\n**Action Taken** : {action}", ) except BaseException: await ultroid_bot.send_message( chat, f"NSFW Warn 3/3 to [{e.sender.first_name}](tg://user?id={e.sender_id})\n\nCan't Able to {action}.", ) elif "kick" in action: try: await ultroid_bot.kick_participant(chat, e.sender_id) await ultroid_bot.send_message( chat, f"NSFW Warn 3/3 to [{e.sender.first_name}](tg://user?id={e.sender_id})\n\n**Action Taken** : {action}", ) except BaseException: await ultroid_bot.send_message( chat, f"NSFW Warn 3/3 to [{e.sender.first_name}](tg://user?id={e.sender_id})\n\nCan't Able to {action}.", ) NWARN.pop(e.sender_id) else: NWARN.update({e.sender_id: 1}) return await ultroid_bot.send_message( chat, f"**NSFW Warn 1/3** To [{e.sender.first_name}](tg://user?id={e.sender_id})\nDon't Send NSFW stuffs Here Or You will Be Get {action}", )