File size: 5,566 Bytes
056f521 |
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 |
# <============================================== IMPORTS =========================================================>
from time import gmtime, strftime, time
from pyrogram import filters
from pyrogram.types import Message
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import CallbackQueryHandler, CommandHandler, ContextTypes
from Mikobot import LOGGER, app, function
from Mikobot.plugins.helper_funcs.chat_status import check_admin
# <=======================================================================================================>
UPTIME = time() # Check bot uptime
# <================================================ FUNCTION =======================================================>
@app.on_message(filters.command("id"))
async def _id(client, message):
chat = message.chat
your_id = message.from_user.id
mention_user = message.from_user.mention
message_id = message.id
reply = message.reply_to_message
text = f"**๏ [ᴍᴇssᴀɢᴇ ɪᴅ]({message.link})** » `{message_id}`\n"
text += f"**๏ [{mention_user}](tg://user?id={your_id})** » `{your_id}`\n"
if not message.command:
message.command = message.text.split()
if not message.command:
message.command = message.text.split()
if len(message.command) == 2:
try:
split = message.text.split(None, 1)[1].strip()
user_id = (await client.get_users(split)).id
user_mention = (await client.get_users(split)).mention
text += f"**๏ [{user_mention}](tg://user?id={user_id})** » `{user_id}`\n"
except Exception:
return await message.reply_text("**🪄 ᴛʜɪs ᴜsᴇʀ ᴅᴏᴇsɴ'ᴛ ᴇxɪsᴛ.**")
text += f"**๏ [ᴄʜᴀᴛ ɪᴅ ](https://t.me/{chat.username})** » `{chat.id}`\n\n"
if (
not getattr(reply, "empty", True)
and not message.forward_from_chat
and not reply.sender_chat
):
text += f"**๏ [ʀᴇᴘʟɪᴇᴅ ᴍᴇssᴀɢᴇ ɪᴅ]({reply.link})** » `{message.reply_to_message.id}`\n"
text += f"**๏ [ʀᴇᴘʟɪᴇᴅ ᴜsᴇʀ ɪᴅ](tg://user?id={reply.from_user.id})** » `{reply.from_user.id}`\n\n"
if reply and reply.forward_from_chat:
text += f"๏ ᴛʜᴇ ғᴏʀᴡᴀʀᴅᴇᴅ ᴄʜᴀɴɴᴇʟ, {reply.forward_from_chat.title}, ʜᴀs ᴀɴ ɪᴅ ᴏғ `{reply.forward_from_chat.id}`\n\n"
if reply and reply.sender_chat:
text += f"๏ ID ᴏғ ᴛʜᴇ ʀᴇᴘʟɪᴇᴅ ᴄʜᴀᴛ/ᴄʜᴀɴɴᴇʟ, ɪs `{reply.sender_chat.id}`"
# Send sticker and text as a reply
sticker_id = (
"CAACAgIAAx0EdppwYAABAgotZg5rBL4P05Xjmy80p7DdNdneDmUAAnccAALIWZhJPyYLf3FzPHs0BA"
)
await message.reply_sticker(sticker=sticker_id)
await message.reply_text(text, disable_web_page_preview=True)
# Function to handle the "logs" command
@check_admin(only_dev=True)
async def logs(update: Update, context: ContextTypes.DEFAULT_TYPE):
user = update.effective_user
with open("Logs.txt", "rb") as f:
caption = "Here is your log"
reply_markup = InlineKeyboardMarkup(
[[InlineKeyboardButton("Close", callback_data="close")]]
)
message = await context.bot.send_document(
document=f,
filename=f.name,
caption=caption,
reply_markup=reply_markup,
chat_id=user.id,
)
# Store the message ID for later reference
context.user_data["log_message_id"] = message.message_id
# Asynchronous callback query handler for the "close" button
@check_admin(only_dev=True)
async def close_callback(update: Update, context: ContextTypes.DEFAULT_TYPE):
query = update.callback_query
message_id = context.user_data.get("log_message_id")
if message_id:
await context.bot.delete_message(
chat_id=query.message.chat_id, message_id=message_id
)
@app.on_message(filters.command("pyroping"))
async def ping(_, m: Message):
LOGGER.info(f"{m.from_user.id} used ping cmd in {m.chat.id}")
start = time()
replymsg = await m.reply_text(text="Pinging...", quote=True)
delta_ping = time() - start
up = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
image_url = "https://telegra.ph/file/e1049f371bbec3f006f3a.jpg"
# Send the image as a reply
await replymsg.reply_photo(
photo=image_url,
caption=f"<b>Pyro-Pong!</b>\n{delta_ping * 1000:.3f} ms\n\nUptime: <code>{up}</code>",
)
await replymsg.delete()
# <=======================================================================================================>
# <================================================ HANDLER =======================================================>
function(CommandHandler("logs", logs, block=False))
function(CallbackQueryHandler(close_callback, pattern="^close$", block=False))
# <================================================= HELP ======================================================>
__help__ = """
➠ *Commands*:
» /instadl, /insta <link>: Get instagram contents like reel video or images.
» /pyroping: see pyroping.
» /hyperlink <text> <link> : Creates a markdown hyperlink with the provided text and link.
» /pickwinner <participant1> <participant2> ... : Picks a random winner from the provided list of participants.
» /id: reply to get user id.
"""
__mod_name__ = "EXTRA"
# <================================================ END =======================================================>
|