id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
5,808 | import os
from telegraph import upload_file as uf
from telethon.utils import pack_bot_file_id
from pyUltroid.dB.greetings_db import (
add_goodbye,
add_thanks,
add_welcome,
delete_goodbye,
delete_welcome,
get_goodbye,
get_welcome,
must_thank,
remove_thanks,
)
from pyUltroid.fns.tools import create_tl_btn, format_btn, get_msg_button
from . import HNDLR, eor, get_string, mediainfo, ultroid_cmd
from ._inline import something
def get_goodbye(chat):
ok = get_stuff("GOODBYE")
return ok.get(chat)
from .. import *
def create_tl_btn(button: list):
btn = []
for z in button:
if len(z) > 1:
kk = [Button.url(x, y.strip()) for x, y in z]
btn.append(kk)
else:
btn.append([Button.url(z[0][0], z[0][1].strip())])
return btn
async def something(e, msg, media, button, reply=True, chat=None):
if e.client._bot:
return await e.reply(msg, file=media, buttons=button)
num = len(STUFF) + 1
STUFF.update({num: {"msg": msg, "media": media, "button": button}})
try:
res = await e.client.inline_query(asst.me.username, f"stf{num}")
return await res[0].click(
chat or e.chat_id,
reply_to=bool(isinstance(e, Message) and reply),
hide_via=True,
silent=True,
)
except Exception as er:
LOGS.exception(er)
async def listgd(event):
wel = get_goodbye(event.chat_id)
if not wel:
return await event.eor(get_string("grt_6"), time=5)
msgg = wel["goodbye"]
med = wel["media"]
if wel.get("button"):
btn = create_tl_btn(wel["button"])
return await something(event, msgg, med, btn)
await event.reply(f"**Goodbye Note in this chat**\n\n`{msgg}`", file=med)
await event.delete() | null |
5,809 | import os
from telegraph import upload_file as uf
from telethon.utils import pack_bot_file_id
from pyUltroid.dB.greetings_db import (
add_goodbye,
add_thanks,
add_welcome,
delete_goodbye,
delete_welcome,
get_goodbye,
get_welcome,
must_thank,
remove_thanks,
)
from pyUltroid.fns.tools import create_tl_btn, format_btn, get_msg_button
from . import HNDLR, eor, get_string, mediainfo, ultroid_cmd
from ._inline import something
def add_thanks(chat):
x = get_stuff("THANK_MEMBERS")
x.update({chat: True})
return udB.set_key("THANK_MEMBERS", x)
def remove_thanks(chat):
x = get_stuff("THANK_MEMBERS")
if x.get(chat):
x.pop(chat)
return udB.set_key("THANK_MEMBERS", x)
def must_thank(chat):
x = get_stuff("THANK_MEMBERS")
return x.get(chat)
async def thank_set(event):
type_ = event.pattern_match.group(1).strip()
if not type_ or type_ == "":
await eor(
event,
f"**Current Chat Settings:**\n**Thanking Members:** `{must_thank(event.chat_id)}`\n\nUse `{HNDLR}thankmembers on` or `{HNDLR}thankmembers off` to toggle current settings!",
)
return
chat = event.chat_id
if type_.lower() == "on":
add_thanks(chat)
elif type_.lower() == "off":
remove_thanks(chat)
await eor(
event,
f"**Done! Thank you members has been turned** `{type_.lower()}` **for this chat**!",
) | null |
5,810 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
Logm = KeyManager("LOGUSERS", cast=list)
async def _(e):
if not e.is_private:
return await e.eor("`Use me in Private.`", time=3)
if not Logm.contains(e.chat_id):
return await e.eor("`Wasn't logging msgs from here.`", time=3)
Logm.remove(e.chat_id)
return await e.eor("`Now I Will log msgs from here.`", time=3) | null |
5,811 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
Logm = KeyManager("LOGUSERS", cast=list)
async def _(e):
if not e.is_private:
return await e.eor("`Use me in Private.`", time=3)
if Logm.contains(e.chat_id):
return await e.eor("`Wasn't logging msgs from here.`", time=3)
Logm.add(e.chat_id)
return await e.eor("`Now I Won't log msgs from here.`", time=3) | null |
5,812 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
Logm = KeyManager("LOGUSERS", cast=list)
LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
if udB.get_key("PM_TEXT"):
UNAPPROVED_MSG = (
"**PMSecurity of {ON}!**\n\n"
+ udB.get_key("PM_TEXT")
+ "\n\nYou have {warn}/{twarn} warnings!"
)
if udB.get_key("PMLOG"):
pattern="logpm$",
)
)
)
if udB.get_key("PMSETTING"):
if udB.get_key("AUTOAPPROVE"):
events.NewMessage(
outgoing=True,
func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR),
),
)
events.NewMessage(
incoming=True,
func=lambda e: e.is_private
and e.sender_id not in DEVLIST
and not e.out
and not e.sender.bot
and not e.sender.is_self
and not e.sender.verified,
)
)
async def permitpm(event):
user = await event.get_sender()
if user.bot or user.is_self or user.verified or Logm.contains(user.id):
return
await event.forward_to(udB.get_key("PMLOGGROUP") or LOG_CHANNEL) | null |
5,813 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
keym = KeyManager("PMPERMIT", cast=list)
LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
_not_approved = {}
async def delete_pm_warn_msgs(chat: int):
try:
await _to_delete[chat].delete()
except KeyError:
pass
from .. import *
DEVLIST = [
719195224, # @xditya
1322549723, # @danish_00
1903729401, # @its_buddhhu
1303895686, # @Sipak_OP
611816596, # @Arnab431
1318486004, # @sppidy
803243487, # @hellboi_atul
]
async def autoappr(e):
miss = await e.get_chat()
if miss.bot or miss.is_self or miss.verified or miss.id in DEVLIST:
return
if keym.contains(miss.id):
return
keym.add(miss.id)
await delete_pm_warn_msgs(miss.id)
try:
await ultroid_bot.edit_folder(miss.id, folder=0)
except BaseException:
pass
try:
await asst.edit_message(
LOG_CHANNEL,
_not_approved[miss.id],
f"#AutoApproved : <b>OutGoing Message.\nUser : {inline_mention(miss, html=True)}</b> [<code>{miss.id}</code>]",
parse_mode="html",
)
except KeyError:
await asst.send_message(
LOG_CHANNEL,
f"#AutoApproved : <b>OutGoing Message.\nUser : {inline_mention(miss, html=True)}</b> [<code>{miss.id}</code>]",
parse_mode="html",
)
except MessageNotModifiedError:
pass | null |
5,814 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
COUNT_PM = {}
LASTMSG = {}
keym = KeyManager("PMPERMIT", cast=list)
PMPIC = udB.get_key("PMPIC")
UND = get_string("pmperm_1")
UNS = get_string("pmperm_2")
UNAPPROVED_MSG = "**PMSecurity of {ON}!**\n\n{UND}\n\nYou have {warn}/{twarn} warnings!"
if udB.get_key("PM_TEXT"):
UNAPPROVED_MSG = (
"**PMSecurity of {ON}!**\n\n"
+ udB.get_key("PM_TEXT")
+ "\n\nYou have {warn}/{twarn} warnings!"
)
WARNS = udB.get_key("PMWARNS") or 4
_not_approved = {}
_to_delete = {}
my_bot = asst.me.username
def update_pm(userid, message, warns_given):
try:
WARN_MSGS.update({userid: message})
except KeyError:
pass
try:
U_WARNS.update({userid: warns_given})
except KeyError:
pass
async def delete_pm_warn_msgs(chat: int):
try:
await _to_delete[chat].delete()
except KeyError:
pass
if udB.get_key("PMLOG"):
pattern="logpm$",
)
)
)
if udB.get_key("PMSETTING"):
if udB.get_key("AUTOAPPROVE"):
events.NewMessage(
outgoing=True,
func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR),
),
)
events.NewMessage(
incoming=True,
func=lambda e: e.is_private
and e.sender_id not in DEVLIST
and not e.out
and not e.sender.bot
and not e.sender.is_self
and not e.sender.verified,
)
)
async def permitpm(event):
inline_pm = Redis("INLINE_PM") or False
user = event.sender
if not keym.contains(user.id) and event.text != UND:
if Redis("MOVE_ARCHIVE"):
try:
await ultroid_bot.edit_folder(user.id, folder=1)
except BaseException as er:
LOGS.info(er)
if event.media and not udB.get_key("DISABLE_PMDEL"):
await event.delete()
name = user.first_name
fullname = get_display_name(user)
username = f"@{user.username}"
mention = inline_mention(user)
count = keym.count()
try:
wrn = COUNT_PM[user.id] + 1
await asst.edit_message(
udB.get_key("LOG_CHANNEL"),
_not_approved[user.id],
f"Incoming PM from **{mention}** [`{user.id}`] with **{wrn}/{WARNS}** warning!",
buttons=[
Button.inline("Approve PM", data=f"approve_{user.id}"),
Button.inline("Block PM", data=f"block_{user.id}"),
],
)
except KeyError:
_not_approved[user.id] = await asst.send_message(
udB.get_key("LOG_CHANNEL"),
f"Incoming PM from **{mention}** [`{user.id}`] with **1/{WARNS}** warning!",
buttons=[
Button.inline("Approve PM", data=f"approve_{user.id}"),
Button.inline("Block PM", data=f"block_{user.id}"),
],
)
wrn = 1
except MessageNotModifiedError:
wrn = 1
if user.id in LASTMSG:
prevmsg = LASTMSG[user.id]
if event.text != prevmsg:
if "PMSecurity" in event.text or "**PMSecurity" in event.text:
return
await delete_pm_warn_msgs(user.id)
message_ = UNAPPROVED_MSG.format(
ON=OWNER_NAME,
warn=wrn,
twarn=WARNS,
UND=UND,
name=name,
fullname=fullname,
username=username,
count=count,
mention=mention,
)
update_pm(user.id, message_, wrn)
if inline_pm:
results = await ultroid_bot.inline_query(
my_bot, f"ip_{user.id}"
)
try:
_to_delete[user.id] = await results[0].click(
user.id, reply_to=event.id, hide_via=True
)
except Exception as e:
LOGS.info(str(e))
elif PMPIC:
_to_delete[user.id] = await ultroid_bot.send_file(
user.id,
PMPIC,
caption=message_,
)
else:
_to_delete[user.id] = await ultroid_bot.send_message(
user.id, message_
)
else:
await delete_pm_warn_msgs(user.id)
message_ = UNAPPROVED_MSG.format(
ON=OWNER_NAME,
warn=wrn,
twarn=WARNS,
UND=UND,
name=name,
fullname=fullname,
username=username,
count=count,
mention=mention,
)
update_pm(user.id, message_, wrn)
if inline_pm:
try:
results = await ultroid_bot.inline_query(
my_bot, f"ip_{user.id}"
)
_to_delete[user.id] = await results[0].click(
user.id, reply_to=event.id, hide_via=True
)
except Exception as e:
LOGS.info(str(e))
elif PMPIC:
_to_delete[user.id] = await ultroid_bot.send_file(
user.id,
PMPIC,
caption=message_,
)
else:
_to_delete[user.id] = await ultroid_bot.send_message(
user.id, message_
)
LASTMSG.update({user.id: event.text})
else:
await delete_pm_warn_msgs(user.id)
message_ = UNAPPROVED_MSG.format(
ON=OWNER_NAME,
warn=wrn,
twarn=WARNS,
UND=UND,
name=name,
fullname=fullname,
username=username,
count=count,
mention=mention,
)
update_pm(user.id, message_, wrn)
if inline_pm:
try:
results = await ultroid_bot.inline_query(
my_bot, f"ip_{user.id}"
)
_to_delete[user.id] = await results[0].click(
user.id, reply_to=event.id, hide_via=True
)
except Exception as e:
LOGS.info(str(e))
elif PMPIC:
_to_delete[user.id] = await ultroid_bot.send_file(
user.id,
PMPIC,
caption=message_,
)
else:
_to_delete[user.id] = await ultroid_bot.send_message(
user.id, message_
)
LASTMSG.update({user.id: event.text})
if user.id not in COUNT_PM:
COUNT_PM.update({user.id: 1})
else:
COUNT_PM[user.id] = COUNT_PM[user.id] + 1
if COUNT_PM[user.id] >= WARNS:
await delete_pm_warn_msgs(user.id)
_to_delete[user.id] = await event.respond(UNS)
try:
del COUNT_PM[user.id]
del LASTMSG[user.id]
except KeyError:
await asst.send_message(
udB.get_key("LOG_CHANNEL"),
"PMPermit is messed! Pls restart the bot!!",
)
return LOGS.info("COUNT_PM is messed.")
await ultroid_bot(BlockRequest(user.id))
await ultroid_bot(ReportSpamRequest(peer=user.id))
await asst.edit_message(
udB.get_key("LOG_CHANNEL"),
_not_approved[user.id],
f"**{mention}** [`{user.id}`] was Blocked for spamming.",
) | null |
5,815 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
if udB.get_key("PM_TEXT"):
UNAPPROVED_MSG = (
"**PMSecurity of {ON}!**\n\n"
+ udB.get_key("PM_TEXT")
+ "\n\nYou have {warn}/{twarn} warnings!"
)
if udB.get_key("PMLOG"):
pattern="logpm$",
)
)
)
if udB.get_key("PMSETTING"):
if udB.get_key("AUTOAPPROVE"):
events.NewMessage(
outgoing=True,
func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR),
),
)
events.NewMessage(
incoming=True,
func=lambda e: e.is_private
and e.sender_id not in DEVLIST
and not e.out
and not e.sender.bot
and not e.sender.is_self
and not e.sender.verified,
)
)
async def _(e):
x = e.pattern_match.group(1).strip()
if x == "start":
udB.set_key("MOVE_ARCHIVE", "True")
await e.eor("Now I will move new Unapproved DM's to archive", time=5)
elif x == "stop":
udB.set_key("MOVE_ARCHIVE", "False")
await e.eor("Now I won't move new Unapproved DM's to archive", time=5)
elif x == "clear":
try:
await e.client.edit_folder(unpack=1)
await e.eor("Unarchived all chats", time=5)
except Exception as mm:
await e.eor(str(mm), time=5) | null |
5,816 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
keym = KeyManager("PMPERMIT", cast=list)
NO_REPLY = get_string("pmperm_3")
if udB.get_key("PM_TEXT"):
UNAPPROVED_MSG = (
"**PMSecurity of {ON}!**\n\n"
+ udB.get_key("PM_TEXT")
+ "\n\nYou have {warn}/{twarn} warnings!"
)
_not_approved = {}
async def delete_pm_warn_msgs(chat: int):
try:
await _to_delete[chat].delete()
except KeyError:
pass
if udB.get_key("PMLOG"):
pattern="logpm$",
)
)
)
if udB.get_key("PMSETTING"):
if udB.get_key("AUTOAPPROVE"):
events.NewMessage(
outgoing=True,
func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR),
),
)
events.NewMessage(
incoming=True,
func=lambda e: e.is_private
and e.sender_id not in DEVLIST
and not e.out
and not e.sender.bot
and not e.sender.is_self
and not e.sender.verified,
)
)
from .. import *
DEVLIST = [
719195224, # @xditya
1322549723, # @danish_00
1903729401, # @its_buddhhu
1303895686, # @Sipak_OP
611816596, # @Arnab431
1318486004, # @sppidy
803243487, # @hellboi_atul
]
async def approvepm(apprvpm):
if apprvpm.reply_to_msg_id:
user = (await apprvpm.get_reply_message()).sender
elif apprvpm.is_private:
user = await apprvpm.get_chat()
else:
return await apprvpm.edit(NO_REPLY)
if user.id in DEVLIST:
return await eor(
apprvpm,
"Lol, He is my Developer\nHe is auto Approved",
)
if not keym.contains(user.id):
keym.add(user.id)
try:
await delete_pm_warn_msgs(user.id)
await apprvpm.client.edit_folder(user.id, folder=0)
except BaseException:
pass
await eod(
apprvpm,
f"<b>{inline_mention(user, html=True)}</b> <code>approved to PM!</code>",
parse_mode="html",
)
try:
await asst.edit_message(
udB.get_key("LOG_CHANNEL"),
_not_approved[user.id],
f"#APPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was approved to PM you!</code>",
buttons=[
Button.inline("Disapprove PM", data=f"disapprove_{user.id}"),
Button.inline("Block", data=f"block_{user.id}"),
],
parse_mode="html",
)
except KeyError:
_not_approved[user.id] = await asst.send_message(
udB.get_key("LOG_CHANNEL"),
f"#APPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was approved to PM you!</code>",
buttons=[
Button.inline("Disapprove PM", data=f"disapprove_{user.id}"),
Button.inline("Block", data=f"block_{user.id}"),
],
parse_mode="html",
)
except MessageNotModifiedError:
pass
else:
await apprvpm.eor("`User may already be approved.`", time=5) | null |
5,817 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
keym = KeyManager("PMPERMIT", cast=list)
NO_REPLY = get_string("pmperm_3")
if udB.get_key("PM_TEXT"):
UNAPPROVED_MSG = (
"**PMSecurity of {ON}!**\n\n"
+ udB.get_key("PM_TEXT")
+ "\n\nYou have {warn}/{twarn} warnings!"
)
_not_approved = {}
if udB.get_key("PMLOG"):
pattern="logpm$",
)
)
)
if udB.get_key("PMSETTING"):
if udB.get_key("AUTOAPPROVE"):
events.NewMessage(
outgoing=True,
func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR),
),
)
events.NewMessage(
incoming=True,
func=lambda e: e.is_private
and e.sender_id not in DEVLIST
and not e.out
and not e.sender.bot
and not e.sender.is_self
and not e.sender.verified,
)
)
from .. import *
DEVLIST = [
719195224, # @xditya
1322549723, # @danish_00
1903729401, # @its_buddhhu
1303895686, # @Sipak_OP
611816596, # @Arnab431
1318486004, # @sppidy
803243487, # @hellboi_atul
]
async def disapprovepm(e):
if e.reply_to_msg_id:
user = (await e.get_reply_message()).sender
elif e.is_private:
user = await e.get_chat()
else:
return await e.edit(NO_REPLY)
if user.id in DEVLIST:
return await eor(
e,
"`Lol, He is my Developer\nHe Can't Be DisApproved.`",
)
if keym.contains(user.id):
keym.remove(user.id)
await eod(
e,
f"<b>{inline_mention(user, html=True)}</b> <code>Disapproved to PM!</code>",
parse_mode="html",
)
try:
await asst.edit_message(
udB.get_key("LOG_CHANNEL"),
_not_approved[user.id],
f"#DISAPPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was disapproved to PM you.</code>",
buttons=[
Button.inline("Approve PM", data=f"approve_{user.id}"),
Button.inline("Block", data=f"block_{user.id}"),
],
parse_mode="html",
)
except KeyError:
_not_approved[user.id] = await asst.send_message(
udB.get_key("LOG_CHANNEL"),
f"#DISAPPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was disapproved to PM you.</code>",
buttons=[
Button.inline("Approve PM", data=f"approve_{user.id}"),
Button.inline("Block", data=f"block_{user.id}"),
],
parse_mode="html",
)
except MessageNotModifiedError:
pass
else:
await eod(
e,
f"<b>{inline_mention(user, html=True)}</b> <code>was never approved!</code>",
parse_mode="html",
) | null |
5,818 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
keym = KeyManager("PMPERMIT", cast=list)
NO_REPLY = get_string("pmperm_3")
if udB.get_key("PM_TEXT"):
UNAPPROVED_MSG = (
"**PMSecurity of {ON}!**\n\n"
+ udB.get_key("PM_TEXT")
+ "\n\nYou have {warn}/{twarn} warnings!"
)
_not_approved = {}
if udB.get_key("PMLOG"):
pattern="logpm$",
)
)
)
if udB.get_key("PMSETTING"):
if udB.get_key("AUTOAPPROVE"):
events.NewMessage(
outgoing=True,
func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR),
),
)
events.NewMessage(
incoming=True,
func=lambda e: e.is_private
and e.sender_id not in DEVLIST
and not e.out
and not e.sender.bot
and not e.sender.is_self
and not e.sender.verified,
)
)
async def blockpm(block):
match = block.pattern_match.group(1).strip()
if block.reply_to_msg_id:
user = (await block.get_reply_message()).sender_id
elif match:
try:
user = await block.client.parse_id(match)
except Exception as er:
return await block.eor(str(er))
elif block.is_private:
user = block.chat_id
else:
return await eor(block, NO_REPLY, time=10)
await block.client(BlockRequest(user))
aname = await block.client.get_entity(user)
await block.eor(f"{inline_mention(aname)} [`{user}`] `has been blocked!`")
try:
keym.remove(user)
except AttributeError:
pass
try:
await asst.edit_message(
udB.get_key("LOG_CHANNEL"),
_not_approved[user],
f"#BLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **blocked**.",
buttons=[
Button.inline("UnBlock", data=f"unblock_{user}"),
],
)
except KeyError:
_not_approved[user] = await asst.send_message(
udB.get_key("LOG_CHANNEL"),
f"#BLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **blocked**.",
buttons=[
Button.inline("UnBlock", data=f"unblock_{user}"),
],
)
except MessageNotModifiedError:
pass | null |
5,819 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
NO_REPLY = get_string("pmperm_3")
if udB.get_key("PM_TEXT"):
UNAPPROVED_MSG = (
"**PMSecurity of {ON}!**\n\n"
+ udB.get_key("PM_TEXT")
+ "\n\nYou have {warn}/{twarn} warnings!"
)
_not_approved = {}
if udB.get_key("PMLOG"):
pattern="logpm$",
)
)
)
if udB.get_key("PMSETTING"):
if udB.get_key("AUTOAPPROVE"):
events.NewMessage(
outgoing=True,
func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR),
),
)
events.NewMessage(
incoming=True,
func=lambda e: e.is_private
and e.sender_id not in DEVLIST
and not e.out
and not e.sender.bot
and not e.sender.is_self
and not e.sender.verified,
)
)
async def unblockpm(event):
match = event.pattern_match.group(1).strip()
reply = await event.get_reply_message()
if reply:
user = reply.sender_id
elif match:
if match == "all":
msg = await event.eor(get_string("com_1"))
u_s = await event.client(GetBlockedRequest(0, 0))
count = len(u_s.users)
if not count:
return await eor(msg, "__You have not blocked Anyone...__")
for user in u_s.users:
await asyncio.sleep(1)
await event.client(UnblockRequest(user.id))
# GetBlockedRequest return 20 users at most.
if count < 20:
return await eor(msg, f"__Unblocked {count} Users!__")
while u_s.users:
u_s = await event.client(GetBlockedRequest(0, 0))
for user in u_s.users:
await asyncio.sleep(3)
await event.client(UnblockRequest(user.id))
count += len(u_s.users)
return await eor(msg, f"__Unblocked {count} users.__")
try:
user = await event.client.parse_id(match)
except Exception as er:
return await event.eor(str(er))
elif event.is_private:
user = event.chat_id
else:
return await event.eor(NO_REPLY, time=10)
try:
await event.client(UnblockRequest(user))
aname = await event.client.get_entity(user)
await event.eor(f"{inline_mention(aname)} [`{user}`] `has been UnBlocked!`")
except Exception as et:
return await event.eor(f"ERROR - {et}")
try:
await asst.edit_message(
udB.get_key("LOG_CHANNEL"),
_not_approved[user],
f"#UNBLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **unblocked**.",
buttons=[
Button.inline("Block", data=f"block_{user}"),
],
)
except KeyError:
_not_approved[user] = await asst.send_message(
udB.get_key("LOG_CHANNEL"),
f"#UNBLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **unblocked**.",
buttons=[
Button.inline("Block", data=f"block_{user}"),
],
)
except MessageNotModifiedError:
pass | null |
5,820 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
try:
from tabulate import tabulate
except ImportError:
tabulate = None
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
keym = KeyManager("PMPERMIT", cast=list)
async def list_approved(event):
xx = await event.eor(get_string("com_1"))
all = keym.get()
if not all:
return await xx.eor("`You haven't approved anyone yet!`", time=5)
users = []
for i in all:
try:
name = get_display_name(await ultroid_bot.get_entity(i))
except BaseException:
name = ""
users.append([name.strip(), str(i)])
with open("approved_pms.txt", "w") as list_appr:
if tabulate:
list_appr.write(
tabulate(users, headers=["UserName", "UserID"], showindex="always")
)
else:
text = "".join(f"[{user[-1]}] - {user[0]}" for user in users)
list_appr.write(text)
await event.reply(
f"List of users approved by [{OWNER_NAME}](tg://user?id={OWNER_ID})",
file="approved_pms.txt",
)
await xx.delete()
remove("approved_pms.txt") | null |
5,821 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
keym = KeyManager("PMPERMIT", cast=list)
async def delete_pm_warn_msgs(chat: int):
try:
await _to_delete[chat].delete()
except KeyError:
pass
from .. import *
DEVLIST = [
719195224, # @xditya
1322549723, # @danish_00
1903729401, # @its_buddhhu
1303895686, # @Sipak_OP
611816596, # @Arnab431
1318486004, # @sppidy
803243487, # @hellboi_atul
]
async def apr_in(event):
uid = int(event.data_match.group(1).decode("UTF-8"))
if uid in DEVLIST:
await event.edit("It's a dev! Approved!")
if not keym.contains(uid):
keym.add(uid)
try:
await ultroid_bot.edit_folder(uid, folder=0)
except BaseException:
pass
try:
user = await ultroid_bot.get_entity(uid)
except BaseException:
return await event.delete()
await event.edit(
f"#APPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was approved to PM you!</code>",
buttons=[
[
Button.inline("Disapprove PM", data=f"disapprove_{uid}"),
Button.inline("Block", data=f"block_{uid}"),
],
],
parse_mode="html",
)
await delete_pm_warn_msgs(uid)
await event.answer("Approved.", alert=True)
else:
await event.edit(
"`User may already be approved.`",
buttons=[
[
Button.inline("Disapprove PM", data=f"disapprove_{uid}"),
Button.inline("Block", data=f"block_{uid}"),
],
],
) | null |
5,822 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
keym = KeyManager("PMPERMIT", cast=list)
async def disapr_in(event):
uid = int(event.data_match.group(1).decode("UTF-8"))
if keym.contains(uid):
keym.remove(uid)
try:
user = await ultroid_bot.get_entity(uid)
except BaseException:
return await event.delete()
await event.edit(
f"#DISAPPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was disapproved to PM you!</code>",
buttons=[
[
Button.inline("Approve PM", data=f"approve_{uid}"),
Button.inline("Block", data=f"block_{uid}"),
],
],
parse_mode="html",
)
await event.answer("Disapproved.", alert=True)
else:
await event.edit(
"`User was never approved!`",
buttons=[
[
Button.inline("Disapprove PM", data=f"disapprove_{uid}"),
Button.inline("Block", data=f"block_{uid}"),
],
],
) | null |
5,823 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
async def blck_in(event):
uid = int(event.data_match.group(1).decode("UTF-8"))
try:
await ultroid_bot(BlockRequest(uid))
except BaseException:
pass
try:
user = await ultroid_bot.get_entity(uid)
except BaseException:
return await event.delete()
await event.edit(
f"BLOCKED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was blocked!</code>",
buttons=Button.inline("UnBlock", data=f"unblock_{uid}"),
parse_mode="html",
)
await event.answer("Blocked.", alert=True) | null |
5,824 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
async def unblck_in(event):
uid = int(event.data_match.group(1).decode("UTF-8"))
try:
await ultroid_bot(UnblockRequest(uid))
except BaseException:
pass
try:
user = await ultroid_bot.get_entity(uid)
except BaseException:
return await event.delete()
await event.edit(
f"#UNBLOCKED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was unblocked!</code>",
buttons=Button.inline("Block", data=f"block_{uid}"),
parse_mode="html",
)
await event.answer("Unblocked.", alert=True) | null |
5,825 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
async def ytfuxist(e):
try:
await e.answer("Deleted.")
await e.delete()
except BaseException:
await ultroid_bot.delete_messages(e.chat_id, e.id) | null |
5,826 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
WARN_MSGS = {}
U_WARNS = {}
PMPIC = udB.get_key("PMPIC")
WARNS = udB.get_key("PMWARNS") or 4
async def in_pm_ans(event):
from_user = int(event.pattern_match.group(1).strip())
try:
warns = U_WARNS[from_user]
except Exception as e:
LOGS.info(e)
warns = "?"
try:
msg_ = WARN_MSGS[from_user]
except KeyError:
msg_ = "**PMSecurity of {OWNER_NAME}**"
wrns = f"{warns}/{WARNS}"
buttons = [
[
Button.inline("Warns", data=f"admin_only{from_user}"),
Button.inline(wrns, data=f"don_{wrns}"),
]
]
include_media = True
mime_type, res = None, None
cont = None
try:
ext = PMPIC.split(".")[-1].lower()
except (AttributeError, IndexError):
ext = None
if ext in ["img", "jpg", "png"]:
_type = "photo"
mime_type = "image/jpg"
elif ext in ["mp4", "mkv", "gif"]:
mime_type = "video/mp4"
_type = "gif"
else:
try:
res = resolve_bot_file_id(PMPIC)
except ValueError:
pass
if res:
res = [
await event.builder.document(
res,
title="Inline PmPermit",
description="~ @TeamUltroid",
text=msg_,
buttons=buttons,
link_preview=False,
)
]
else:
_type = "article"
include_media = False
if not res:
if include_media:
cont = types.InputWebDocument(PMPIC, 0, mime_type, [])
res = [
event.builder.article(
title="Inline PMPermit.",
type=_type,
text=msg_,
description="@TeamUltroid",
include_media=include_media,
buttons=buttons,
thumb=cont,
content=cont,
)
]
await event.answer(res, switch_pm="• Ultroid •", switch_pm_param="start") | null |
5,827 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
async def _admin_tools(event):
chat = int(event.pattern_match.group(1).strip())
await event.edit(
buttons=[
[
Button.inline("Approve PM", data=f"approve_{chat}"),
Button.inline("Block PM", data=f"block_{chat}"),
],
[Button.inline("« Back", data=f"pmbk_{chat}")],
],
) | null |
5,828 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
async def _mejik(e):
data = e.pattern_match.group(1).strip().decode("utf-8").split("/")
text = "👮♂ Warn Count : " + data[0]
text += "\n🤖 Total Warn Count : " + data[1]
await e.answer(text, alert=True) | null |
5,829 | import asyncio
import re
from os import remove
from pyUltroid.dB import DEVLIST
from telethon import events
from telethon.errors import MessageNotModifiedError
from telethon.tl.functions.contacts import (
BlockRequest,
GetBlockedRequest,
UnblockRequest,
)
from telethon.tl.functions.messages import ReportSpamRequest
from telethon.utils import get_display_name, resolve_bot_file_id
from pyUltroid.dB.base import KeyManager
from . import *
U_WARNS = {}
WARNS = udB.get_key("PMWARNS") or 4
async def edt(event):
from_user = int(event.pattern_match.group(1).strip())
try:
warns = U_WARNS[from_user]
except Exception as e:
LOGS.info(str(e))
warns = "0"
wrns = f"{warns}/{WARNS}"
await event.edit(
buttons=[
[
Button.inline("Warns", data=f"admin_only{from_user}"),
Button.inline(wrns, data=f"don_{wrns}"),
]
],
) | null |
5,830 | from telethon.tl.functions.channels import GetFullChannelRequest as getchat
from telethon.tl.functions.phone import CreateGroupCallRequest as startvc
from telethon.tl.functions.phone import DiscardGroupCallRequest as stopvc
from telethon.tl.functions.phone import EditGroupCallTitleRequest as settitle
from telethon.tl.functions.phone import GetGroupCallRequest as getvc
from telethon.tl.functions.phone import InviteToGroupCallRequest as invitetovc
from . import get_string, ultroid_cmd
async def get_call(event):
async def _(e):
try:
await e.client(stopvc(await get_call(e)))
await e.eor(get_string("vct_4"))
except Exception as ex:
await e.eor(f"`{ex}`") | null |
5,831 | from telethon.tl.functions.channels import GetFullChannelRequest as getchat
from telethon.tl.functions.phone import CreateGroupCallRequest as startvc
from telethon.tl.functions.phone import DiscardGroupCallRequest as stopvc
from telethon.tl.functions.phone import EditGroupCallTitleRequest as settitle
from telethon.tl.functions.phone import GetGroupCallRequest as getvc
from telethon.tl.functions.phone import InviteToGroupCallRequest as invitetovc
from . import get_string, ultroid_cmd
async def get_call(event):
mm = await event.client(getchat(event.chat_id))
xx = await event.client(getvc(mm.full_chat.call, limit=1))
return xx.call
def user_list(l, n):
for i in range(0, len(l), n):
yield l[i : i + n]
pattern="stopvc$",
admins_only=True,
groups_only=True,
async def _(e):
ok = await e.eor(get_string("vct_3"))
users = []
z = 0
async for x in e.client.iter_participants(e.chat_id):
if not x.bot:
users.append(x.id)
hmm = list(user_list(users, 6))
for p in hmm:
try:
await e.client(invitetovc(call=await get_call(e), users=p))
z += 6
except BaseException:
pass
await ok.edit(get_string("vct_5").format(z)) | null |
5,832 | from telethon.tl.functions.channels import GetFullChannelRequest as getchat
from telethon.tl.functions.phone import CreateGroupCallRequest as startvc
from telethon.tl.functions.phone import DiscardGroupCallRequest as stopvc
from telethon.tl.functions.phone import EditGroupCallTitleRequest as settitle
from telethon.tl.functions.phone import GetGroupCallRequest as getvc
from telethon.tl.functions.phone import InviteToGroupCallRequest as invitetovc
from . import get_string, ultroid_cmd
async def _(e):
try:
await e.client(startvc(e.chat_id))
await e.eor(get_string("vct_1"))
except Exception as ex:
await e.eor(f"`{ex}`") | null |
5,833 | from telethon.tl.functions.channels import GetFullChannelRequest as getchat
from telethon.tl.functions.phone import CreateGroupCallRequest as startvc
from telethon.tl.functions.phone import DiscardGroupCallRequest as stopvc
from telethon.tl.functions.phone import EditGroupCallTitleRequest as settitle
from telethon.tl.functions.phone import GetGroupCallRequest as getvc
from telethon.tl.functions.phone import InviteToGroupCallRequest as invitetovc
from . import get_string, ultroid_cmd
async def get_call(event):
mm = await event.client(getchat(event.chat_id))
xx = await event.client(getvc(mm.full_chat.call, limit=1))
return xx.call
async def _(e):
title = e.pattern_match.group(1).strip()
if not title:
return await e.eor(get_string("vct_6"), time=5)
try:
await e.client(settitle(call=await get_call(e), title=title.strip()))
await e.eor(get_string("vct_2").format(title))
except Exception as ex:
await e.eor(f"`{ex}`") | null |
5,834 | import asyncio
import os
import random
from random import shuffle
from telethon.tl.functions.photos import UploadProfilePhotoRequest
from pyUltroid.fns.helper import download_file
from pyUltroid.fns.tools import get_google_images
from . import LOGS, get_help, get_string, udB, ultroid_bot, ultroid_cmd
if search := udB.get_key("AUTOPIC"):
images = {}
sleep = udB.get_key("SLEEP_TIME") or 1221
try:
from apscheduler.schedulers.asyncio import AsyncIOScheduler
schedule = AsyncIOScheduler()
schedule.add_job(autopic_func, "interval", seconds=sleep)
schedule.start()
except ModuleNotFoundError as er:
LOGS.error(f"autopic: '{er.name}' not installed.")
async def autopic(e):
search = e.pattern_match.group(1).strip()
if udB.get_key("AUTOPIC") and not search:
udB.del_key("AUTOPIC")
return await e.eor(get_string("autopic_5"))
if not search:
return await e.eor(get_string("autopic_1"), time=5)
e = await e.eor(get_string("com_1"))
gi = googleimagesdownload()
args = {
"keywords": search,
"limit": 50,
"format": "jpg",
"output_directory": "./resources/downloads/",
}
try:
pth = await gi.download(args)
ok = pth[0][search]
except Exception as er:
LOGS.exception(er)
return await e.eor(str(er))
if not ok:
return await e.eor(get_string("autopic_2").format(search), time=5)
await e.eor(get_string("autopic_3").format(search))
udB.set_key("AUTOPIC", search)
SLEEP_TIME = udB.get_key("SLEEP_TIME") or 1221
while True:
for lie in ok:
if udB.get_key("AUTOPIC") != search:
return
file = await e.client.upload_file(lie)
await e.client(UploadProfilePhotoRequest(file))
await asyncio.sleep(SLEEP_TIME)
shuffle(ok) | null |
5,835 | import asyncio
import os
import random
from random import shuffle
from telethon.tl.functions.photos import UploadProfilePhotoRequest
from pyUltroid.fns.helper import download_file
from pyUltroid.fns.tools import get_google_images
from . import LOGS, get_help, get_string, udB, ultroid_bot, ultroid_cmd
if search := udB.get_key("AUTOPIC"):
images = {}
sleep = udB.get_key("SLEEP_TIME") or 1221
try:
from apscheduler.schedulers.asyncio import AsyncIOScheduler
schedule = AsyncIOScheduler()
schedule.add_job(autopic_func, "interval", seconds=sleep)
schedule.start()
except ModuleNotFoundError as er:
LOGS.error(f"autopic: '{er.name}' not installed.")
from . import *
async def download_file(link, name, validate=False):
from .. import *
async def get_google_images(query):
async def autopic_func():
search = udB.get_key("AUTOPIC")
if images.get(search) is None:
images[search] = await get_google_images(search)
if not images.get(search):
return
img = random.choice(images[search])
filee = await download_file(img["original"], "resources/downloads/autopic.jpg")
file = await ultroid_bot.upload_file(filee)
await ultroid_bot(UploadProfilePhotoRequest(file))
os.remove(filee) | null |
5,836 | from . import get_help
from pyUltroid.fns.tools import get_chatbot_reply
from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd
from .. import *
async def get_chatbot_reply(message):
chatbot_base = "https://kuki-api-lac.vercel.app/message={}"
req_link = chatbot_base.format(
message,
)
try:
return (await async_searcher(req_link, re_json=True)).get("reply")
except Exception:
LOGS.info(f"**ERROR:**`{format_exc()}`")
async def im_lonely_chat_with_me(event):
if event.reply_to:
message = (await event.get_reply_message()).message
else:
try:
message = event.text.split(" ", 1)[1]
except IndexError:
return await eod(event, get_string("tban_1"), time=10)
reply_ = await get_chatbot_reply(message=message)
await event.eor(reply_) | null |
5,837 | from . import get_help
from pyUltroid.fns.tools import get_chatbot_reply
from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd
async def chat_bot_fn(event, type_):
if event.reply_to:
user_ = (await event.get_reply_message()).sender
else:
temp = event.text.split(maxsplit=1)
try:
user_ = await event.client.get_entity(await event.client.parse_id(temp[1]))
except BaseException as er:
LOGS.exception(er)
user_ = event.chat if event.is_private else None
if not user_:
return await eod(
event,
get_string("chab_1"),
)
key = udB.get_key("CHATBOT_USERS") or {}
chat = event.chat_id
user = user_.id
if type_ == "add":
if key.get(chat):
if user not in key[chat]:
key[chat].append(user)
else:
key.update({chat: [user]})
elif type_ == "remov":
if key.get(chat):
if user in key[chat]:
key[chat].remove(user)
if chat in key and not key[chat]:
del key[chat]
udB.set_key("CHATBOT_USERS", key)
await event.eor(f"**ChatBot:**\n{type_}ed {inline_mention(user_)}")
async def add_chatBot(event):
await chat_bot_fn(event, type_="add") | null |
5,838 | from . import get_help
from pyUltroid.fns.tools import get_chatbot_reply
from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd
async def chat_bot_fn(event, type_):
if event.reply_to:
user_ = (await event.get_reply_message()).sender
else:
temp = event.text.split(maxsplit=1)
try:
user_ = await event.client.get_entity(await event.client.parse_id(temp[1]))
except BaseException as er:
LOGS.exception(er)
user_ = event.chat if event.is_private else None
if not user_:
return await eod(
event,
get_string("chab_1"),
)
key = udB.get_key("CHATBOT_USERS") or {}
chat = event.chat_id
user = user_.id
if type_ == "add":
if key.get(chat):
if user not in key[chat]:
key[chat].append(user)
else:
key.update({chat: [user]})
elif type_ == "remov":
if key.get(chat):
if user in key[chat]:
key[chat].remove(user)
if chat in key and not key[chat]:
del key[chat]
udB.set_key("CHATBOT_USERS", key)
await event.eor(f"**ChatBot:**\n{type_}ed {inline_mention(user_)}")
async def rem_chatBot(event):
await chat_bot_fn(event, type_="remov") | null |
5,839 | from . import get_help
from pyUltroid.fns.tools import get_chatbot_reply
from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd
async def lister(event):
key = udB.get_key("CHATBOT_USERS") or {}
users = key.get(event.chat_id, [])
if not users:
return await event.eor(get_string("chab_2"), time=5)
msg = "**Total List Of AI Enabled Users In This Chat :**\n\n"
for i in users:
try:
user = await event.client.get_entity(int(i))
user = inline_mention(user)
except BaseException:
user = f"`{i}`"
msg += f"• {user}\n"
await event.eor(msg, link_preview=False) | null |
5,840 | import re
from telethon.errors.rpcerrorlist import ChatAdminRequiredError, UserNotParticipantError
from telethon.tl.custom import Button
from telethon.tl.functions.channels import GetParticipantRequest
from telethon.tl.functions.messages import ExportChatInviteRequest
from telethon.tl.types import (
Channel,
ChannelParticipantBanned,
ChannelParticipantLeft,
User,
)
from pyUltroid.dB.forcesub_db import add_forcesub, get_forcesetting, rem_forcesub
from . import (
LOGS,
asst,
callback,
events,
get_string,
in_pattern,
inline_mention,
udB,
ultroid_bot,
ultroid_cmd,
)
async def force_sub(ult):
def add_forcesub(chat_id, chattojoin):
async def addfor(e):
match = e.pattern_match.group(1).strip()
if not match:
return await e.eor(get_string("fsub_1"), time=5)
try:
match = await e.client.parse_id(match)
except BaseException:
return await e.eor(get_string("fsub_2"), time=5)
add_forcesub(e.chat_id, match)
await e.eor("Added ForceSub in This Chat !")
ultroid_bot.add_handler(force_sub, events.NewMessage(incoming=True)) | null |
5,841 | import re
from telethon.errors.rpcerrorlist import ChatAdminRequiredError, UserNotParticipantError
from telethon.tl.custom import Button
from telethon.tl.functions.channels import GetParticipantRequest
from telethon.tl.functions.messages import ExportChatInviteRequest
from telethon.tl.types import (
Channel,
ChannelParticipantBanned,
ChannelParticipantLeft,
User,
)
from pyUltroid.dB.forcesub_db import add_forcesub, get_forcesetting, rem_forcesub
from . import (
LOGS,
asst,
callback,
events,
get_string,
in_pattern,
inline_mention,
udB,
ultroid_bot,
ultroid_cmd,
)
def rem_forcesub(chat_id):
omk = get_chats()
if chat_id in omk.keys():
try:
del omk[chat_id]
return udB.set_key("FORCESUB", omk)
except KeyError:
return False
async def remor(e):
res = rem_forcesub(e.chat_id)
if not res:
return await e.eor(get_string("fsub_3"), time=5)
await e.eor("Removed ForceSub...") | null |
5,842 | import re
from telethon.errors.rpcerrorlist import ChatAdminRequiredError, UserNotParticipantError
from telethon.tl.custom import Button
from telethon.tl.functions.channels import GetParticipantRequest
from telethon.tl.functions.messages import ExportChatInviteRequest
from telethon.tl.types import (
Channel,
ChannelParticipantBanned,
ChannelParticipantLeft,
User,
)
from pyUltroid.dB.forcesub_db import add_forcesub, get_forcesetting, rem_forcesub
from . import (
LOGS,
asst,
callback,
events,
get_string,
in_pattern,
inline_mention,
udB,
ultroid_bot,
ultroid_cmd,
)
def get_forcesetting(chat_id):
omk = get_chats()
if chat_id in omk.keys():
return omk[chat_id]
async def getfsr(e):
res = get_forcesetting(e.chat_id)
if not res:
return await e.eor("ForceSub is Not Active In This Chat !", time=5)
cha = await e.client.get_entity(int(res))
await e.eor(f"**ForceSub Status** : `Active`\n- **{cha.title}** `({res})`") | null |
5,843 | import re
from telethon.errors.rpcerrorlist import ChatAdminRequiredError, UserNotParticipantError
from telethon.tl.custom import Button
from telethon.tl.functions.channels import GetParticipantRequest
from telethon.tl.functions.messages import ExportChatInviteRequest
from telethon.tl.types import (
Channel,
ChannelParticipantBanned,
ChannelParticipantLeft,
User,
)
from pyUltroid.dB.forcesub_db import add_forcesub, get_forcesetting, rem_forcesub
from . import (
LOGS,
asst,
callback,
events,
get_string,
in_pattern,
inline_mention,
udB,
ultroid_bot,
ultroid_cmd,
)
async def fcall(e):
match = e.pattern_match.group(1).strip()
spli = match.split("_")
user = await ultroid_bot.get_entity(int(spli[0]))
cl = await ultroid_bot.get_entity(int(spli[1]))
text = f"Hi {inline_mention(user)}, You Need to Join"
text += f" {cl.title} in order to Chat in this Group."
el = (
f"https://t.me/{cl.username}"
if cl.username
else (await ultroid_bot(ExportChatInviteRequest(cl))).link
)
res = [
await e.builder.article(
title="forcesub",
text=text,
buttons=[
[Button.url(text=get_string("fsub_4"), url=el)],
[Button.inline(get_string("fsub_5"), data=f"unm_{match}")],
],
)
]
await e.answer(res) | null |
5,844 | import re
from telethon.errors.rpcerrorlist import ChatAdminRequiredError, UserNotParticipantError
from telethon.tl.custom import Button
from telethon.tl.functions.channels import GetParticipantRequest
from telethon.tl.functions.messages import ExportChatInviteRequest
from telethon.tl.types import (
Channel,
ChannelParticipantBanned,
ChannelParticipantLeft,
User,
)
from pyUltroid.dB.forcesub_db import add_forcesub, get_forcesetting, rem_forcesub
from . import (
LOGS,
asst,
callback,
events,
get_string,
in_pattern,
inline_mention,
udB,
ultroid_bot,
ultroid_cmd,
)
async def diesoon(e):
match = (e.data_match.group(1)).decode("UTF-8")
spli = match.split("_")
if e.sender_id != int(spli[0]):
return await e.answer(get_string("fsub_7"), alert=True)
try:
values = await ultroid_bot(GetParticipantRequest(int(spli[1]), int(spli[0])))
if isinstance(values.participant, ChannelParticipantLeft) or (
isinstance(values.participant, ChannelParticipantBanned) and values.left
):
raise UserNotParticipantError("")
except UserNotParticipantError:
return await e.answer(
"Please Join That Channel !\nThen Click This Button !", alert=True
)
await ultroid_bot.edit_permissions(
e.chat_id, int(spli[0]), send_messages=True, until_date=None
)
await e.edit(get_string("fsub_8")) | null |
5,845 | from telethon.tl.types import User
from pyUltroid._misc import sudoers
from . import get_string, inline_mention, udB, ultroid_bot, ultroid_cmd
from .. import *
sudoers = SUDO_M.get_sudos
async def _(ult):
inputs = ult.pattern_match.group(1).strip()
if ult.reply_to_msg_id:
replied_to = await ult.get_reply_message()
id = replied_to.sender_id
name = await replied_to.get_sender()
elif inputs:
try:
id = await ult.client.parse_id(inputs)
except ValueError:
try:
id = int(inputs)
except ValueError:
id = inputs
try:
name = await ult.client.get_entity(int(id))
except BaseException:
name = None
elif ult.is_private:
id = ult.chat_id
name = await ult.get_chat()
else:
return await ult.eor(get_string("sudo_1"), time=5)
if name and isinstance(name, User) and (name.bot or name.verified):
return await ult.eor(get_string("sudo_4"))
name = inline_mention(name) if name else f"`{id}`"
if id == ultroid_bot.uid:
mmm = get_string("sudo_2")
elif id in sudoers():
mmm = f"{name} `is already a SUDO User ...`"
else:
udB.set_key("SUDO", "True")
key = sudoers()
key.append(id)
udB.set_key("SUDOS", key)
mmm = f"**Added** {name} **as SUDO User**"
await ult.eor(mmm, time=5) | null |
5,846 | from telethon.tl.types import User
from pyUltroid._misc import sudoers
from . import get_string, inline_mention, udB, ultroid_bot, ultroid_cmd
from .. import *
sudoers = SUDO_M.get_sudos
async def _(ult):
inputs = ult.pattern_match.group(1).strip()
if ult.reply_to_msg_id:
replied_to = await ult.get_reply_message()
id = replied_to.sender_id
name = await replied_to.get_sender()
elif inputs:
try:
id = await ult.client.parse_id(inputs)
except ValueError:
try:
id = int(inputs)
except ValueError:
id = inputs
try:
name = await ult.client.get_entity(int(id))
except BaseException:
name = None
elif ult.is_private:
id = ult.chat_id
name = await ult.get_chat()
else:
return await ult.eor(get_string("sudo_1"), time=5)
name = inline_mention(name) if name else f"`{id}`"
if id not in sudoers():
mmm = f"{name} `wasn't a SUDO User ...`"
else:
key = sudoers()
key.remove(id)
udB.set_key("SUDOS", key)
mmm = f"**Removed** {name} **from SUDO User(s)**"
await ult.eor(mmm, time=5) | null |
5,847 | from telethon.tl.types import User
from pyUltroid._misc import sudoers
from . import get_string, inline_mention, udB, ultroid_bot, ultroid_cmd
from .. import *
sudoers = SUDO_M.get_sudos
async def _(ult):
sudos = sudoers()
if not sudos:
return await ult.eor(get_string("sudo_3"), time=5)
msg = ""
for i in sudos:
try:
name = await ult.client.get_entity(int(i))
except BaseException:
name = None
if name:
msg += f"• {inline_mention(name)} ( `{i}` )\n"
else:
msg += f"• `{i}` -> Invalid User\n"
m = udB.get_key("SUDO") or True
if not m:
m = "[False](https://graph.org/Ultroid-04-06)"
return await ult.eor(
f"**SUDO MODE : {m}\n\nList of SUDO Users :**\n{msg}", link_preview=False
) | null |
5,848 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
from .. import *
def translate(*args, **kwargs):
headers = {
"Referer": "https://translate.google.co.in",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/47.0.2526.106 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
}
x = requests.post(
"https://translate.google.co.in/_/TranslateWebserverUi/data/batchexecute",
headers=headers,
data=_package_rpc(*args, **kwargs),
).text
response = ""
data = json.loads(json.loads(x[4:])[0][2])[1][0][0]
subind = data[-2]
if not subind:
subind = data[-1]
for i in subind:
response += i[0]
return response
async def _(event):
input = event.pattern_match.group(1).strip().split(maxsplit=1)
txt = input[1] if len(input) > 1 else None
if input:
input = input[0]
if txt:
text = txt
elif event.is_reply:
previous_message = await event.get_reply_message()
text = previous_message.message
else:
return await eor(
event, f"`{HNDLR}tr LanguageCode` as reply to a message", time=5
)
lan = input or "en"
try:
tt = translate(text, lang_tgt=lan)
output_str = f"**TRANSLATED** to {lan}\n{tt}"
await event.eor(output_str)
except Exception as exc:
LOGS.exception(exc)
await event.eor(str(exc), time=5) | null |
5,849 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
async def _(event):
ult = event
match = event.pattern_match.group(1).strip()
if match:
try:
ids = await event.client.parse_id(match)
except Exception as er:
return await event.eor(str(er))
return await event.eor(
f"**Chat ID:** `{event.chat_id}`\n**User ID:** `{ids}`"
)
data = f"**Current Chat ID:** `{event.chat_id}`"
if event.reply_to_msg_id:
event = await event.get_reply_message()
data += f"\n**From User ID:** `{event.sender_id}`"
if event.media:
bot_api_file_id = event.file.id
data += f"\n**Bot API File ID:** `{bot_api_file_id}`"
data += f"\n**Msg ID:** `{event.id}`"
await ult.eor(data) | null |
5,850 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
async def _(ult):
mentions = "• **Bots in this Chat**: \n"
if input_str := ult.pattern_match.group(1).strip():
mentions = f"• **Bots in **{input_str}: \n"
try:
chat = await ult.client.parse_id(input_str)
except Exception as e:
return await ult.eor(str(e))
else:
chat = ult.chat_id
try:
async for x in ult.client.iter_participants(
chat,
filter=ChannelParticipantsBots,
):
if isinstance(x.participant, ChannelParticipantAdmin):
mentions += f"\n⚜️ {inline_mention(x)} `{x.id}`"
else:
mentions += f"\n• {inline_mention(x)} `{x.id}`"
except Exception as e:
mentions += f" {str(e)}" + "\n"
await ult.eor(mentions) | null |
5,851 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
async def _(ult):
input_ = ult.pattern_match.group(1).strip()
if not input_:
return await ult.eor("`Input some link`", time=5)
text = None
if len(input_.split()) > 1:
spli_ = input_.split()
input_ = spli_[0]
text = spli_[1]
if not text:
text = "ㅤㅤㅤㅤㅤㅤㅤ"
await ult.eor(f"[{text}]({input_})", link_preview=False) | null |
5,852 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
try:
import cv2
except ImportError:
cv2 = None
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
from .. import *
async def metadata(file):
out, _ = await bash(f'mediainfo "{_unquote_text(file)}" --Output=JSON')
if _ and _.endswith("NOT_FOUND"):
raise DependencyMissingError(
f"'{_}' is not installed!\nInstall it to use this command."
)
data = {}
_info = json.loads(out)["media"]["track"]
info = _info[0]
if info.get("Format") in ["GIF", "PNG"]:
return {
"height": _info[1]["Height"],
"width": _info[1]["Width"],
"bitrate": _info[1].get("BitRate", 320),
}
if info.get("AudioCount"):
data["title"] = info.get("Title", file)
data["performer"] = info.get("Performer") or udB.get_key("artist") or ""
if info.get("VideoCount"):
data["height"] = int(float(_info[1].get("Height", 720)))
data["width"] = int(float(_info[1].get("Width", 1280)))
data["bitrate"] = int(_info[1].get("BitRate", 320))
data["duration"] = int(float(info.get("Duration", 0)))
return data
async def _(e):
reply = await e.get_reply_message()
if not (reply and reply.media):
return await e.eor("`Reply to a gif or audio file only.`")
if "audio" in mediainfo(reply.media):
msg = await e.eor("`Downloading...`")
try:
bbbb = await reply.download_media(thumb=-1)
except TypeError:
bbbb = ULTConfig.thumb
im = cv2.imread(bbbb)
dsize = (512, 512)
output = cv2.resize(im, dsize, interpolation=cv2.INTER_AREA)
cv2.imwrite("img.jpg", output)
thumb = "img.jpg"
audio, _ = await e.client.fast_downloader(reply.document)
await msg.edit("`Creating video note...`")
await bash(
f'ffmpeg -i "{thumb}" -i "{audio.name}" -preset ultrafast -c:a libmp3lame -ab 64 circle.mp4 -y'
)
await msg.edit("`Uploading...`")
data = await metadata("circle.mp4")
file, _ = await e.client.fast_uploader("circle.mp4", to_delete=True)
await e.client.send_file(
e.chat_id,
file,
thumb=thumb,
reply_to=reply,
attributes=[
DocumentAttributeVideo(
duration=min(data["duration"], 60),
w=512,
h=512,
round_message=True,
)
],
)
await msg.delete()
[os.remove(k) for k in [audio.name, thumb]]
elif mediainfo(reply.media) == "gif" or mediainfo(reply.media).startswith("video"):
msg = await e.eor("**Creating video note**")
file = await reply.download_media("resources/downloads/")
if file.endswith(".webm"):
nfile = await con.ffmpeg_convert(file, "file.mp4")
os.remove(file)
file = nfile
if file:
await e.client.send_file(
e.chat_id,
file,
video_note=True,
thumb=ULTConfig.thumb,
reply_to=reply,
)
os.remove(file)
await msg.delete()
else:
await e.eor("`Reply to a gif or audio file only.`") | null |
5,853 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
FilesEMOJI = {
"py": "🐍",
"json": "🔮",
("sh", "bat"): "⌨️",
(".mkv", ".mp4", ".avi", ".gif", "webm"): "🎥",
(".mp3", ".ogg", ".m4a", ".opus"): "🔊",
(".jpg", ".jpeg", ".png", ".webp", ".ico"): "🖼",
(".txt", ".text", ".log"): "📄",
(".apk", ".xapk"): "📲",
(".pdf", ".epub"): "📗",
(".zip", ".rar"): "🗜",
(".exe", ".iso"): "⚙",
}
async def _(e):
files = e.pattern_match.group(1).strip()
if not files:
files = "*"
elif files.endswith("/"):
files += "*"
elif "*" not in files:
files += "/*"
files = glob.glob(files)
if not files:
return await e.eor("`Directory Empty or Incorrect.`", time=5)
folders = []
allfiles = []
for file in sorted(files):
if os.path.isdir(file):
folders.append(f"📂 {file}")
else:
for ext in FilesEMOJI.keys():
if file.endswith(ext):
allfiles.append(f"{FilesEMOJI[ext]} {file}")
break
else:
if "." in str(file)[1:]:
allfiles.append(f"🏷 {file}")
else:
allfiles.append(f"📒 {file}")
omk = [*sorted(folders), *sorted(allfiles)]
text = ""
fls, fos = 0, 0
flc, foc = 0, 0
for i in omk:
try:
emoji = i.split()[0]
name = i.split(maxsplit=1)[1]
nam = name.split("/")[-1]
if os.path.isdir(name):
size = 0
for path, dirs, files in os.walk(name):
for f in files:
fp = os.path.join(path, f)
size += os.path.getsize(fp)
if hb(size):
text += f"{emoji} `{nam}` `{hb(size)}" + "`\n"
fos += size
else:
text += f"{emoji} `{nam}`" + "\n"
foc += 1
else:
if hb(int(os.path.getsize(name))):
text += (
emoji
+ f" `{nam}`"
+ " `"
+ hb(int(os.path.getsize(name)))
+ "`\n"
)
fls += int(os.path.getsize(name))
else:
text += f"{emoji} `{nam}`" + "\n"
flc += 1
except BaseException:
pass
tfos, tfls, ttol = hb(fos), hb(fls), hb(fos + fls)
if not hb(fos):
tfos = "0 B"
if not hb(fls):
tfls = "0 B"
if not hb(fos + fls):
ttol = "0 B"
text += f"\n\n`Folders` : `{foc}` : `{tfos}`\n`Files` : `{flc}` : `{tfls}`\n`Total` : `{flc+foc}` : `{ttol}`"
try:
if (flc + foc) > 100:
text = text.replace("`", "")
await e.eor(text)
except MessageTooLongError:
with io.BytesIO(str.encode(text)) as out_file:
out_file.name = "output.txt"
await e.reply(f"`{e.text}`", file=out_file, thumb=ULTConfig.thumb)
await e.delete() | null |
5,854 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
async def lastname(steal):
mat = steal.pattern_match.group(1).strip()
message = await steal.get_reply_message()
if mat:
try:
user_id = await steal.client.parse_id(mat)
except ValueError:
user_id = mat
elif message:
user_id = message.sender_id
else:
return await steal.eor("`Use this command with reply or give Username/id...`")
chat = "@SangMataInfo_bot"
id = f"/search_id {user_id}"
lol = await steal.eor(get_string("com_1"))
try:
async with steal.client.conversation(chat) as conv:
try:
msg = await conv.send_message(id)
response = await conv.get_response()
respond = await conv.get_response()
responds = await conv.get_response()
except YouBlockedUserError:
return await lol.edit("Please unblock @sangmatainfo_bot and try again")
if (
(response and response.text == "No records found")
or (respond and respond.text == "No records found")
or (responds and responds.text == "No records found")
):
await lol.edit("No records found for this user")
await steal.client.delete_messages(conv.chat_id, [msg.id, response.id])
elif response.text.startswith("🔗"):
await lol.edit(respond.message)
await lol.reply(responds.message)
elif respond.text.startswith("🔗"):
await lol.edit(response.message)
await lol.reply(responds.message)
else:
await lol.edit(respond.message)
await lol.reply(response.message)
await steal.client.delete_messages(
conv.chat_id,
[msg.id, responds.id, respond.id, response.id],
)
except AsyncTimeout:
await lol.edit("Error: @SangMataInfo_bot is not responding!.") | null |
5,855 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
try:
from playwright.async_api import async_playwright
except ImportError:
async_playwright = None
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
async def webss(event):
xx = await event.eor(get_string("com_1"))
xurl = event.pattern_match.group(1).strip()
if not xurl:
return await xx.eor(get_string("wbs_1"), time=5)
if not (await is_url_ok(xurl)):
return await xx.eor(get_string("wbs_2"), time=5)
path, pic = check_filename("shot.png"), None
if async_playwright:
try:
async with async_playwright() as playwright:
chrome = await playwright.chromium.launch()
page = await chrome.new_page()
await page.goto(xurl)
await page.screenshot(path=path, full_page=True)
pic = path
except Exception as er:
LOGS.exception(er)
await xx.respond(f"Error with playwright:\n`{er}`")
if WebShot and not pic:
try:
shot = WebShot(
quality=88, flags=["--enable-javascript", "--no-stop-slow-scripts"]
)
pic = await shot.create_pic_async(url=xurl)
except Exception as er:
LOGS.exception(er)
if not pic:
pic, msg = await download_file(
f"https://shot.screenshotapi.net/screenshot?&url={xurl}&output=image&file_type=png&wait_for_event=load",
path,
validate=True,
)
if msg:
await xx.edit(json_parser(msg, indent=1))
return
if pic:
await xx.reply(
get_string("wbs_3").format(xurl),
file=pic,
link_preview=False,
force_document=True,
)
os.remove(pic)
await xx.delete() | null |
5,856 | import glob
import io
import os
import secrets
from asyncio.exceptions import TimeoutError as AsyncTimeout
from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
from telethon.tl.types import (
ChannelParticipantAdmin,
ChannelParticipantsBots,
DocumentAttributeVideo,
)
from pyUltroid.fns.tools import metadata, translate
from . import (
HNDLR,
LOGS,
ULTConfig,
async_searcher,
bash,
check_filename,
con,
download_file,
eor,
get_string,
)
from . import humanbytes as hb
from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
async def magic(event):
try:
match = event.text.split(maxsplit=1)[1].strip()
except IndexError:
return await event.eor("`Provide url to turn into tiny...`")
data = {
"url": match.split()[0],
"id": match[1] if len(match) > 1 else secrets.token_urlsafe(6),
}
data = await async_searcher(
"https://tiny.ultroid.tech/api/new",
data=data,
post=True,
re_json=True,
)
response = data.get("response", {})
if not response.get("status"):
return await event.eor(f'**ERROR :** `{response["message"]}`')
await event.eor(
f"• **Ultroid Tiny**\n• Given Url : {url}\n• Shorten Url : {data['response']['tinyUrl']}"
) | null |
5,857 | import os
from telethon.tl.functions.account import UpdateProfileRequest
from telethon.tl.functions.photos import DeletePhotosRequest, UploadProfilePhotoRequest
from . import eod, eor, get_string, mediainfo, ultroid_cmd
async def _(ult):
ok = await ult.eor("...")
set = ult.pattern_match.group(1).strip()
try:
await ult.client(UpdateProfileRequest(about=set))
await eod(ok, f"Profile bio changed to\n`{set}`")
except Exception as ex:
await eod(ok, f"Error occured.\n`{str(ex)}`") | null |
5,858 | import os
from telethon.tl.functions.account import UpdateProfileRequest
from telethon.tl.functions.photos import DeletePhotosRequest, UploadProfilePhotoRequest
from . import eod, eor, get_string, mediainfo, ultroid_cmd
async def _(ult):
ok = await ult.eor("...")
names = first_name = ult.pattern_match.group(1).strip()
last_name = ""
if "//" in names:
first_name, last_name = names.split("//", 1)
try:
await ult.client(
UpdateProfileRequest(
first_name=first_name,
last_name=last_name,
),
)
await eod(ok, f"Name changed to `{names}`")
except Exception as ex:
await eod(ok, f"Error occured.\n`{str(ex)}`") | null |
5,859 | import os
from telethon.tl.functions.account import UpdateProfileRequest
from telethon.tl.functions.photos import DeletePhotosRequest, UploadProfilePhotoRequest
from . import eod, eor, get_string, mediainfo, ultroid_cmd
async def _(ult):
if not ult.is_reply:
return await ult.eor("`Reply to a Media..`", time=5)
reply_message = await ult.get_reply_message()
ok = await ult.eor(get_string("com_1"))
replfile = await reply_message.download_media()
file = await ult.client.upload_file(replfile)
try:
if "pic" in mediainfo(reply_message.media):
await ult.client(UploadProfilePhotoRequest(file=file))
else:
await ult.client(UploadProfilePhotoRequest(video=file))
await eod(ok, "`My Profile Photo has Successfully Changed !`")
except Exception as ex:
await eod(ok, f"Error occured.\n`{str(ex)}`")
os.remove(replfile) | null |
5,860 | import os
from telethon.tl.functions.account import UpdateProfileRequest
from telethon.tl.functions.photos import DeletePhotosRequest, UploadProfilePhotoRequest
from . import eod, eor, get_string, mediainfo, ultroid_cmd
async def remove_profilepic(delpfp):
ok = await eor(delpfp, "`...`")
group = delpfp.text[8:]
if group == "all":
lim = 0
elif group.isdigit():
lim = int(group)
else:
lim = 1
pfplist = await delpfp.client.get_profile_photos("me", limit=lim)
await delpfp.client(DeletePhotosRequest(pfplist))
await eod(ok, f"`Successfully deleted {len(pfplist)} profile picture(s).`") | null |
5,861 | import os
from telethon.tl.functions.account import UpdateProfileRequest
from telethon.tl.functions.photos import DeletePhotosRequest, UploadProfilePhotoRequest
from . import eod, eor, get_string, mediainfo, ultroid_cmd
async def gpoto(e):
ult = e.pattern_match.group(1).strip()
if e.is_reply:
gs = await e.get_reply_message()
user_id = gs.sender_id
elif ult:
split = ult.split()
user_id = split[0]
if len(ult) > 1:
ult = ult[-1]
else:
ult = None
else:
user_id = e.chat_id
a = await e.eor(get_string("com_1"))
limit = None
just_dl = ult in ["-dl", "--dl"]
if just_dl:
ult = None
if ult and ult != "all":
try:
limit = int(ult)
except ValueError:
pass
if not limit or e.client._bot:
okla = await e.client.download_profile_photo(user_id)
else:
okla = []
if limit == "all":
limit = None
async for photo in e.client.iter_profile_photos(user_id, limit=limit):
photo_path = await e.client.download_media(photo)
if photo.video_sizes:
await e.respond(file=photo_path)
os.remove(photo_path)
else:
okla.append(photo_path)
if not okla:
return await eor(a, "`Pfp Not Found...`")
if not just_dl:
await a.delete()
await e.reply(file=okla)
if not isinstance(okla, list):
okla = [okla]
for file in okla:
os.remove(file)
return
if isinstance(okla, list):
okla = "\n".join(okla)
await a.edit(f"Downloaded pfp to [ `{okla}` ].") | null |
5,862 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def get_uinfo(e):
user, data = None, None
reply = await e.get_reply_message()
if reply:
user = await e.client.get_entity(reply.sender_id)
data = e.pattern_match.group(1)
else:
ok = e.pattern_match.group(1).split(maxsplit=1)
if len(ok) > 1:
data = ok[1]
try:
user = await e.client.get_entity(await e.client.parse_id(ok[0]))
except IndexError:
pass
except ValueError as er:
await e.eor(str(er))
return None, None
return user, data
async def prmte(ult):
xx = await ult.eor(get_string("com_1"))
user, rank = await get_uinfo(ult)
rank = rank or "Admin"
FullRight = False
if not user:
return await xx.edit(get_string("pro_1"))
if rank.split()[0] == "-f":
try:
rank = rank.split(maxsplit=1)[1]
except IndexError:
rank = "Admin"
FullRight = True
try:
if FullRight:
await ult.client(
EditAdminRequest(ult.chat_id, user.id, ult.chat.admin_rights, rank)
)
else:
await ult.client.edit_admin(
ult.chat_id,
user.id,
invite_users=True,
ban_users=True,
delete_messages=True,
pin_messages=True,
manage_call=True,
title=rank,
)
await eod(
xx, get_string("pro_2").format(inline_mention(user), ult.chat.title, rank)
)
except Exception as ex:
return await xx.edit(f"`{ex}`") | null |
5,863 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def get_uinfo(e):
user, data = None, None
reply = await e.get_reply_message()
if reply:
user = await e.client.get_entity(reply.sender_id)
data = e.pattern_match.group(1)
else:
ok = e.pattern_match.group(1).split(maxsplit=1)
if len(ok) > 1:
data = ok[1]
try:
user = await e.client.get_entity(await e.client.parse_id(ok[0]))
except IndexError:
pass
except ValueError as er:
await e.eor(str(er))
return None, None
return user, data
async def dmote(ult):
xx = await ult.eor(get_string("com_1"))
user, rank = await get_uinfo(ult)
if not rank:
rank = "Not Admin"
if not user:
return await xx.edit(get_string("de_1"))
try:
await ult.client.edit_admin(
ult.chat_id,
user.id,
invite_users=None,
ban_users=None,
delete_messages=None,
pin_messages=None,
manage_call=None,
title=rank,
)
await eod(xx, get_string("de_2").format(inline_mention(user), ult.chat.title))
except Exception as ex:
return await xx.edit(f"`{ex}`") | null |
5,864 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
from .. import *
DEVLIST = [
719195224, # @xditya
1322549723, # @danish_00
1903729401, # @its_buddhhu
1303895686, # @Sipak_OP
611816596, # @Arnab431
1318486004, # @sppidy
803243487, # @hellboi_atul
]
async def get_uinfo(e):
user, data = None, None
reply = await e.get_reply_message()
if reply:
user = await e.client.get_entity(reply.sender_id)
data = e.pattern_match.group(1)
else:
ok = e.pattern_match.group(1).split(maxsplit=1)
if len(ok) > 1:
data = ok[1]
try:
user = await e.client.get_entity(await e.client.parse_id(ok[0]))
except IndexError:
pass
except ValueError as er:
await e.eor(str(er))
return None, None
return user, data
async def bban(ult):
something = await get_uinfo(ult)
if not something:
return
user, reason = something
if not user:
return await eod(ult, get_string("ban_1"))
if user.id in DEVLIST:
return await eod(ult, get_string("ban_2"))
try:
await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=False)
except UserIdInvalidError:
return await eod(ult, get_string("adm_1"))
except BadRequestError:
return await eod(ult, get_string("ban_3"))
senderme = inline_mention(await ult.get_sender())
userme = inline_mention(user)
text = get_string("ban_4").format(userme, senderme, ult.chat.title)
if reason:
text += get_string("ban_5").format(reason)
await eod(ult, text) | null |
5,865 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def get_uinfo(e):
user, data = None, None
reply = await e.get_reply_message()
if reply:
user = await e.client.get_entity(reply.sender_id)
data = e.pattern_match.group(1)
else:
ok = e.pattern_match.group(1).split(maxsplit=1)
if len(ok) > 1:
data = ok[1]
try:
user = await e.client.get_entity(await e.client.parse_id(ok[0]))
except IndexError:
pass
except ValueError as er:
await e.eor(str(er))
return None, None
return user, data
async def uunban(ult):
xx = await ult.eor(get_string("com_1"))
if ult.text[1:].startswith("unbanall"):
return
something = await get_uinfo(ult)
if not something:
return
user, reason = something
if not user:
return await xx.edit(get_string("unban_1"))
try:
await ult.client.edit_permissions(ult.chat_id, user.id, view_messages=True)
except UserIdInvalidError:
return await eod(ult, get_string("adm_1"))
except BadRequestError:
return await xx.edit(get_string("adm_2"))
sender = inline_mention(await ult.get_sender())
text = get_string("unban_3").format(inline_mention(user), sender, ult.chat.title)
if reason:
text += get_string("ban_5").format(reason)
await xx.edit(text) | null |
5,866 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
from .. import *
DEVLIST = [
719195224, # @xditya
1322549723, # @danish_00
1903729401, # @its_buddhhu
1303895686, # @Sipak_OP
611816596, # @Arnab431
1318486004, # @sppidy
803243487, # @hellboi_atul
]
async def get_uinfo(e):
user, data = None, None
reply = await e.get_reply_message()
if reply:
user = await e.client.get_entity(reply.sender_id)
data = e.pattern_match.group(1)
else:
ok = e.pattern_match.group(1).split(maxsplit=1)
if len(ok) > 1:
data = ok[1]
try:
user = await e.client.get_entity(await e.client.parse_id(ok[0]))
except IndexError:
pass
except ValueError as er:
await e.eor(str(er))
return None, None
return user, data
async def kck(ult):
if "kickme" in ult.text:
return
if ult.is_private:
return await ult.eor("`Use this in Group/Channel.`", time=5)
ml = ult.text.split(" ", maxsplit=1)[0]
xx = await ult.eor(get_string("com_1"))
something = await get_uinfo(ult)
if not something:
return
user, reason = something
if not user:
return await xx.edit(get_string("adm_1"))
if user.id in DEVLIST:
return await xx.edit(get_string("kick_2"))
if getattr(user, "is_self", False):
return await xx.edit(get_string("kick_3"))
try:
await ult.client.kick_participant(ult.chat_id, user.id)
except BadRequestError as er:
LOGS.info(er)
return await xx.edit(get_string("kick_1"))
except Exception as e:
LOGS.exception(e)
return
text = get_string("kick_4").format(
inline_mention(user), inline_mention(await ult.get_sender()), ult.chat.title
)
if reason:
text += get_string("ban_5").format(reason)
await xx.edit(text) | null |
5,867 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
def ban_time(time_str):
"""Simplify ban time from text"""
if not any(time_str.endswith(unit) for unit in ("s", "m", "h", "d")):
time_str += "s"
unit = time_str[-1]
time_int = time_str[:-1]
if not time_int.isdigit():
raise Exception("Invalid time amount specified.")
to_return = ""
if unit == "s":
to_return = int(time.time() + int(time_int))
elif unit == "m":
to_return = int(time.time() + int(time_int) * 60)
elif unit == "h":
to_return = int(time.time() + int(time_int) * 60 * 60)
elif unit == "d":
to_return = int(time.time() + int(time_int) * 24 * 60 * 60)
return to_return
async def tkicki(e):
huh = e.text.split()
inputt = None
try:
tme = huh[1]
except IndexError:
return await e.eor(get_string("adm_3"), time=15)
try:
inputt = huh[2]
except IndexError:
if e.reply_to_msg_id:
inputt = (await e.get_reply_message()).sender_id
if not inputt:
return await e.eor(get_string("tban_1"))
userid = await e.client.parse_id(inputt)
try:
user = await e.client.get_entity(userid)
except Exception as ex:
return await eor(e, f"`{ex}`")
try:
bun = ban_time(tme)
await e.client.edit_permissions(
e.chat_id, user.id, until_date=bun, view_messages=False
)
await eod(
e,
get_string("tban_2").format(inline_mention(user), e.chat.title, tme),
time=15,
)
except Exception as m:
return await e.eor(str(m)) | null |
5,868 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def pin_message(ult):
match = ult.pattern_match.group(1).strip()
if not ult.is_reply:
return await ult.eor("`Reply to message..`", time=6)
if not match:
return await ult.eor("`Please provide time..`", time=8)
msg = await ult.eor(get_string("com_1"))
msg_id = ult.reply_to_msg_id
try:
time = ban_time(match)
await ult.client.pin_message(ult.chat_id, msg_id)
await msg.eor(f"`pinned for time` `{time}`", time=8)
except Exception as er:
return await msg.edit(str(er))
await asyncio.sleep(time)
try:
await ult.client.unpin_message(ult.chat_id, msg_id)
except Exception as er:
LOGS.exception(er)
async def pin(msg):
if not msg.is_reply:
return await eor(msg, get_string("pin_1"))
me = await msg.get_reply_message()
if me.is_private:
text = "`Pinned.`"
else:
text = f"Pinned [This Message]({me.message_link}) !"
try:
await msg.client.pin_message(msg.chat_id, me.id, notify=False)
except BadRequestError:
return await eor(msg, get_string("adm_2"))
except Exception as e:
return await eor(msg, f"**ERROR:**`{e}`")
await eor(msg, text) | null |
5,869 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def unp(ult):
xx = await ult.eor(get_string("com_1"))
ch = (ult.pattern_match.group(1).strip()).strip()
msg = None
if ult.is_reply:
msg = ult.reply_to_msg_id
elif ch != "all":
return await xx.edit(get_string("unpin_1").format(HNDLR))
try:
await ult.client.unpin_message(ult.chat_id, msg)
except BadRequestError:
return await xx.edit(get_string("adm_2"))
except Exception as e:
return await xx.edit(f"**ERROR:**`{e}`")
await xx.edit("`Unpinned!`") | null |
5,870 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def fastpurger(purg):
match = purg.pattern_match.group(1).strip()
try:
ABC = purg.text[6]
except IndexError:
ABC = None
if ABC and purg.text[6] in ["m", "a"]:
return
if not purg._client._bot and (
(match)
or (purg.is_reply and (purg.is_private or isinstance(purg.chat, types.Chat)))
):
p = 0
async for msg in purg.client.iter_messages(
purg.chat_id,
limit=int(match) if match else None,
min_id=purg.reply_to_msg_id if purg.is_reply else None,
):
await msg.delete()
p += 0
return await eor(purg, f"Purged {p} Messages! ", time=5)
if not purg.reply_to_msg_id:
return await eor(purg, get_string("purge_1"), time=10)
try:
await purg.client.delete_messages(
purg.chat_id, list(range(purg.reply_to_msg_id, purg.id))
)
except Exception as er:
LOGS.info(er)
await purg.eor("__Fast purge complete!__", time=5) | null |
5,871 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def fastpurgerme(purg):
if num := purg.pattern_match.group(1).strip():
try:
nnt = int(num)
except BaseException:
await eor(purg, get_string("com_3"), time=5)
return
mp = 0
async for mm in purg.client.iter_messages(
purg.chat_id, limit=nnt, from_user="me"
):
await mm.delete()
mp += 1
await eor(purg, f"Purged {mp} Messages!", time=5)
return
elif not purg.reply_to_msg_id:
return await eod(
purg,
"`Reply to a message to purge from or use it like ``purgeme <num>`",
time=10,
)
chat = await purg.get_input_chat()
msgs = []
async for msg in purg.client.iter_messages(
chat,
from_user="me",
min_id=purg.reply_to_msg_id,
):
msgs.append(msg)
if msgs:
await purg.client.delete_messages(chat, msgs)
await purg.eor(
"__Fast purge complete!__\n**Purged** `" + str(len(msgs)) + "` **messages.**",
time=5,
) | null |
5,872 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def _(e):
if not e.is_reply:
return await eod(
e,
get_string("purgeall_1"),
)
msg = await e.get_reply_message()
name = msg.sender
try:
await e.client.delete_messages(e.chat_id, from_user=msg.sender_id)
await e.eor(get_string("purgeall_2").format(name.first_name), time=5)
except Exception as er:
return await e.eor(str(er), time=5) | null |
5,873 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def djshsh(event):
chat = await event.get_chat()
if isinstance(chat, types.Chat):
FChat = await event.client(GetFullChatRequest(chat.id))
elif isinstance(chat, types.Channel):
FChat = await event.client(GetFullChannelRequest(chat.id))
else:
return
msg_id = FChat.full_chat.pinned_msg_id
if not msg_id:
return await event.eor(get_string("pinned_1"))
msg = await event.client.get_messages(chat.id, ids=msg_id)
if msg:
await event.eor(get_string("pinned_2").format(msg.message_link)) | null |
5,874 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def get_all_pinned(event):
x = await event.eor(get_string("com_1"))
chat_id = (str(event.chat_id)).replace("-100", "")
chat_name = get_display_name(event.chat)
a = ""
c = 1
async for i in event.client.iter_messages(
event.chat_id, filter=InputMessagesFilterPinned
):
if i.message:
t = " ".join(i.message.split()[:4])
txt = f"{t}...."
else:
txt = "Go to message."
a += f"{c}. <a href=https://t.me/c/{chat_id}/{i.id}>{txt}</a>\n"
c += 1
if c == 1:
m = f"<b>The pinned message in {chat_name}:</b>\n\n"
else:
m = f"<b>List of pinned message(s) in {chat_name}:</b>\n\n"
if not a:
return await eor(x, get_string("listpin_1"), time=5)
await x.edit(m + a, parse_mode="html") | null |
5,875 | from . import get_help
import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest, GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from pyUltroid.dB import DEVLIST
from pyUltroid.fns.admins import ban_time
from pyUltroid.fns.info import get_uinfo
from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
async def autodelte(ult):
match = ult.pattern_match.group(1).strip()
if not match or match not in ["24h", "7d", "1m", "off"]:
return await ult.eor("`Please Use in Proper Format..`", time=5)
if match == "24h":
tt = 3600 * 24
elif match == "7d":
tt = 3600 * 24 * 7
elif match == "1m":
tt = 3600 * 24 * 31
else:
tt = 0
try:
await ult.client(SetHistoryTTLRequest(ult.chat_id, period=tt))
except ChatNotModifiedError:
return await ult.eor(
f"Auto Delete Setting is Already same to `{match}`", time=5
)
await ult.eor(f"Auto Delete Status Changed to `{match}` !") | null |
5,876 | from . import HNDLR, eod, get_string, ultroid_cmd
async def _(e):
async def dm(e):
if len(e.text.split()) <= 1:
return await e.eor(get_string("dm_1"), time=5)
chat = e.text.split()[1]
try:
chat_id = await e.client.parse_id(chat)
except Exception as ex:
return await e.eor(f"`{ex}`", time=5)
if len(e.text.split()) > 2:
msg = e.text.split(maxsplit=2)[2]
elif e.reply_to:
msg = await e.get_reply_message()
else:
return await e.eor(get_string("dm_2"), time=5)
try:
_ = await e.client.send_message(chat_id, msg)
n_, time = get_string("dm_3"), None
if not _.is_private:
n_ = f"[{n_}]({_.message_link})"
await e.eor(n_, time=time)
except Exception as m:
await e.eor(get_string("dm_4").format(m, HNDLR), time=5) | null |
5,877 | from . import HNDLR, eod, get_string, ultroid_cmd
async def saf(e):
x = await e.get_reply_message()
if not x:
return await eod(
e, "Reply to Any Message to save it to ur saved messages", time=5
)
if e.pattern_match.group(1).strip() == "f":
await x.forward_to(e.sender_id)
else:
await e.client.send_message(e.sender_id, x)
await e.eor("Message saved to Your Pm/Saved Messages.", time=5) | null |
5,878 | import glob
import os
import random
from telethon.tl.types import InputMessagesFilterPhotos
from pyUltroid.fns.misc import unsplashsearch
from pyUltroid.fns.tools import LogoHelper
from . import OWNER_ID, OWNER_NAME, download_file, get_string, mediainfo, ultroid_cmd
from .. import *
async def unsplashsearch(query, limit=None, shuf=True):
query = query.replace(" ", "-")
link = "https://unsplash.com/s/photos/" + query
extra = await async_searcher(link, re_content=True)
res = BeautifulSoup(extra, "html.parser", from_encoding="utf-8")
all_ = res.find_all("img", srcset=re.compile("images.unsplash.com/photo"))
if shuf:
shuffle(all_)
return list(map(lambda e: e['src'], all_[:limit]))
from .. import *
class LogoHelper:
def get_text_size(text, image, font):
im = Image.new("RGB", (image.width, image.height))
draw = ImageDraw.Draw(im)
return draw.textsize(text, font)
def find_font_size(text, font, image, target_width_ratio):
tested_font_size = 100
tested_font = ImageFont.truetype(font, tested_font_size)
observed_width, observed_height = LogoHelper.get_text_size(
text, image, tested_font
)
estimated_font_size = (
tested_font_size / (observed_width / image.width) * target_width_ratio
)
return round(estimated_font_size)
def make_logo(imgpath, text, funt, **args):
fill = args.get("fill")
width_ratio = args.get("width_ratio") or 0.7
stroke_width = int(args.get("stroke_width"))
stroke_fill = args.get("stroke_fill")
img = Image.open(imgpath)
width, height = img.size
draw = ImageDraw.Draw(img)
font_size = LogoHelper.find_font_size(text, funt, img, width_ratio)
font = ImageFont.truetype(funt, font_size)
w, h = draw.textsize(text, font=font)
draw.text(
((width - w) / 2, (height - h) / 2),
text,
font=font,
fill=fill,
stroke_width=stroke_width,
stroke_fill=stroke_fill,
)
file_name = check_filename("logo.png")
img.save(file_name, "PNG")
return file_name
async def logo_gen(event):
xx = await event.eor(get_string("com_1"))
name = event.pattern_match.group(1).strip()
if not name:
return await xx.eor("`Give a name too!`", time=5)
bg_, font_ = None, None
if event.reply_to_msg_id:
temp = await event.get_reply_message()
if temp.media:
if hasattr(temp.media, "document") and (
("font" in temp.file.mime_type)
or (".ttf" in temp.file.name)
or (".otf" in temp.file.name)
):
font_ = await temp.download_media("resources/fonts/")
elif "pic" in mediainfo(temp.media):
bg_ = await temp.download_media()
if not bg_:
if event.client._bot:
SRCH = [
"blur background",
"background",
"neon lights",
"nature",
"abstract",
"space",
"3d render",
]
res = await unsplashsearch(random.choice(SRCH), limit=1)
bg_, _ = await download_file(res[0], "resources/downloads/logo.png")
newimg = "resources/downloads/unsplash-temp.jpg"
img_ = Image.open(bg_)
img_.resize((5000, 5000)).save(newimg)
os.remove(bg_)
bg_ = newimg
else:
pics = []
async for i in event.client.iter_messages(
"@UltroidLogos", filter=InputMessagesFilterPhotos
):
pics.append(i)
id_ = random.choice(pics)
bg_ = await id_.download_media()
if not font_:
fpath_ = glob.glob("resources/fonts/*")
font_ = random.choice(fpath_)
if len(name) <= 8:
strke = 10
elif len(name) >= 9:
strke = 5
else:
strke = 20
name = LogoHelper.make_logo(
bg_,
name,
font_,
fill="white",
stroke_width=strke,
stroke_fill="black",
)
await xx.edit("`Done!`")
await event.client.send_file(
event.chat_id,
file=name,
caption=f"Logo by [{OWNER_NAME}](tg://user?id={OWNER_ID})",
force_document=True,
)
os.remove(name)
await xx.delete()
if os.path.exists(bg_):
os.remove(bg_) | null |
5,879 | import os
from . import bash, get_string, mediainfo, ultroid_cmd
async def _(e):
try:
import glitch_me # ignore :pylint
except ModuleNotFoundError:
await bash(
"pip install -e git+https://github.com/1Danish-00/glitch_me.git#egg=glitch_me"
)
reply = await e.get_reply_message()
if not reply or not reply.media:
return await e.eor(get_string("cvt_3"))
xx = await e.eor(get_string("glitch_1"))
wut = mediainfo(reply.media)
if wut.startswith(("pic", "sticker")):
ok = await reply.download_media()
elif reply.document and reply.document.thumbs:
ok = await reply.download_media(thumb=-1)
else:
return await xx.eor(get_string("com_4"))
cmd = f"glitch_me gif --line_count 200 -f 10 -d 50 '{ok}' ult.gif"
await bash(cmd)
await e.reply(file="ult.gif", force_document=False)
await xx.delete()
os.remove(ok)
os.remove("ult.gif") | null |
5,880 | import os
from . import eor, get_string, udB, ultroid_cmd
async def get_var(event):
try:
opt = event.text.split(maxsplit=2)[1]
except IndexError:
return await event.eor(f"what to get?\nRead `{HNDLR}help variables`")
x = await event.eor(get_string("com_1"))
if opt != "keys":
try:
varname = event.text.split(maxsplit=2)[2]
except IndexError:
return await eor(x, "Such a var doesn't exist!", time=5)
if opt == "var":
c = 0
# try redis
val = udB.get_key(varname)
if val is not None:
c += 1
await x.edit(
f"**Variable** - `{varname}`\n**Value**: `{val}`\n**Type**: Redis Key."
)
# try env vars
val = os.getenv(varname)
if val is not None:
c += 1
await x.edit(
f"**Variable** - `{varname}`\n**Value**: `{val}`\n**Type**: Env Var."
)
if c == 0:
await eor(x, "Such a var doesn't exist!", time=5)
elif opt == "type":
c = 0
# try redis
val = udB.get_key(varname)
if val is not None:
c += 1
await x.edit(f"**Variable** - `{varname}`\n**Type**: Redis Key.")
# try env vars
val = os.getenv(varname)
if val is not None:
c += 1
await x.edit(f"**Variable** - `{varname}`\n**Type**: Env Var.")
if c == 0:
await eor(x, "Such a var doesn't exist!", time=5)
elif opt == "db":
val = udB.get(varname)
if val is not None:
await x.edit(f"**Key** - `{varname}`\n**Value**: `{val}`")
else:
await eor(x, "No such key!", time=5)
elif opt == "keys":
keys = sorted(udB.keys())
msg = "".join(
f"• `{i}`" + "\n"
for i in keys
if not i.isdigit()
and not i.startswith("-")
and not i.startswith("_")
and not i.startswith("GBAN_REASON_")
)
await x.edit(f"**List of DB Keys :**\n{msg}") | null |
5,881 | from . import get_help
import asyncio
import io
from telethon.utils import get_display_name
from pyUltroid.dB.base import KeyManager
from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
KeyM = KeyManager("BROADCAST", cast=list)
async def broadcast_adder(event):
msgg = event.pattern_match.group(1).strip()
x = await event.eor(get_string("bd_1"))
if msgg == "all":
await x.edit(get_string("bd_2"))
chats = [
e.entity
for e in await event.client.get_dialogs()
if (e.is_group or e.is_channel)
]
new = 0
for i in chats:
try:
if (
i.broadcast
and (i.creator or i.admin_rights)
and not KeyM.contains(i.id)
):
new += 1
cid = f"-100{i.id}"
KeyM.add(int(cid))
except Exception as Ex:
LOGS.exception(Ex)
await x.edit(get_string("bd_3").format(KeyM.count(), new))
return
if event.reply_to_msg_id:
previous_message = await event.get_reply_message()
raw_text = previous_message.text
lines = raw_text.split("\n")
length = len(lines)
for line_number in range(1, length - 2):
channel_id = lines[line_number][4:-1]
if not KeyM.contains(channel_id):
KeyM.add(channel_id)
await x.edit(get_string("bd_4"))
await asyncio.sleep(3)
await event.delete()
return
chat_id = event.chat_id
if chat_id == udB.get_key("LOG_CHANNEL"):
return
if KeyM.contains(chat_id):
await x.edit(get_string("bd_6"))
elif xx := KeyM.add(chat_id):
await x.edit(get_string("bd_5"))
else:
await x.edit(get_string("sf_8"))
await asyncio.sleep(3)
await x.delete() | null |
5,882 | from . import get_help
import asyncio
import io
from telethon.utils import get_display_name
from pyUltroid.dB.base import KeyManager
from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
KeyM = KeyManager("BROADCAST", cast=list)
async def broadcast_remover(event):
chat_id = event.pattern_match.group(1).strip() or event.chat_id
x = await event.eor(get_string("com_1"))
if chat_id == "all":
await x.edit(get_string("bd_8"))
udB.del_key("BROADCAST")
await x.edit("Database cleared.")
return
if KeyM.contains(chat_id):
KeyM.remove(chat_id)
await x.edit(get_string("bd_7"))
else:
await x.edit(get_string("bd_9"))
await asyncio.sleep(3)
await x.delete() | null |
5,883 | from . import get_help
import asyncio
import io
from telethon.utils import get_display_name
from pyUltroid.dB.base import KeyManager
from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
KeyM = KeyManager("BROADCAST", cast=list)
async def list_all(event):
x = await event.eor(get_string("com_1"))
channels = KeyM.get()
num = KeyM.count()
if not channels:
return await eor(x, "No chats were added.", time=5)
msg = "Channels in database:\n"
for channel in channels:
name = ""
try:
name = get_display_name(await event.client.get_entity(channel))
except ValueError:
name = ""
msg += f"=> **{name}** [`{channel}`]\n"
msg += f"\nTotal {num} channels."
if len(msg) > 4096:
MSG = msg.replace("*", "").replace("`", "")
with io.BytesIO(str.encode(MSG)) as out_file:
out_file.name = "channels.txt"
await event.reply(
"Channels in Database",
file=out_file,
force_document=True,
allow_cache=False,
)
await x.delete()
else:
await x.edit(msg) | null |
5,884 | from . import get_help
import asyncio
import io
from telethon.utils import get_display_name
from pyUltroid.dB.base import KeyManager
from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
KeyM = KeyManager("BROADCAST", cast=list)
async def forw(event):
if not event.is_reply:
return await event.eor(get_string("ex_1"))
ultroid_bot = event.client
channels = KeyM.get()
x = await event.eor("Sending...")
if not channels:
return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
error_count = 0
sent_count = 0
previous_message = await event.get_reply_message()
error_count = 0
for channel in channels:
try:
await ultroid_bot.forward_messages(channel, previous_message)
sent_count += 1
await x.edit(
f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
)
except Exception:
try:
await ultroid_bot.send_message(
udB.get_key("LOG_CHANNEL"),
f"Error in sending at {channel}.",
)
except Exception as Em:
LOGS.info(Em)
error_count += 1
await x.edit(
f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
)
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
if error_count > 0:
await ultroid_bot.send_message(
udB.get_key("LOG_CHANNEL"), f"{error_count} Errors"
) | null |
5,885 | from . import get_help
import asyncio
import io
from telethon.utils import get_display_name
from pyUltroid.dB.base import KeyManager
from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
KeyM = KeyManager("BROADCAST", cast=list)
async def sending(event):
x = await event.eor(get_string("com_1"))
if not event.is_reply:
return await x.edit(get_string("ex_1"))
channels = KeyM.get()
if not channels:
return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
await x.edit("Sending....")
if event.reply_to_msg_id:
previous_message = await event.get_reply_message()
if previous_message.poll:
return await x.edit(f"Reply `{HNDLR}forward` for polls.")
if previous_message:
error_count = 0
sent_count = 0
for channel in channels:
try:
await ultroid_bot.send_message(channel, previous_message)
sent_count += 1
await x.edit(
f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
)
except Exception as error:
await ultroid_bot.send_message(
udB.get_key("LOG_CHANNEL"),
f"Error in sending at {channel}.\n\n{error}",
)
error_count += 1
await x.edit(
f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
)
await x.edit(f"{sent_count} messages sent with {error_count} errors.")
if error_count > 0:
await ultroid_bot.send_message(
udB.get_key("LOG_CHANNEL"),
f"{error_count} Errors",
) | null |
5,886 | from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest
from pyUltroid.fns.admins import lock_unlock
from . import ultroid_cmd
def lock_unlock(query, lock=True):
async def un_lock(e):
mat = e.pattern_match.group(2).strip()
if not mat:
return await e.eor("`Give some Proper Input..`", time=5)
lock = e.pattern_match.group(1) == ""
ml = lock_unlock(mat, lock)
if not ml:
return await e.eor("`Incorrect Input`", time=5)
msg = "Locked" if lock else "Unlocked"
try:
await e.client(EditChatDefaultBannedRightsRequest(e.chat_id, ml))
except Exception as er:
return await e.eor(str(er))
await e.eor(f"**{msg}** - `{mat}` ! ") | null |
5,887 | from . import get_help
import asyncio
import os
import re
import time
from datetime import datetime as dt
from telethon.errors.rpcerrorlist import MessageNotModifiedError
from telethon.tl.types import DocumentAttributeVideo
from pyUltroid.fns.tools import metadata
from . import (
ULTConfig,
bash,
downloader,
get_string,
humanbytes,
math,
mediainfo,
time_formatter,
ultroid_cmd,
uploader,
)
from .. import *
async def metadata(file):
out, _ = await bash(f'mediainfo "{_unquote_text(file)}" --Output=JSON')
if _ and _.endswith("NOT_FOUND"):
raise DependencyMissingError(
f"'{_}' is not installed!\nInstall it to use this command."
)
data = {}
_info = json.loads(out)["media"]["track"]
info = _info[0]
if info.get("Format") in ["GIF", "PNG"]:
return {
"height": _info[1]["Height"],
"width": _info[1]["Width"],
"bitrate": _info[1].get("BitRate", 320),
}
if info.get("AudioCount"):
data["title"] = info.get("Title", file)
data["performer"] = info.get("Performer") or udB.get_key("artist") or ""
if info.get("VideoCount"):
data["height"] = int(float(_info[1].get("Height", 720)))
data["width"] = int(float(_info[1].get("Width", 1280)))
data["bitrate"] = int(_info[1].get("BitRate", 320))
data["duration"] = int(float(info.get("Duration", 0)))
return data
async def _(e):
cr = e.pattern_match.group(1).strip()
crf = 27
to_stream = False
if cr:
k = e.text.split()
if len(k) == 2:
crf = int(k[1]) if k[1].isdigit() else 27
elif len(k) > 2:
crf = int(k[1]) if k[1].isdigit() else 27
to_stream = "stream" in k[2]
vido = await e.get_reply_message()
if vido and vido.media and "video" in mediainfo(vido.media):
if hasattr(vido.media, "document"):
vfile = vido.media.document
name = vido.file.name
else:
vfile = vido.media
name = ""
if not name:
name = "video_" + dt.now().isoformat("_", "seconds") + ".mp4"
xxx = await e.eor(get_string("audiotools_5"))
c_time = time.time()
file = await downloader(
f"resources/downloads/{name}",
vfile,
xxx,
c_time,
f"Downloading {name}...",
)
o_size = os.path.getsize(file.name)
d_time = time.time()
diff = time_formatter((d_time - c_time) * 1000)
file_name = (file.name).split("/")[-1]
out = file_name.replace(file_name.split(".")[-1], "compressed.mkv")
await xxx.edit(
f"`Downloaded {file.name} of {humanbytes(o_size)} in {diff}.\nNow Compressing...`"
)
x, y = await bash(
f'mediainfo --fullscan """{file.name}""" | grep "Frame count"'
)
if y and y.endswith("NOT_FOUND"):
return await xxx.edit(f"ERROR: `{y}`")
total_frames = x.split(":")[1].split("\n")[0]
progress = f"progress-{c_time}.txt"
with open(progress, "w"):
pass
proce = await asyncio.create_subprocess_shell(
f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{file.name}""" -preset ultrafast -vcodec libx265 -crf {crf} -c:a copy """{out}""" -y',
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
while proce.returncode != 0:
await asyncio.sleep(3)
with open(progress, "r+") as fil:
text = fil.read()
frames = re.findall("frame=(\\d+)", text)
size = re.findall("total_size=(\\d+)", text)
speed = 0
if len(frames):
elapse = int(frames[-1])
if len(size):
size = int(size[-1])
per = elapse * 100 / int(total_frames)
time_diff = time.time() - int(d_time)
speed = round(elapse / time_diff, 2)
if int(speed) != 0:
some_eta = ((int(total_frames) - elapse) / speed) * 1000
text = f"`Compressing {file_name} at {crf} CRF.\n`"
progress_str = "`[{0}{1}] {2}%\n\n`".format(
"".join("●" for _ in range(math.floor(per / 5))),
"".join("" for _ in range(20 - math.floor(per / 5))),
round(per, 2),
)
e_size = f"{humanbytes(size)} of ~{humanbytes((size / per) * 100)}"
eta = f"~{time_formatter(some_eta)}"
try:
await xxx.edit(
text
+ progress_str
+ "`"
+ e_size
+ "`"
+ "\n\n`"
+ eta
+ "`"
)
except MessageNotModifiedError:
pass
os.remove(file.name)
c_size = os.path.getsize(out)
f_time = time.time()
difff = time_formatter((f_time - d_time) * 1000)
await xxx.edit(
f"`Compressed {humanbytes(o_size)} to {humanbytes(c_size)} in {difff}\nTrying to Upload...`"
)
differ = 100 - ((c_size / o_size) * 100)
caption = f"**Original Size: **`{humanbytes(o_size)}`\n"
caption += f"**Compressed Size: **`{humanbytes(c_size)}`\n"
caption += f"**Compression Ratio: **`{differ:.2f}%`\n"
caption += f"\n**Time Taken To Compress: **`{difff}`"
mmmm = await uploader(out, out, f_time, xxx, f"Uploading {out}...")
if to_stream:
data = await metadata(out)
width = data["width"]
height = data["height"]
duration = data["duration"]
attributes = [
DocumentAttributeVideo(
duration=duration, w=width, h=height, supports_streaming=True
)
]
await e.client.send_file(
e.chat_id,
mmmm,
thumb=ULTConfig.thumb,
caption=caption,
attributes=attributes,
force_document=False,
reply_to=e.reply_to_msg_id,
)
else:
await e.client.send_file(
e.chat_id,
mmmm,
thumb=ULTConfig.thumb,
caption=caption,
force_document=True,
reply_to=e.reply_to_msg_id,
)
await xxx.delete()
os.remove(out)
os.remove(progress)
else:
await e.eor(get_string("audiotools_8"), time=5) | null |
5,888 | from . import get_help
import asyncio
import io
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id
from pyUltroid.dB.base import KeyManager
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
async def _(e):
x = e.pattern_match.group(1).strip()
z = await e.eor(get_string("com_1"))
a, b = x.split("|")
try:
c = await e.client.parse_id(a)
except Exception:
await z.edit(get_string("cha_1"))
return
try:
d = await e.client.parse_id(b)
except Exception as er:
LOGS.exception(er)
await z.edit(get_string("cha_1"))
return
async for msg in e.client.iter_messages(int(c), reverse=True):
try:
await asyncio.sleep(2)
await e.client.send_message(int(d), msg)
except FloodWaitError as er:
await asyncio.sleep(er.seconds + 5)
await e.client.send_message(int(d), msg)
except BaseException as er:
LOGS.exception(er)
await z.edit("Done") | null |
5,889 | from . import get_help
import asyncio
import io
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id
from pyUltroid.dB.base import KeyManager
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
SourceM = KeyManager("CH_SOURCE", cast=list)
async def autopost_func(e):
if not udB.get_key("AUTOPOST"):
return
x = SourceM.get()
th = await e.get_chat()
if get_peer_id(th) not in x:
return
y = DestiM.get()
for ys in y:
try:
await e.client.send_message(int(ys), e.message)
except Exception as ex:
try:
ERROR[str(ex)]
except KeyError:
ERROR.update({str(ex): ex})
Error = f"**Error on AUTOPOST**\n\n`{ex}`"
await asst.send_message(udB.get_key("LOG_CHANNEL"), Error)
async def source(e):
if x := e.pattern_match.group(1).strip():
try:
y = await e.client.parse_id(x)
except Exception as er:
LOGS.exception(er)
return
else:
y = e.chat_id
if not SourceM.contains(y):
SourceM.add(y)
await e.eor(get_string("cha_2"))
ultroid_bot.add_handler(autopost_func, events.NewMessage())
else:
await e.eor(get_string("cha_3")) | null |
5,890 | from . import get_help
import asyncio
import io
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id
from pyUltroid.dB.base import KeyManager
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
SourceM = KeyManager("CH_SOURCE", cast=list)
if udB.get_key("AUTOPOST"):
ultroid_bot.add_handler(autopost_func, events.NewMessage())
async def dd(event):
chat_id = event.pattern_match.group(1).strip()
x = await event.eor(get_string("com_1"))
if chat_id == "all":
await x.edit(get_string("bd_8"))
udB.del_key("CH_SOURCE")
await x.edit(get_string("cha_4"))
return
if chat_id:
try:
y = await event.client.parse_id(chat_id)
except Exception as er:
LOGS.exception(er)
return
else:
y = event.chat_id
if SourceM.contains(y):
SourceM.remove(y)
await eor(x, get_string("cha_5"), time=5)
else:
await eor(x, "Source channel is already removed from database. ", time=3) | null |
5,891 | from . import get_help
import asyncio
import io
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id
from pyUltroid.dB.base import KeyManager
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
SourceM = KeyManager("CH_SOURCE", cast=list)
async def list_all(event):
x = await event.eor(get_string("com_1"))
num = SourceM.count()
if not num:
return await eor(x, "No chats were added.", time=5)
msg = get_string("cha_8")
channels = SourceM.get()
for channel in channels:
name = ""
try:
name = get_display_name(await event.client.get_entity(int(channel)))
except BaseException:
name = ""
msg += f"\n=> **{name}** [`{channel}`]"
msg += f"\nTotal {num} channels."
if len(msg) > 4096:
MSG = msg.replace("*", "").replace("`", "")
with io.BytesIO(str.encode(MSG)) as out_file:
out_file.name = "channels.txt"
await event.reply(
"Channels in database",
file=out_file,
force_document=True,
allow_cache=False,
)
await x.delete()
else:
await x.edit(msg) | null |
5,892 | from . import get_help
import asyncio
import io
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id
from pyUltroid.dB.base import KeyManager
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
DestiM = KeyManager("CH_DESTINATIONS", cast=list)
async def destination(e):
if x := e.pattern_match.group(1).strip():
try:
y = await e.client.parse_id(x)
except Exception as er:
LOGS.exception(er)
return
else:
y = e.chat_id
if not DestiM.contains(y):
DestiM.add(y)
await e.eor("Destination added succesfully")
else:
await e.eor("Destination channel already added") | null |
5,893 | from . import get_help
import asyncio
import io
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id
from pyUltroid.dB.base import KeyManager
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
DestiM = KeyManager("CH_DESTINATIONS", cast=list)
if udB.get_key("AUTOPOST"):
ultroid_bot.add_handler(autopost_func, events.NewMessage())
async def dd(event):
chat_id = event.pattern_match.group(1).strip()
x = await event.eor(get_string("com_1"))
if chat_id == "all":
await x.edit(get_string("bd_8"))
udB.del_key("CH_DESTINATION")
await x.edit("Destinations database cleared.")
return
if chat_id:
try:
y = await event.client.parse_id(chat_id)
except Exception as er:
LOGS.exception(er)
return
else:
y = event.chat_id
if DestiM.contains(y):
DestiM.remove(y)
await eor(x, "Destination removed from database")
else:
await eor(x, "Destination channel is already removed from database. ", time=5) | null |
5,894 | from . import get_help
import asyncio
import io
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id
from pyUltroid.dB.base import KeyManager
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
DestiM = KeyManager("CH_DESTINATIONS", cast=list)
async def list_all(event):
ultroid_bot = event.client
x = await event.eor(get_string("com_1"))
channels = DestiM.get()
num = len(channels)
if not num:
return await eor(x, "No chats were added.", time=5)
msg = get_string("cha_7")
for channel in channels:
name = ""
try:
name = get_display_name(await ultroid_bot.get_entity(int(channel)))
except BaseException:
name = ""
msg += f"\n=> **{name}** [`{channel}`]"
msg += f"\nTotal {num} channels."
if len(msg) > 4096:
MSG = msg.replace("*", "").replace("`", "")
with io.BytesIO(str.encode(MSG)) as out_file:
out_file.name = "channels.txt"
await ultroid_bot.send_file(
event.chat_id,
out_file,
force_document=True,
allow_cache=False,
caption="Destination channels in database",
reply_to=event,
)
await x.delete()
else:
await x.edit(msg) | null |
5,895 | from . import get_help
import asyncio
from . import get_string, ultroid_cmd
async def delete_it(delme):
msg_src = await delme.get_reply_message()
if not msg_src:
return
await msg_src.try_delete()
await delme.try_delete() | null |
5,896 | from . import get_help
import asyncio
from . import get_string, ultroid_cmd
async def copy(e):
reply = await e.get_reply_message()
if reply:
await reply.reply(reply)
return await e.try_delete()
await e.eor(get_string("ex_1"), time=5) | null |
5,897 | from . import get_help
import asyncio
from . import get_string, ultroid_cmd
async def editer(edit):
message = edit.text
chat = await edit.get_input_chat()
string = str(message[6:])
reply = await edit.get_reply_message()
if reply and reply.text:
try:
await reply.edit(string)
await edit.delete()
except BaseException:
pass
else:
i = 1
async for message in edit.client.iter_messages(chat, from_user="me", limit=2):
if i == 2:
await message.edit(string)
await edit.delete()
break
i += 1 | null |
5,898 | from . import get_help
import asyncio
from . import get_string, ultroid_cmd
async def _(e):
if e.reply_to_msg_id:
chat = e.chat_id
try:
msg = (await e.client.get_messages(e.chat_id, limit=1, max_id=e.id))[0]
except IndexError:
return await e.eor(
"`You have previously sent no message to reply again...`", time=5
)
except BaseException as er:
return await e.eor(f"**ERROR:** `{er}`")
await asyncio.wait(
[
e.client.delete_messages(chat, [e.id, msg.id]),
e.client.send_message(chat, msg, reply_to=e.reply_to_msg_id),
]
)
else:
await e.try_delete() | null |
5,899 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def leave(ult):
await ult.eor(f"`{ult.client.me.first_name} has left this group, bye!!.`")
await ult.client(LeaveChannelRequest(ult.chat_id)) | null |
5,900 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def date(event):
m = dt.now().month
y = dt.now().year
d = dt.now().strftime("Date - %B %d, %Y\nTime- %H:%M:%S")
k = calendar.month(y, m)
await event.eor(f"`{k}\n\n{d}`") | null |
5,901 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def stats(
event: NewMessage.Event,
):
ok = await event.eor("`Collecting stats...`")
start_time = time.time()
private_chats = 0
bots = 0
groups = 0
broadcast_channels = 0
admin_in_groups = 0
creator_in_groups = 0
admin_in_broadcast_channels = 0
creator_in_channels = 0
unread_mentions = 0
unread = 0
dialog: Dialog
async for dialog in event.client.iter_dialogs():
entity = dialog.entity
if isinstance(entity, Channel) and entity.broadcast:
broadcast_channels += 1
if entity.creator or entity.admin_rights:
admin_in_broadcast_channels += 1
if entity.creator:
creator_in_channels += 1
elif (isinstance(entity, Channel) and entity.megagroup) or isinstance(
entity, Chat
):
groups += 1
if entity.creator or entity.admin_rights:
admin_in_groups += 1
if entity.creator:
creator_in_groups += 1
elif isinstance(entity, User):
private_chats += 1
if entity.bot:
bots += 1
unread_mentions += dialog.unread_mentions_count
unread += dialog.unread_count
stop_time = time.time() - start_time
try:
ct = (await event.client(GetBlockedRequest(1, 0))).count
except AttributeError:
ct = 0
try:
sp = await event.client(GetAllStickersRequest(0))
sp_count = len(sp.sets)
except BaseException:
sp_count = 0
full_name = inline_mention(event.client.me)
response = f"🔸 **Stats for {full_name}** \n\n"
response += f"**Private Chats:** {private_chats} \n"
response += f"** •• **`Users: {private_chats - bots}` \n"
response += f"** •• **`Bots: {bots}` \n"
response += f"**Groups:** {groups} \n"
response += f"**Channels:** {broadcast_channels} \n"
response += f"**Admin in Groups:** {admin_in_groups} \n"
response += f"** •• **`Creator: {creator_in_groups}` \n"
response += f"** •• **`Admin Rights: {admin_in_groups - creator_in_groups}` \n"
response += f"**Admin in Channels:** {admin_in_broadcast_channels} \n"
response += f"** •• **`Creator: {creator_in_channels}` \n"
response += f"** •• **`Admin Rights: {admin_in_broadcast_channels - creator_in_channels}` \n"
response += f"**Unread:** {unread} \n"
response += f"**Unread Mentions:** {unread_mentions} \n"
response += f"**Blocked Users:** {ct}\n"
response += f"**Total Stickers Pack Installed :** `{sp_count}`\n\n"
response += f"**__It Took:__** {stop_time:.02f}s \n"
await ok.edit(response) | null |
5,902 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def abs_rmbg(event):
RMBG_API = udB.get_key("RMBG_API")
if not RMBG_API:
return await event.eor(
"Get your API key from [here](https://www.remove.bg/) for this plugin to work.",
)
match = event.pattern_match.group(1).strip()
reply = await event.get_reply_message()
if match and os.path.exists(match):
dl = match
elif reply and reply.media:
if reply.document and reply.document.thumbs:
dl = await reply.download_media(thumb=-1)
else:
dl = await reply.download_media()
else:
return await eod(
event, f"Use `{HNDLR}rmbg` as reply to a pic to remove its background."
)
if not (dl and dl.endswith(("webp", "jpg", "png", "jpeg"))):
os.remove(dl)
return await event.eor(get_string("com_4"))
if dl.endswith("webp"):
file = f"{dl}.png"
Image.open(dl).save(file)
os.remove(dl)
dl = file
xx = await event.eor("`Sending to remove.bg`")
dn, out = await ReTrieveFile(dl)
os.remove(dl)
if not dn:
dr = out["errors"][0]
de = dr.get("detail", "")
return await xx.edit(
f"**ERROR ~** `{dr['title']}`,\n`{de}`",
)
zz = Image.open(out)
if zz.mode != "RGB":
zz.convert("RGB")
wbn = check_filename("ult-rmbg.webp")
zz.save(wbn, "webp")
await event.client.send_file(
event.chat_id,
out,
force_document=True,
reply_to=reply,
)
await event.client.send_file(event.chat_id, wbn, reply_to=reply)
os.remove(out)
os.remove(wbn)
await xx.delete() | null |
5,903 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def telegraphcmd(event):
xx = await event.eor(get_string("com_1"))
match = event.pattern_match.group(1).strip() or "Ultroid"
reply = await event.get_reply_message()
if not reply:
return await xx.eor("`Reply to Message.`")
if not reply.media and reply.message:
content = reply.message
else:
getit = await reply.download_media()
dar = mediainfo(reply.media)
if dar == "sticker":
file = f"{getit}.png"
Image.open(getit).save(file)
os.remove(getit)
getit = file
elif dar.endswith("animated"):
file = f"{getit}.gif"
await bash(f"lottie_convert.py '{getit}' {file}")
os.remove(getit)
getit = file
if "document" not in dar:
try:
nn = f"https://graph.org{uf(getit)[0]}"
amsg = f"Uploaded to [Telegraph]({nn}) !"
except Exception as e:
amsg = f"Error : {e}"
os.remove(getit)
return await xx.eor(amsg)
content = pathlib.Path(getit).read_text()
os.remove(getit)
makeit = Telegraph.create_page(title=match, content=[content])
await xx.eor(
f"Pasted to Telegraph : [Telegraph]({makeit['url']})", link_preview=False
) | null |
5,904 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def sugg(event):
sll = event.text.split(maxsplit=1)
try:
text = sll[1]
except IndexError:
text = None
if not (event.is_reply or text):
return await eod(
event,
"`Please reply to a message to make a suggestion poll!`",
)
if event.is_reply and not text:
reply = await event.get_reply_message()
if reply.text and len(reply.text) < 35:
text = reply.text
else:
text = "Do you Agree to Replied Suggestion ?"
reply_to = event.reply_to_msg_id if event.is_reply else event.id
try:
await event.client.send_file(
event.chat_id,
file=InputMediaPoll(
poll=Poll(
id=12345,
question=text,
answers=[PollAnswer("Yes", b"1"), PollAnswer("No", b"2")],
),
),
reply_to=reply_to,
)
except Exception as e:
return await eod(event, f"`Oops, you can't send polls here!\n\n{e}`")
await event.delete() | null |
5,905 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def ipinfo(event):
ip = event.text.split()
ipaddr = ""
try:
ipaddr = f"/{ip[1]}"
except IndexError:
ipaddr = ""
det = await async_searcher(f"https://ipinfo.io{ipaddr}/geo", re_json=True)
try:
ip = det["ip"]
city = det["city"]
region = det["region"]
country = det["country"]
cord = det["loc"]
try:
zipc = det["postal"]
except KeyError:
zipc = "None"
tz = det["timezone"]
await eor(
event,
"""
**IP Details Fetched.**
**IP:** `{}`
**City:** `{}`
**Region:** `{}`
**Country:** `{}`
**Co-ordinates:** `{}`
**Postal Code:** `{}`
**Time Zone:** `{}`
""".format(
ip,
city,
region,
country,
cord,
zipc,
tz,
),
)
except BaseException:
err = det["error"]["title"]
msg = det["error"]["message"]
await event.eor(f"ERROR:\n{err}\n{msg}", time=5) | null |
5,906 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
_copied_msg = {}
async def copp(event):
msg = await event.get_reply_message()
if not msg:
return await event.eor(f"Use `{HNDLR}cpy` as reply to a message!", time=5)
_copied_msg["CLIPBOARD"] = msg
await event.eor(f"Copied. Use `{HNDLR}pst` to paste!", time=10) | null |
5,907 | import calendar
import html
import io
import os
import pathlib
import time
from datetime import datetime as dt
from pyUltroid._misc._assistant import asst_cmd
from pyUltroid.dB.gban_mute_db import is_gbanned
from pyUltroid.fns.tools import get_chat_and_msgid
from telethon.errors.rpcerrorlist import ChatForwardsRestrictedError, UserBotError
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
GetAdminedPublicChannelsRequest,
InviteToChannelRequest,
LeaveChannelRequest,
)
from telethon.tl.functions.contacts import GetBlockedRequest
from telethon.tl.functions.messages import AddChatUserRequest, GetAllStickersRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import (
Channel,
Chat,
InputMediaPoll,
Poll,
PollAnswer,
TLObject,
User,
)
from telethon.utils import get_peer_id
from pyUltroid.fns.info import get_chat_info
from . import (
HNDLR,
LOGS,
Image,
ReTrieveFile,
Telegraph,
asst,
async_searcher,
bash,
check_filename,
eod,
eor,
get_paste,
get_string,
inline_mention,
json_parser,
mediainfo,
udB,
ultroid_cmd,
)
async def toothpaste(event):
try:
await event.respond(_copied_msg["CLIPBOARD"])
except KeyError:
return await eod(
event,
f"Nothing was copied! Use `{HNDLR}cpy` as reply to a message first!",
)
except Exception as ex:
return await event.eor(str(ex), time=5)
await event.delete()
async def pepsodent(event):
await toothpaste(event) | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.