Ultroid v0.4.1

This commit is contained in:
Devesh Pal
2022-02-10 16:28:53 +05:30
parent 138ee1882a
commit 70a3a11b89
18 changed files with 251 additions and 226 deletions

View File

@@ -28,8 +28,15 @@ from ._inline import something
@ultroid_bot.on(events.ChatAction())
async def ChatActionsHandler(ult): # sourcery no-metrics
# clean chat actions
async def Function(event):
try:
await DummyHandler(event)
except Exception as er:
LOGS.exception(er)
async def DummyHandler(ult):
# clean chat actions
key = udB.get_key("CLEANCHAT") or []
if ult.chat_id in key:
try:

View File

@@ -18,10 +18,10 @@ from telethon.errors.rpcerrorlist import (
PeerIdInvalidError,
UserNotParticipantError,
)
from telethon.tl.types import MessageEntityMention, MessageEntityMentionName
from telethon.tl.types import MessageEntityMention, MessageEntityMentionName, User
from telethon.utils import get_display_name
from . import *
from . import ultroid_bot, asst, udB, inline_mention, Button, LOGS, get_string, LOG_CHANNEL, callback, events
CACHE_SPAM = {}
TAG_EDITS = {}
@@ -35,7 +35,7 @@ TAG_EDITS = {}
)
async def all_messages_catcher(e):
x = await e.get_sender()
if isinstance(x, types.User) and (x.bot or x.verified):
if isinstance(x, User) and (x.bot or x.verified):
return
if not udB.get_key("TAG_LOG"):
return
@@ -105,7 +105,7 @@ if udB.get_key("TAG_LOG"):
@ultroid_bot.on(events.MessageEdited(func=lambda x: not x.out))
async def upd_edits(event):
x = event.sender
if isinstance(x, types.User) and (x.bot or x.verified):
if isinstance(x, User) and (x.bot or x.verified):
return
if event.chat_id not in TAG_EDITS:
if event.sender_id == udB.get_key("TAG_LOG"):
@@ -266,7 +266,7 @@ async def parse_buttons(event):
where_n, who_n = get_display_name(y), get_display_name(x)
where_l = event.message_link
buttons = [[Button.url(where_n, where_l)]]
if isinstance(x, types.User) and x.username:
if isinstance(x, User) and x.username:
try:
buttons.append(
[Button.mention(who_n, await asst.get_input_entity(x.username))]

View File

@@ -51,6 +51,7 @@ from telethon.errors.rpcerrorlist import ChatNotModifiedError, UserIdInvalidErro
from telethon.tl.functions.channels import GetFullChannelRequest
from telethon.tl.functions.messages import GetFullChatRequest, SetHistoryTTLRequest
from telethon.tl.types import InputMessagesFilterPinned
from telethon.utils import get_display_name
from . import (
HNDLR,
@@ -442,7 +443,7 @@ async def djshsh(event):
async def get_all_pinned(event):
x = await event.eor(get_string("com_1"))
chat_id = (str(event.chat_id)).replace("-100", "")
chat_name = (await event.get_chat()).title
chat_name = get_display_name(event.chat)
a = ""
c = 1
async for i in event.client.iter_messages(

View File

@@ -26,7 +26,7 @@ from telethon import events
@ultroid_cmd(pattern="autocorrect", fullsudo=True)
async def acc(e):
if udB.get_key("AUTOCORRECT"):
if not udB.get_key("AUTOCORRECT"):
udB.set_key("AUTOCORRECT", "True")
ultroid_bot.add_handler(
gramme, events.NewMessage(outgoing=True, func=lambda x: x.text)

View File

@@ -58,7 +58,7 @@ async def autopic(e):
file = await e.client.upload_file(lie)
await e.client(UploadProfilePhotoRequest(file))
await asyncio.sleep(SLEEP_TIME)
shuffle(clls)
shuffle(ok)
if search := udB.get_key("AUTOPIC"):

View File

@@ -14,12 +14,12 @@ Format:- `{i}button Hey There! @UseUltroid 😎.
[Ultroid | t.me/theUltroid][Support | t.me/UltroidSupport | same]
[TeamUltroid | t.me/TeamUltroid]`
"""
import os
from pyUltroid.functions.tools import create_tl_btn, get_msg_button
from telegraph import upload_file as uf
from telethon.utils import pack_bot_file_id
from . import *
from . import HNDLR, ultroid_cmd, mediainfo, get_string
from ._inline import something

View File

@@ -213,7 +213,7 @@ async def dd(event):
return
if chat_id:
try:
y = await e.client.parse_id(chat_id)
y = await event.client.parse_id(chat_id)
except Exception as er:
LOGS.exception(er)
return

View File

@@ -24,7 +24,7 @@ import os
from pyUltroid.dB.filestore_db import del_stored, get_stored_msg, list_all_stored_msgs
from pyUltroid.functions.tools import get_file_link
from . import asst, get_string, in_pattern, udB, ultroid_bot, ultroid_cmd
from . import asst, get_string, in_pattern, udB, ultroid_bot, ultroid_cmd, HNDLR
@ultroid_cmd(pattern="store$")
@@ -100,6 +100,6 @@ async def file_short(event):
)
if not res:
title = "You have no stored file :("
text = title + "\n\nRead `{HNDLR}help fileshare` to know how to store."
text = title + f"\n\nRead `{HNDLR}help fileshare` to know how to store."
return await event.answer([await event.builder.article(title=title, text=text)])
await event.answer(res, switch_pm="• File Store •", switch_pm_param="start")

View File

@@ -12,7 +12,6 @@
• `{i}unlock <msgs/media/sticker/gif/games/inline/polls/invites/pin/changeinfo>`
UNLOCK the Used Setting in Used Group.
"""
from pyUltroid.functions.admins import lock_unlock
from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest
@@ -24,10 +23,10 @@ from . import ultroid_cmd
pattern="(un|)lock( (.*)|$)", admins_only=True, manager=True, require="change_info"
)
async def un_lock(e):
mat = e.pattern_match.group(2)
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).strip() == ""
lock = e.pattern_match.group(1) == ""
ml = lock_unlock(mat, lock)
if not ml:
return await e.eor("`Incorrect Input`", time=5)

View File

@@ -6,8 +6,8 @@
"""
✘ Commands Available -
• `{i}eod` or `{i}eod <dd/mm>`
`Get Event of the Day`
• `{i}eod`
`Get Event of the Today`
• `{i}pntrst <link/id>`
Download and send pinterest pins
@@ -22,8 +22,9 @@
Convert replied image into html.
"""
import calendar
import os
from datetime import datetime
from datetime import datetime as dt
from bs4 import BeautifulSoup as bs
from htmlwebshot import WebShot
@@ -32,27 +33,14 @@ from img2html.converter import Img2HTMLConverter
from . import async_searcher, get_random_user_data, get_string, re, ultroid_cmd
@ultroid_cmd(pattern="eod( (.*)|$)")
@ultroid_cmd(pattern="eod$")
async def diela(e):
match = e.pattern_match.group(1).strip()
m = await e.eor(get_string("com_1"))
li = "https://daysoftheyear.com"
te = "🎊 **Events of the Day**\n\n"
if match:
date = match.split("/")[0]
month = match.split("/")[1]
if month.startswith("0"):
month = month[:1]
try:
month = list(calendar.month_name)[int(month)][:3]
except (KeyError, TypeError):
month = dt.today().strftime("%b")
li += "/days/" + month + "/" + date
te = get_string("eod_2").format(match)
else:
da = datetime.today()
month = da.strftime("%b")
li += "/days/" + month + "/" + da.strftime("%F").split("-")[2]
da = dt.today()
month = da.strftime("%b")
li += "/days/" + month + "/" + da.strftime("%F").split("-")[2]
ct = await async_searcher(li, re_content=True)
bt = bs(ct, "html.parser", from_encoding="utf-8")
ml = bt.find_all("a", "js-link-target", href=re.compile("daysoftheyear.com/days"))

View File

@@ -34,7 +34,7 @@ from pyUltroid.dB.night_db import *
from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest
from telethon.tl.types import ChatBannedRights
from . import LOGS, get_string, ultroid_bot, ultroid_cmd
from . import LOGS, get_string, ultroid_bot, ultroid_cmd, udB
@ultroid_cmd(pattern="nmtime( (.*)|$)")

View File

@@ -268,12 +268,12 @@ async def hehe(args):
else:
file.seek(0)
await conv.send_file(file, force_document=True)
rsp = await conv.get_response()
if "Sorry, the file type is invalid." in rsp.text:
await xx.edit(
get_string("sts_8"),
)
return
rsp = await conv.get_response()
if "Sorry, the file type is invalid." in rsp.text:
await xx.edit(
get_string("sts_8"),
)
return
await conv.send_message(emoji)
await conv.get_response()
await conv.send_message("/done")