Spaces:
Sleeping
Sleeping
teamx-cloner
commited on
Commit
·
64d78d6
1
Parent(s):
517af04
Create bsdk.py
Browse files- plugins/bsdk.py +135 -0
plugins/bsdk.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# UserBot
|
| 2 |
+
# Copyright (C) 2021-2023 Teamx-cloner
|
| 3 |
+
#
|
| 4 |
+
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
| 5 |
+
# PLease read the GNU Affero General Public License in
|
| 6 |
+
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
| 7 |
+
|
| 8 |
+
from . import get_help
|
| 9 |
+
|
| 10 |
+
__doc__ = get_help("help_bot")
|
| 11 |
+
|
| 12 |
+
import asyncio
|
| 13 |
+
import os
|
| 14 |
+
import sys
|
| 15 |
+
import time
|
| 16 |
+
from telethon import events, TelegramClient
|
| 17 |
+
from telethon.tl.functions import PingRequest
|
| 18 |
+
from secrets import choice
|
| 19 |
+
from telethon import Button
|
| 20 |
+
from xteam._misc import sudoers
|
| 21 |
+
from telethon.tl.types import InputMessagesFilterVideo, InputMessagesFilterVoice
|
| 22 |
+
from telethon.tl.types import InputMessagesFilterPhotos
|
| 23 |
+
from xteam.fns.custom_markdown import CustomMarkdown
|
| 24 |
+
from xteam.fns.helper import download_file, inline_mention
|
| 25 |
+
from ._inline import *
|
| 26 |
+
from xteam.fns.helper import inline_mention
|
| 27 |
+
from . import (
|
| 28 |
+
OWNER_NAME,
|
| 29 |
+
OWNER_ID,
|
| 30 |
+
BOT_NAME,
|
| 31 |
+
OWNER_USERNAME,
|
| 32 |
+
asst,
|
| 33 |
+
start_time,
|
| 34 |
+
time_formatter,
|
| 35 |
+
udB,
|
| 36 |
+
ultroid_cmd as xteam_cmd,
|
| 37 |
+
get_string,
|
| 38 |
+
ultroid_bot as client,
|
| 39 |
+
eor,
|
| 40 |
+
ultroid_bot,
|
| 41 |
+
call_back,
|
| 42 |
+
callback,
|
| 43 |
+
NOSPAM_CHAT as noU
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
PING = [
|
| 47 |
+
[ # First row of buttons (you can have multiple rows)
|
| 48 |
+
# InlineKeyboardButton("Button 1 Text", url="https://example.com/1"), # Example URL button
|
| 49 |
+
Button.inline("CLOSE", data="close"),
|
| 50 |
+
# InlineKeyboardButton("ᴘɪɴɢ", callback_data="close") # Example callback button
|
| 51 |
+
]
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
# markup = ReplyInlineMarkup(PING)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
async def mention_user(user_id):
|
| 58 |
+
try:
|
| 59 |
+
user_entity = await ultroid_bot.get_entity(user_id)
|
| 60 |
+
first_name = user_entity.first_name
|
| 61 |
+
mention_text = f"[{first_name}](tg://user?id={user_id})"
|
| 62 |
+
return mention_text
|
| 63 |
+
except Exception as e:
|
| 64 |
+
print(f"Failed to mention user: {e}")
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
@xteam_cmd(pattern="xping$", chats=[], type=["official", "assistant"])
|
| 68 |
+
async def _(event):
|
| 69 |
+
start = time.time()
|
| 70 |
+
x = await event.edit("ping")
|
| 71 |
+
end = round((time.time() - start) * 1000)
|
| 72 |
+
uptime = time_formatter((time.time() - start_time) * 1000)
|
| 73 |
+
await x.edit(f"**Pong!\n{end}ms**")
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@xteam_cmd(pattern="Ping$", chats=[], type=["official", "assistant"])
|
| 77 |
+
async def _(event):
|
| 78 |
+
noU.extend([-1001212184059, -1001451324102])
|
| 79 |
+
if event.chat_id in noU:# Check if chat_id is NOT in the database (assuming udB is a dictionary or similar)
|
| 80 |
+
await event.reply("Maaf, fitur ping tidak tersedia di obrolan ini.")
|
| 81 |
+
return
|
| 82 |
+
start = time.time()
|
| 83 |
+
x = await event.reply("Ping")
|
| 84 |
+
end = round((time.time() - start) * 1000)
|
| 85 |
+
uptime = time_formatter((time.time() - start_time) * 1000)
|
| 86 |
+
await x.edit(f"<blockquote>Pong !! {end}ms\nUptime - {uptime}</blockquote>", parse_mode="html")
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
@xteam_cmd(pattern="pingk")
|
| 90 |
+
async def wping(e):
|
| 91 |
+
chat_id = e.chat_id
|
| 92 |
+
if str(chat_id) not in udB: # Check if chat_id is NOT in the database
|
| 93 |
+
await e.respond("Maaf, fitur kping tidak tersedia di obrolan ini.")
|
| 94 |
+
return
|
| 95 |
+
try:
|
| 96 |
+
asupannya = [
|
| 97 |
+
asupan
|
| 98 |
+
async for asupan in e.client.iter_messages(
|
| 99 |
+
"@xcryasupan", filter=InputMessagesFilterVideo
|
| 100 |
+
)
|
| 101 |
+
]
|
| 102 |
+
|
| 103 |
+
if not asupannya:
|
| 104 |
+
await e.respond("No video found in @xcryasupan.")
|
| 105 |
+
return
|
| 106 |
+
|
| 107 |
+
start = time.time()
|
| 108 |
+
x = await e.respond("Pong!") # Use respond instead of eor for initial message
|
| 109 |
+
end = round((time.time() - start) * 1000)
|
| 110 |
+
uptime = time_formatter((time.time() - start_time) * 1000)
|
| 111 |
+
|
| 112 |
+
await e.client.send_file( # send_file is used for sending files with caption and buttons.
|
| 113 |
+
e.chat.id,
|
| 114 |
+
file=random.choice(asupannya),
|
| 115 |
+
caption=f"<blockquote> Ping : {end}ms\nUptime : {uptime}\nOwner :{OWNER_NAME}</blockquote>",
|
| 116 |
+
parse_mode="html",
|
| 117 |
+
buttons=Button.inline("• x •", "close"),
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
await x.delete() # delete the "pong" message after sending the video with caption.
|
| 121 |
+
|
| 122 |
+
except Exception as ex:
|
| 123 |
+
try:
|
| 124 |
+
await x.edit(f"**Ping Error:** {ex}")
|
| 125 |
+
except:
|
| 126 |
+
await e.respond(f"**Ping Error:** {ex}") # in case x was not defined.
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
@callback(data="close", owner=True)
|
| 130 |
+
async def on_plug_in_callback_query_handler(event):
|
| 131 |
+
await event.edit(
|
| 132 |
+
get_string("inline_5"),
|
| 133 |
+
buttons=Button.inline("OPEN", data="open"),
|
| 134 |
+
)
|
| 135 |
+
|