Spaces:
Sleeping
Sleeping
Commit
·
dae81a0
1
Parent(s):
10fde30
update
Browse files- bot/plugins/eval.py +12 -5
- bot/plugins/ping.py +116 -0
bot/plugins/eval.py
CHANGED
|
@@ -45,8 +45,8 @@ async def evaluation_cmd_t(client, message: Message):
|
|
| 45 |
await status_message.edit_text(final_output)
|
| 46 |
|
| 47 |
async def aexec(code, client, message):
|
| 48 |
-
|
| 49 |
-
|
| 50 |
async def __aexec(client, message):
|
| 51 |
import os
|
| 52 |
neo = message
|
|
@@ -57,6 +57,13 @@ async def __aexec(client, message):
|
|
| 57 |
to_photo = message.reply_photo
|
| 58 |
to_video = message.reply_video
|
| 59 |
p = print
|
| 60 |
-
"""
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
await status_message.edit_text(final_output)
|
| 46 |
|
| 47 |
async def aexec(code, client, message):
|
| 48 |
+
# Define the function template with consistent indentation
|
| 49 |
+
function_template = """
|
| 50 |
async def __aexec(client, message):
|
| 51 |
import os
|
| 52 |
neo = message
|
|
|
|
| 57 |
to_photo = message.reply_photo
|
| 58 |
to_video = message.reply_video
|
| 59 |
p = print
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
# Combine the template with the user-provided code, ensuring consistent indentation
|
| 63 |
+
full_code = function_template + "\n".join(f" {line}" for line in code.split("\n"))
|
| 64 |
+
|
| 65 |
+
# Execute the combined code
|
| 66 |
+
exec(full_code)
|
| 67 |
+
|
| 68 |
+
# Call the dynamically defined function
|
| 69 |
+
return await locals()["__aexec"](client, message)
|
bot/plugins/ping.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Credits by @neomatrix90
|
| 2 |
+
|
| 3 |
+
import asyncio
|
| 4 |
+
import aiohttp
|
| 5 |
+
import random
|
| 6 |
+
import time
|
| 7 |
+
import requests
|
| 8 |
+
from random import choice
|
| 9 |
+
from datetime import datetime as dt
|
| 10 |
+
|
| 11 |
+
from hydrogram import filters
|
| 12 |
+
from hydrogram.types import Message
|
| 13 |
+
from bot import TelegramBot, StartTime, utils
|
| 14 |
+
from bot.config import Telegram
|
| 15 |
+
|
| 16 |
+
PING_DISABLE_NONPREM = {}
|
| 17 |
+
ANIME_WAIFU_IS_RANDOM = {}
|
| 18 |
+
|
| 19 |
+
def waifu_hentai():
|
| 20 |
+
LIST_SFW_JPG = ["trap", "waifu", "blowjob", "neko"]
|
| 21 |
+
waifu_link = "https"
|
| 22 |
+
waifu_api = "api.waifu.pics"
|
| 23 |
+
waifu_types = "nsfw"
|
| 24 |
+
waifu_category = choice(LIST_SFW_JPG)
|
| 25 |
+
waifu_param = f"{waifu_link}://{waifu_api}/{waifu_types}/{waifu_category}"
|
| 26 |
+
response = requests.get(waifu_param).json()
|
| 27 |
+
return response["url"]
|
| 28 |
+
|
| 29 |
+
def waifu_random():
|
| 30 |
+
LIST_SFW_JPG = ["neko", "waifu", "megumin"]
|
| 31 |
+
waifu_link = "https"
|
| 32 |
+
waifu_api = "api.waifu.pics"
|
| 33 |
+
waifu_types = "sfw"
|
| 34 |
+
waifu_category = choice(LIST_SFW_JPG)
|
| 35 |
+
waifu_param = f"{waifu_link}://{waifu_api}/{waifu_types}/{waifu_category}"
|
| 36 |
+
response = requests.get(waifu_param).json()
|
| 37 |
+
return response["url"]
|
| 38 |
+
|
| 39 |
+
async def fetch_server_status():
|
| 40 |
+
"""Fetch the server status from the given URL."""
|
| 41 |
+
url = "https://kawaiimizo-maakichu.hf.space/health"
|
| 42 |
+
try:
|
| 43 |
+
async with aiohttp.ClientSession() as session:
|
| 44 |
+
async with session.get(url) as response:
|
| 45 |
+
if response.status == 200:
|
| 46 |
+
data = await response.json()
|
| 47 |
+
return data.get("message", "Unknown")
|
| 48 |
+
return "Server Unreachable"
|
| 49 |
+
except Exception as e:
|
| 50 |
+
return f"Error: {str(e)}"
|
| 51 |
+
|
| 52 |
+
def get_caption(duration: float, uptime: str, is_premium: bool, server_status: str) -> str:
|
| 53 |
+
"""Generate the caption for the ping response."""
|
| 54 |
+
if is_premium:
|
| 55 |
+
return f"**Pong !!** `{duration}ms`\n**Uptime** - `{uptime}`\n**Server:** {server_status}"
|
| 56 |
+
return (
|
| 57 |
+
f"🏓 **Pɪɴɢᴇʀ :** `{duration}ms`\n"
|
| 58 |
+
f"👨💻 **Sᴇʀᴠᴇʀ:** `{server_status}`"
|
| 59 |
+
f"⌛ **Uᴘᴛɪᴍᴇ :** `{uptime}`\n"
|
| 60 |
+
f"🤴 **Oᴡɴᴇʀ :** {client.me.mention}"
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
async def send_ping_response(message: Message, duration: float, uptime: str, is_premium: bool, server_status: str, photo=None):
|
| 64 |
+
"""Send the ping response with optional photo."""
|
| 65 |
+
caption = get_caption(duration, uptime, is_premium, server_status)
|
| 66 |
+
if photo:
|
| 67 |
+
await message.reply_photo(photo, caption=caption)
|
| 68 |
+
else:
|
| 69 |
+
await message.reply_text(caption)
|
| 70 |
+
|
| 71 |
+
@TelegramBot.on_message(filters.command("pingset") & filters.user(Telegram.OWNER_ID) & ~filters.forwarded)
|
| 72 |
+
async def pingsetsetting(client, message: Message):
|
| 73 |
+
global PING_DISABLE_NONPREM, ANIME_WAIFU_IS_RANDOM
|
| 74 |
+
args = message.text.lower().split()[1:]
|
| 75 |
+
chat = message.chat
|
| 76 |
+
|
| 77 |
+
if chat.type != "private" and args:
|
| 78 |
+
if args[0] == "anime":
|
| 79 |
+
ANIME_WAIFU_IS_RANDOM[message.from_user.id] = {"anime": True, "hentai": False}
|
| 80 |
+
await message.reply_text(f"Turned on ping {args[0]}.")
|
| 81 |
+
elif args[0] == "hentai":
|
| 82 |
+
ANIME_WAIFU_IS_RANDOM[message.from_user.id] = {"anime": False, "hentai": True}
|
| 83 |
+
await message.reply_text(f"Turned on ping {args[0]}.")
|
| 84 |
+
elif args[0] in ("no", "off", "false"):
|
| 85 |
+
PING_DISABLE_NONPREM[message.from_user.id] = False
|
| 86 |
+
ANIME_WAIFU_IS_RANDOM[message.from_user.id] = {"anime": False, "hentai": False}
|
| 87 |
+
await message.reply_text("Turned off ping automatic.")
|
| 88 |
+
else:
|
| 89 |
+
ping_mode = "On" if PING_DISABLE_NONPREM.get(message.from_user.id) else \
|
| 90 |
+
"Anime" if ANIME_WAIFU_IS_RANDOM.get(message.from_user.id) else "Off"
|
| 91 |
+
await message.reply_text(f"Ping Mode: {ping_mode}")
|
| 92 |
+
|
| 93 |
+
@TelegramBot.on_message(filters.command("ping") & ~filters.forwarded)
|
| 94 |
+
async def custom_ping_handler(client, message: Message):
|
| 95 |
+
uptime = utils.get_readable_time((time.time() - StartTime))
|
| 96 |
+
start = dt.now()
|
| 97 |
+
lol = await message.reply_text("**Pong!!**")
|
| 98 |
+
await asyncio.sleep(1.5)
|
| 99 |
+
duration = (dt.now() - start).microseconds / 1000
|
| 100 |
+
|
| 101 |
+
is_premium = client.me.is_premium
|
| 102 |
+
is_anime = ANIME_WAIFU_IS_RANDOM.get(message.from_user.id)
|
| 103 |
+
server_status = await fetch_server_status()
|
| 104 |
+
|
| 105 |
+
if PING_DISABLE_NONPREM.get(message.from_user.id):
|
| 106 |
+
await lol.edit_text(get_caption(duration, uptime, is_premium, server_status))
|
| 107 |
+
return
|
| 108 |
+
|
| 109 |
+
if is_anime:
|
| 110 |
+
photo = waifu_random() if is_anime.get("anime") else waifu_hentai() if is_anime.get("hentai") else None
|
| 111 |
+
if photo:
|
| 112 |
+
await send_ping_response(message, duration, uptime, is_premium, server_status, photo)
|
| 113 |
+
await lol.delete()
|
| 114 |
+
return
|
| 115 |
+
|
| 116 |
+
await send_ping_response(message, duration, uptime, is_premium, server_status)
|