Spaces:
Paused
Paused
File size: 9,727 Bytes
b45d238 631b7c5 8476308 b45d238 43c1f9a b45d238 631b7c5 b45d238 631b7c5 b45d238 631b7c5 b45d238 631b7c5 b45d238 631b7c5 241dec4 631b7c5 43c1f9a 631b7c5 241dec4 dbe816b 241dec4 dbe816b 241dec4 dbe816b 241dec4 dbe816b 241dec4 4308bae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
import os
import asyncio
import platform
import subprocess
import time
import random
from datetime import datetime
from secrets import choice
from telethon import Button, events
from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
from telethon.utils import get_display_name
from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
from telethon.utils import get_display_name
from telethon.tl.types import InputMessagesFilterVideo, InputMessagesFilterVoice, InputMessagesFilterPhotos
from xteam._misc import SUDO_M, owner_and_sudos
from xteam.dB.base import KeyManager
from xteam.fns.helper import inline_mention
from strings import get_string
from platform import python_version as pyver
from pyrogram import __version__ as pver
from telegram import __version__ as lver
from telethon import __version__ as tver
from pytgcalls import __version__ as pytver
from pyrogram import filters
from pyrogram.types import Message
from telethon import TelegramClient, events
from telethon.tl.custom import Button
from . import *
from . import ultroid_bot as client
import resources
from xteam.fns.helper import inline_mention
from . import (
OWNER_NAME,
OWNER_ID,
BOT_NAME,
OWNER_USERNAME,
asst,
start_time,
time_formatter,
udB,
ultroid_cmd as xteam_cmd,
get_string,
ultroid_bot as client,
eor,
ultroid_bot,
call_back,
callback,
)
def format_message_text(uptime):
return f"<blockquote expandable><b>β° xα΄α΄α΄α΄ α΄ΚΚα΄α΄ Ιͺκ± α΄ΚΙͺα΄ α΄ β°</b>\n\n" \
f"β΅ Owner : {OWNER_NAME}\n" \
f"β΅ Dc id : {ultroid_bot.dc_id}\n" \
f"β΅ Library : {lver}\n" \
f"β΅ Uptime : {uptime}\n" \
f"β΅ Telethon : {tver}\n" \
f"β΅ Pyrogram : {pver}\n" \
f"β΅ Python : {pyver()}\n</blockquote>"
@xteam_cmd(pattern="aline$")
async def alive(event):
start = time.time()
pro = await event.eor("π₯")
await asyncio.sleep(1)
end = round((time.time() - start) * 1000)
uptime = time_formatter((time.time() - start_time) * 1000)
message_text = format_message_text(uptime)
await pro.edit(f"<blockquote expandable><b>β° xα΄α΄α΄α΄ α΄ΚΚα΄α΄ Ιͺκ± α΄ΚΙͺα΄ α΄ β°</b>\n\n" \
f"β΅ Owner : {OWNER_NAME}\n" \
f"β΅ Dc id : {ultroid_bot.dc_id}\n" \
f"β΅ Library : {lver}\n" \
f"β΅ Uptime : {uptime}\n" \
f"β΅ Telethon : {tver}\n" \
f"β΅ Pyrogram : {pver}\n" \
f"β΅ Python : {pyver()}\n</blockquote>",
parse_mode="html",
)
@xteam_cmd(pattern="Alive$")
async def alive_video(event):
try:
asupannya = [
asupan
async for asupan in event.client.iter_messages(
"@xcryasupan", filter=InputMessagesFilterVideo
)
]
if not asupannya:
await event.respond("No video found in @xcryasupan.")
return
pro = await event.eor("β‘")
await asyncio.sleep(1)
await pro.delete()
uptime = time_formatter((time.time() - start_time) * 1000000)
message_text = format_message_text(uptime)
selected_video_message = random.choice(asupannya)
# Print information about the selected video message for debugging
print(f"Selected video message ID: {selected_video_message.id}")
if selected_video_message.video:
print(f"Selected video attributes: {selected_video_message.video}")
# Try to send the video directly
await client.send_file(
event.chat.id,
file=selected_video_message.video, # Pass the video object
caption=message_text,
parse_mode="html",
)
else:
await event.respond("Selected message does not contain a video.")
except Exception as e:
await event.respond(f"An error occurred: {e}")
@xteam_cmd(pattern="live$")
async def live_video(event):
try:
asupannya = [
asupan
async for asupan in event.client.iter_messages(
"@xcryasupan", filter=InputMessagesFilterVideo
)
]
if not asupannya:
await event.respond("No video found in @xcryasupan.")
return
pro = await event.eor("β‘")
await asyncio.sleep(1)
await pro.delete()
# Assuming start_time and time_formatter are defined
uptime = time_formatter((time.time() - start_time) * 1000) # Assuming time_formatter expects milliseconds
message_text = format_message_text(uptime)
selected_video_message = random.choice(asupannya)
# Create the inline keyboard with a "Close" button
buttons = [
[Button.inline("Close", data="close_alive_message")]
]
if selected_video_message.video:
await client.send_message(
event.chat.id,
caption=message_text,
parse_mode="html",
buttons=buttons # Add the buttons here
)
else:
await event.respond("Selected message does not contain a video.")
except Exception as e:
await event.respond(f"An error occurred: {e}")
@in_pattern("Alive", owner=False)
async def alive_inline_handler(ult):
start = time.time()
end = round((time.time() - start) * 1000)
uptime = time_formatter((time.time() - start_time) * 1000)
message_text = (
f"<blockquote><b>β° xα΄α΄α΄α΄ α΄ΚΚα΄α΄ Ιͺκ± α΄ΚΙͺα΄ α΄ β°</b>\n\n"
f"β΅ Owner : {OWNER_NAME}\n"
f"β΅ Dc id : {ultroid_bot.dc_id}\n"
f"β΅ Library : {lver}\n"
f"β΅ Uptime : {uptime}\n"
f"β΅ Telethon : {tver}\n"
f"β΅ Pyrogram : {pver}\n"
f"β΅ Python : {pyver()}</blockquote>"
)
# Menggabungkan tombol dalam list of lists untuk 'buttons' parameter.
buttons_markup = [
[
Button.inline("π‘ Modules π‘",data="ownr"), # New data for modules
],
]
result = await ult.builder.article(
title="Bot Status",
text=message_text,
parse_mode="html",
buttons=buttons_markup # Menyertakan tombol "Close"
)
await ult.answer([result], cache_time=0)
@client.on(events.CallbackQuery(b'delete_this_message'))
async def handle_delete_callback(event):
"""
Menangani callback dari tombol 'Hapus Pesan Ini'.
"""
print(f"Callback diterima dari chat ID: {event.chat_id}, pesan ID: {event.message_id}")
# Dapatkan ID pesan dan ID chat dari callback query
message_id_to_delete = event.message_id
chat_id_of_message = event.chat_id
try:
# Hapus pesan yang terkait dengan callback query
await client.delete_messages(chat_id_of_message, message_id_to_delete)
print(f"Pesan dengan ID {message_id_to_delete} di chat {chat_id_of_message} telah dihapus.")
# Opsional: Beri tahu pengguna bahwa pesan telah dihapus
await event.answer("Pesan berhasil dihapus!", alert=False)
except Exception as e:
print(f"Gagal menghapus pesan: {e}")
await event.answer("Gagal menghapus pesan.", alert=True)
@xteam_cmd(pattern="alive$")
async def alive_message_handler(ult):
start = time.time()
# The 'end' variable is still unused if you just want to display uptime.
# end = round((time.time() - start) * 1000)
uptime = time_formatter((time.time() - start_time) * 1000)
message_text = (
f"<blockquote><b>β° xα΄α΄α΄α΄ α΄ΚΚα΄α΄ Ιͺκ± α΄ΚΙͺα΄ α΄ β°</b>\n\n"
f"β΅ Owner : {OWNER_NAME}\n"
f"β΅ Dc id : {ultroid_bot.dc_id}\n"
f"β΅ Library : {lver}\n"
f"β΅ Uptime : {uptime}\n"
f"β΅ Telethon : {tver}\n"
f"β΅ Pyrogram : {pver}\n"
f"β΅ Python : {pyver()}</blockquote>"
)
buttons_markup = [
[
#Button.url("π‘ Modules π‘", url="https://example.com/modules"), # Use Button.url for external links
# Or Button.inline if you have an inline query handler for 'ownr'
Button.inline("π‘ Modules π‘", data="ownr"),
],
]
await ult.reply(
message_text,
parse_mode="html",
buttons=buttons_markup
)
@xteam_cmd(pattern="alivee$")
async def alive(event):
start = time.time()
pro = await event.eor("β₯οΈ")
await asyncio.sleep(2) # Simulate some delay
end = round((time.time() - start) * 1000)
uptime = time_formatter((time.time() - start_time) * 1000)
# Reformat message using markdown
message_text = (
f"```\n" # Use a code block for the border to keep it preformatted
f"ββββββββββββββββββββ\n"
f"βββ«**α΄ΚΚα΄α΄ Ιͺκ± Ι΄α΄α΄‘ α΄ΚΙͺα΄ α΄!**β£ββ\n"
f"β£βββββββββββββββββββ«\n"
f"β α΄α΄‘Ι΄α΄Κ : `{OWNER_NAME}`\n"
f"β ΚΙͺΚΚα΄ΚΚ : `{lver}`\n"
f"β α΄α΄α΄Ιͺα΄α΄ : `{uptime}`\n"
f"β α΄α΄Κα΄α΄Κα΄Ι΄ : `{tver}`\n"
f"β α΄ΚΚα΄Ι’Κα΄α΄ : `{pver}`\n"
f"β α΄Κα΄Κα΄Ι΄ : `{pyver()}`\n"
f"ββββββββββββββββββββ\n"
f"```"
)
# The parse_mode would likely default to "markdown" or "md" in Telethon if not specified
await pro.edit(message_text, parse_mode="markdown") # Explicitly setting parse_mode="markdown" |