Skip to content

Commit

Permalink
Ultroid v0.4 updates
Browse files Browse the repository at this point in the history
Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com>
Co-authored-by: Danish <danish@ultroid.tech>
Co-authored-by: Mahesh Chauhan <84653476+vasusen-code@users.noreply.github.com>
Co-authored-by: Aditya <xditya@ultroid.tech>
Co-authored-by: CyrusXD <79554993+Ashutosh1478@users.noreply.github.com>
  • Loading branch information
6 people authored Feb 9, 2022
1 parent b9f9c54 commit 8ad7073
Show file tree
Hide file tree
Showing 111 changed files with 2,610 additions and 2,173 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& pip3 install --no-cache-dir -r root/TeamUltroid/requirements.txt \
&& pip3 install av --no-binary av

# Railway's banned dependency
RUN if [ ! $RAILWAY_STATIC_URL ]; then pip3 install --no-cache-dir yt-dlp; fi

# changing workdir
WORKDIR /root/TeamUltroid/

Expand Down
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![Stars](https://img.shields.io/github/stars/TeamUltroid/Ultroid?style=flat-square&color=yellow)](https://github.com/TeamUltroid/Ultroid/stargazers)
[![Forks](https://img.shields.io/github/forks/TeamUltroid/Ultroid?style=flat-square&color=orange)](https://github.com/TeamUltroid/Ultroid/fork)
[![Size](https://img.shields.io/github/repo-size/TeamUltroid/Ultroid?style=flat-square&color=green)](https://github.com/TeamUltroid/Ultroid/)
[![Python](https://img.shields.io/badge/Python-v3.9.9-blue)](https://www.python.org/)
[![Python](https://img.shields.io/badge/Python-v3.10.2-blue)](https://www.python.org/)
[![CodeFactor](https://www.codefactor.io/repository/github/teamultroid/ultroid/badge/main)](https://www.codefactor.io/repository/github/teamultroid/ultroid/overview/main)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/TeamUltroid/Ultroid/graphs/commit-activity)
[![Docker Pulls](https://img.shields.io/docker/pulls/theteamultroid/ultroid?style=flat-square)](https://img.shields.io/docker/pulls/theteamultroid/ultroid?style=flat-square)
Expand Down Expand Up @@ -46,9 +46,9 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
- [Ultroid CLI](#Ultroid-CLI)

### Local Deploy - Easy Method
- Linux - `bash -c "$(curl -fsSL https://git.io/JY9UM)"`
- Linux - `wget -O locals.py https://git.io/JY9UM && python3 locals.py`
- Windows - `cd desktop ; wget https://git.io/JY9UM -o locals.py ; python locals.py`
- Termux - `sh -c "$(curl -fsSL https://git.io/JY9UM)"`
- Termux - `wget -O locals.py https://git.io/JY9UM && python locals.py`

### Local Deploy - Traditional Method
- Get your [Necessary Variables](#Necessary-Variables)
Expand All @@ -66,9 +66,9 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
- For Linux users:
`bash sessiongen`
or
`bash -c "$(curl -fsSL https://git.io/JY9JI)"`
`wget -O session.py https://git.io/JY9JI && python3 session.py`
- For Termux users:
`sh -c "$(curl -fsSL https://git.io/JqgsR)"`
`wget -O session.py https://git.io/JY9JI && python session.py`
- For Windows Users:
`cd desktop ; wget https://git.io/JY9JI -o ultroid.py ; python ultroid.py`
- Fill your details in a `.env` file, as given in [`.env.sample`](https://github.com/TeamUltroid/Ultroid/blob/main/.env.sample).
Expand All @@ -94,15 +94,22 @@ Take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) for mo
---
## Necessary Variables
- `SESSION` - SessionString for your accounts login session. Get it from [here](#Session-String)
- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)
- `REDIS_PASSWORD` - Redis endpoint Password, from [redislabs](http://redislabs.com/), tutorial [here.](./resources/extras/redistut.md)

One of the following databases:
- For **Redis** (tutorial [here](./resources/extras/redistut.md))
- `REDIS_URI` - Redis endpoint URL, from [redislabs](http://redislabs.com/).
- `REDIS_PASSWORD` - Redis endpoint Password, from [redislabs](http://redislabs.com/).
- For **MONGODB**
- `MONGO_URI` - Get it from [mongodb](https://mongodb.com/atlas).
- For **SQLDB**
- `DATABASE_URL`- Get it from [elephantsql](https://elephantsql.com).

## Session String
Different ways to get your `SESSION`:
* [![Run on Repl.it](https://replit.com/badge/github/TeamUltroid/Ultroid)](https://replit.com/@TeamUltroid/UltroidStringSession)
* Linux : `bash -c "$(curl -fsSL https://git.io/JY9JI)"`
* Linux : `wget -O session.py https://git.io/JY9JI && python3 session.py`
* PowerShell : `cd desktop ; wget https://git.io/JY9JI ; python ultroid.py`
* Termux : `sh -c "$(curl -fsSL https://da.gd/termux-tel)"`
* Termux : `wget -O session.py https://git.io/JY9JI && python session.py`
* TelegramBot : [@SessionGeneratorBot](https://t.me/SessionGeneratorBot)

---
Expand Down
2 changes: 1 addition & 1 deletion assistant/callbackstuffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def text_to_url(event):
[Button.inline("« Bᴀᴄᴋ", data="cbs_pmcstm")],
],
},
"alabs_vcstm": {
"alvcstm": {
"text": f"Customise your {HNDLR}alive. Choose from the below options -",
"buttons": [
[Button.inline("Aʟɪᴠᴇ Tᴇxᴛ", data="abs_alvtx")],
Expand Down
5 changes: 3 additions & 2 deletions assistant/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def _akokk(e):

@callback(re.compile("aki_(.*)"), owner=True)
async def doai(e):
adt = e.pattern_match.group(1).decode("utf-8")
adt = e.pattern_match.group(1).strip().decode("utf-8")
dt = adt.split("_")
ch = int(dt[0])
mid = int(dt[1])
Expand Down Expand Up @@ -156,10 +156,11 @@ async def magic(event):
"CAADAgADjAADECECEFZM-SrKO9GgAg",
"CAADAgADSwIAAj-VzArAzNCDiGWAHAI",
"CAADAgADhQADwZxgDIuMHR9IU10iAg",
"CAADAgADiwMAAsSraAuoe2BwYu1sdQI",
]


@callback("delit")
@callback("delit", owner=True)
async def delete_it(event):
await event.delete()

Expand Down
27 changes: 16 additions & 11 deletions assistant/inlinestuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,22 @@ async def _(e):
],
]
try:
lnk = e.builder.article(
title=f"Upload {filename}",
text=f"**File:**\n{filename}",
buttons=buttons,
)
except BaseException:
lnk = e.builder.article(
title="fl2lnk",
text="File not found",
)
await e.answer([lnk], switch_pm="File to Link.", switch_pm_param="start")
lnk = [
await e.builder.article(
title=f"Upload {filename}",
text=f"**File:**\n{filename}",
buttons=buttons,
)
]
except BaseException as er:
LOGS.exception(er)
lnk = [
await e.builder.article(
title="fl2lnk",
text="File not found",
)
]
await e.answer(lnk, switch_pm="File to Link.", switch_pm_param="start")


@callback(
Expand Down
2 changes: 1 addition & 1 deletion assistant/manager/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ async def home_aja(e):

@callback(re.compile("hlp_(.*)"))
async def do_something(event):
match = event.pattern_match.group(1).decode("utf-8")
match = event.pattern_match.group(1).strip().decode("utf-8")
await event.edit(STRINGS[match], buttons=Button.inline("<< Back", "mnghome"))
2 changes: 1 addition & 1 deletion assistant/manager/admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def dowj(e):
return await e.eor("Reply to a message...")
try:
await replied.delete()
if e.pattern_match.group(1) == "kick":
if e.pattern_match.group(1).strip() == "kick":
await e.client.kick_participant(e.chat_id, user)
te = "Kicked"
else:
Expand Down
4 changes: 2 additions & 2 deletions assistant/manager/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ async def dheh(e):
await e.client.send_message(e.chat_id, text, reply_to=ri)


@asst_cmd(pattern="echo ?(.*)")
@asst_cmd(pattern="echo( (.*)|$)")
async def oqha(e):
match = e.pattern_match.group(1)
match = e.pattern_match.group(1).strip()
if match:
text = match
reply_to = e
Expand Down
4 changes: 2 additions & 2 deletions assistant/manager/stickermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import random

from pyUltroid.functions.misc import create_quotly
from pyUltroid.functions.tools import resize_photo
from pyUltroid.functions.tools import TgConverter
from telethon import errors
from telethon.errors.rpcerrorlist import StickersetInvalidError
from telethon.tl.functions.messages import GetStickerSetRequest as GetSticker
Expand Down Expand Up @@ -51,7 +51,7 @@ async def kang_cmd(ult):
elif reply.photo:
dl = await reply.download_media()
name = "sticker.webp"
image = resize_photo(dl)
image = TgConverter.resize_photo_sticker(dl)
image.save(name, "WEBP")
elif reply.text:
dl = await create_quotly(reply)
Expand Down
10 changes: 7 additions & 3 deletions assistant/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pyUltroid.functions.helper import inline_mention
from pyUltroid.misc import SUDO_M, owner_and_sudos
from telethon import Button, events
from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
from telethon.utils import get_display_name

from strings.strings import get_string
Expand Down Expand Up @@ -77,12 +78,15 @@ async def own(event):

@callback("closeit")
async def closet(lol):
await lol.delete()
try:
await lol.delete()
except MessageDeleteForbiddenError:
await lol.answer("MESSAGE_TOO_OLD", alert=True)


@asst_cmd(pattern="start ?(.*)", forwards=False, func=lambda x: not x.is_group)
@asst_cmd(pattern="start( (.*)|$)", forwards=False, func=lambda x: not x.is_group)
async def ultroid(event):
args = event.pattern_match.group(1)
args = event.pattern_match.group(1).strip()
if not is_added(event.sender_id) and event.sender_id not in owner_and_sudos():
add_user(event.sender_id)
kak_uiw = udB.get_key("OFF_START_LOG")
Expand Down
53 changes: 32 additions & 21 deletions assistant/ytdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
from PIL import Image
except ImportError:
Image = None
from pyUltroid.functions.helper import bash, fast_download, numerize, time_formatter
from pyUltroid.functions.helper import (
bash,
fast_download,
humanbytes,
numerize,
time_formatter,
)
from pyUltroid.functions.ytdl import dler, get_buttons, get_formats
from telethon import Button
from telethon.errors.rpcerrorlist import FilePartLengthInvalidError, MediaEmptyError
Expand Down Expand Up @@ -52,7 +58,7 @@ async def _(event):
await event.answer([fuk])
return
results = []
search = VideosSearch(string, limit=10)
search = VideosSearch(string, limit=50)
nub = search.result()
nibba = nub["result"]
for v in nibba:
Expand All @@ -70,12 +76,12 @@ async def _(event):
else "None"
)
thumb = f"https://i.ytimg.com/vi/{ids}/hqdefault.jpg"
text = f"<strong>Title:- <a href={link}>{title}</a></strong>\n"
text += f"<strong>⏳ Duration:-</strong> <code>{duration}</code>\n"
text += f"<strong>👀 Views:- </strong> <code>{views}</code>\n"
text += f"<strong>🎙️ Publisher:- </strong> <code>{publisher}</code>\n"
text += f"<strong>🗓️ Published on:- </strong> <code>{published_on}</code>\n"
text += f"<strong>📝 Description:- </strong> <code>{description}</code>"
text = f"**Title: [{title}]({link})**\n\n"
text += f"`Description: {description}\n\n"
text += f"「 Duration: {duration}\n"
text += f"「 Views: {views}\n"
text += f"「 Publisher: {publisher}\n"
text += f"「 Published on: {published_on} 」`"
desc = f"{title}\n{duration}"
file = wb(thumb, 0, "image/jpeg", [])
buttons = [
Expand All @@ -96,9 +102,7 @@ async def _(event):
),
],
]
BACK_BUTTON.update(
{ids: {"text": text, "buttons": buttons, "parse_mode": "html"}}
)
BACK_BUTTON.update({ids: {"text": text, "buttons": buttons}})
results.append(
await event.builder.article(
type="photo",
Expand All @@ -108,7 +112,6 @@ async def _(event):
content=file,
text=text,
include_media=True,
parse_mode="html",
buttons=buttons,
),
)
Expand All @@ -122,7 +125,7 @@ async def _(event):
owner=True,
)
async def _(e):
_e = e.pattern_match.group(1).decode("UTF-8")
_e = e.pattern_match.group(1).strip().decode("UTF-8")
_lets_split = _e.split(":")
_ytdl_data = await dler(e, _yt_base_url + _lets_split[1])
_data = get_formats(_lets_split[0], _lets_split[1], _ytdl_data)
Expand All @@ -140,7 +143,7 @@ async def _(e):
owner=True,
)
async def _(event):
url = event.pattern_match.group(1).decode("UTF-8")
url = event.pattern_match.group(1).strip().decode("UTF-8")
lets_split = url.split(":")
vid_id = lets_split[2]
link = _yt_base_url + vid_id
Expand All @@ -151,6 +154,7 @@ async def _(event):
ext = "mp3"
if lets_split[0] == "audio":
opts = {
"format": "bestaudio",
"addmetadata": True,
"key": "FFmpegMetadata",
"prefer_ffmpeg": True,
Expand Down Expand Up @@ -184,8 +188,12 @@ async def _(event):
else ytdl_data["description"][:100]
)
description = description or "None"
filepath = vid_id + f".{ext}"
if not os.path.exists(filepath):
filepath = filepath + f".{ext}"
size = os.path.getsize(filepath)
file, _ = await event.client.fast_uploader(
vid_id + f".{ext}" * 2,
filepath,
filename=title + "." + ext,
show_progress=True,
event=event,
Expand Down Expand Up @@ -235,6 +243,7 @@ async def _(event):
filepath = vid_id + ".mkv"
if not os.path.exists(filepath):
filepath = filepath + ".webm"
size = os.path.getsize(filepath)
file, _ = await event.client.fast_uploader(
filepath,
filename=title + ".mkv",
Expand All @@ -250,12 +259,14 @@ async def _(event):
supports_streaming=True,
),
]
text = f"**Title:** `{title}`\n\n"
text += f"`📝 Description:` `{description}`\n\n"
text += f"`⏳ Duration:` `{time_formatter(int(duration)*1000)}`\n"
text += f"`🎤 Artist:` `{artist}`\n"
text += f"`👀 Views`: `{views}`\n"
text += f"`👍 Likes`: `{likes}`\n"
description = description if description != "" else "None"
text = f"**Title: [{title}]({_yt_base_url}{vid_id})**\n\n"
text += f"`📝 Description: {description}\n\n"
text += f"「 Duration: {time_formatter(int(duration)*1000)}\n"
text += f"「 Artist: {artist}\n"
text += f"「 Views: {views}\n"
text += f"「 Likes: {likes}\n"
text += f"「 Size: {humanbytes(size)} 」`"
button = Button.switch_inline("Search More", query="yt ", same_peer=True)
try:
await event.edit(
Expand Down
3 changes: 2 additions & 1 deletion plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.


import asyncio
import os
import time
Expand All @@ -26,7 +27,7 @@
from strings import get_string

Redis = udB.get_key

con = TgConverter
OWNER_NAME = ultroid_bot.full_name
OWNER_ID = ultroid_bot.uid

Expand Down
27 changes: 25 additions & 2 deletions plugins/_chatactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank
from pyUltroid.dB.nsfw_db import is_profan
from pyUltroid.functions.helper import inline_mention
from pyUltroid.functions.tools import create_tl_btn, get_chatbot_reply
from pyUltroid.functions.tools import async_searcher, create_tl_btn, get_chatbot_reply
from telethon import events
from telethon.errors.rpcerrorlist import UserNotParticipantError
from telethon.tl.functions.channels import GetParticipantRequest
Expand Down Expand Up @@ -64,10 +64,33 @@ async def ChatActionsHandler(ult): # sourcery no-metrics
)
await res[0].click(ult.chat_id, reply_to=ult.action_message.id)

# gban checks
if ult.user_joined or ult.added_by:
user = await ult.get_user()
chat = await ult.get_chat()
# gbans and @UltroidBans checks
if udB.get_key("ULTROID_BANS"):
try:
is_banned = await async_searcher(
"https://bans.ultroid.tech/api/status",
json={"userId": user.id},
post=True,
re_json=True,
)
if is_banned["is_banned"]:
await ult.client.edit_permissions(
chat.id,
user.id,
view_messages=False,
)
await ult.client.send_message(
chat.id,
"**@UltroidBans:** Banned user detected and banned!\n`{}`.\nBan reason: {}".format(
str(is_banned),
is_banned["reason"],
),
)
except BaseException:
pass
reason = is_gbanned(user.id)
if reason and chat.admin_rights:
try:
Expand Down
Loading

0 comments on commit 8ad7073

Please sign in to comment.