Skip to content

Commit

Permalink
Ultroid v0.5 Updates
Browse files Browse the repository at this point in the history
Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: Aditya <[email protected]>
Co-authored-by: Kaif <[email protected]>
Co-authored-by: Aditya <[email protected]>
Co-authored-by: 1Danish-00 <[email protected]>
Co-authored-by: smartman_ru <[email protected]>
  • Loading branch information
7 people authored Mar 19, 2022
1 parent f106c48 commit 90ad564
Show file tree
Hide file tree
Showing 81 changed files with 1,630 additions and 927 deletions.
4 changes: 2 additions & 2 deletions .github/stalebot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ staleLabel: inactive
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
any recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
closeComment: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.session-journal
*.session
build
test*
*.mp3
*.webm
*.webp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
### Local Deploy - Easy Method
- 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 - `wget -O locals.py https://git.io/JY9UM && python locals.py`
- Termux - `wget -O install-termux https://tiny.ultroid.tech/termux && bash install-termux`

### Local Deploy - Traditional Method
- Get your [Necessary Variables](#Necessary-Variables)
Expand Down
4 changes: 2 additions & 2 deletions assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

from pyUltroid import *
from pyUltroid import _ult_cache
from pyUltroid._misc import owner_and_sudos
from pyUltroid._misc._assistant import asst_cmd, callback, in_pattern
from pyUltroid.functions.helper import *
from pyUltroid.functions.tools import get_stored_file
from pyUltroid.misc import owner_and_sudos
from pyUltroid.misc._assistant import asst_cmd, callback, in_pattern
from telethon import Button, custom

from plugins import ATRA_COL
Expand Down
10 changes: 7 additions & 3 deletions assistant/callbackstuffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
from random import choice

from bs4 import BeautifulSoup as bs
from pyUltroid.functions.gDrive import GDriveManager

try:
from pyUltroid.functions.gDrive import GDriveManager
except ImportError:
GDriveManager = None
from pyUltroid.functions.helper import fast_download, progress, uploader
from pyUltroid.functions.tools import (
Carbon,
Expand All @@ -33,7 +37,7 @@

# --------------------------------------------------------------------#
telegraph = telegraph_client()
GDrive = GDriveManager()
GDrive = GDriveManager() if GDriveManager else None
# --------------------------------------------------------------------#


Expand Down Expand Up @@ -1306,4 +1310,4 @@ async def fdroid_dler(event):
if msg and hasattr(msg, "media"):
FD_MEDIA.update({uri: msg.media})
os.remove(thumb)
os.remove(file)
os.remove(file)
13 changes: 11 additions & 2 deletions assistant/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@
from html import unescape
from random import choice, shuffle

import akinator
from . import LOGS

try:
import akinator
except ImportError:
akinator = None
LOGS.error("'akinator' not installed.")

from pyUltroid._misc._decorators import ultroid_cmd
from pyUltroid.functions.helper import inline_mention
from pyUltroid.functions.tools import async_searcher
from pyUltroid.misc._decorators import ultroid_cmd
from telethon.errors.rpcerrorlist import (
BotMethodInvalidError,
ChatSendStickersForbiddenError,
Expand All @@ -41,6 +48,8 @@

@ultroid_cmd(pattern="akinator")
async def akina(e):
if not akinator:
return
sta = akinator.Akinator()
games.update({e.chat_id: {e.id: sta}})
try:
Expand Down
198 changes: 197 additions & 1 deletion assistant/inlinestuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.

import base64
import inspect
from datetime import datetime
from random import choice
from re import compile as re_compile
Expand All @@ -20,6 +21,7 @@
webuploader,
)
from telethon import Button
from telethon.tl.alltlobjects import LAYER, tlobjects
from telethon.tl.types import DocumentAttributeAudio as Audio
from telethon.tl.types import InputWebDocument as wb

Expand Down Expand Up @@ -158,7 +160,7 @@ async def _(e):
filename = filename.split("/")[-1]
await e.edit(f"Uploading `{filename}` on {host}")
link = (await webuploader(chat_id, msg_id, host)).strip().replace("\n", "")
await e.edit(f"Uploaded [{filename}]({link}) on {host}.")
await e.edit(f"Uploaded `{filename}` on {host}.", buttons=Button.url("View", link))


@in_pattern("repo", owner=True)
Expand Down Expand Up @@ -688,3 +690,197 @@ async def savn_s(event):
)
await event.answer(res, switch_pm=swi, switch_pm_param="start")
_savn_cache.update({query: res})


_OMG = {}


@in_pattern("omgu", owner=True)
async def omgubuntu(ult):
try:
match = ult.text.split(maxsplit=1)[1].lower()
except IndexError:
return await ult.answer(
[], switch_pm="Enter Query to search...", switch_pm_param="start"
)
if _OMG.get(match):
return await ult.answer(
_OMG[match], switch_pm="OMG Ubuntu Search :]", switch_pm_param="start"
)
get_web = "https://www.omgubuntu.co.uk/?s=" + match.replace(" ", "+")
get_ = await async_searcher(get_web, re_content=True)
BSC = bs(get_, "html.parser", from_encoding="utf-8")
res = []
for cont in BSC.find_all("div", "sbs-layout__item"):
img = cont.find("div", "sbs-layout__image")
url = img.find("a")["href"]
src = img.find("img")["src"]
con = cont.find("div", "sbs-layout__content")
tit = con.find("a", "layout__title-link")
title = tit.text.strip()
desc = con.find("p", "layout__description").text.strip()
text = f"[{title.strip()}]({url})\n\n{desc}"
img = wb(src, 0, "image/jpeg", [])
res.append(
await ult.builder.article(
title=title,
type="photo",
description=desc,
url=url,
text=text,
buttons=Button.switch_inline(
"Search Again", query=ult.text, same_peer=True
),
include_media=True,
content=img,
thumb=img,
)
)
await ult.answer(
res,
switch_pm=f"Showing {len(res)} results!" if res else "No Results Found :[",
switch_pm_param="start",
)
_OMG[match] = res


@in_pattern("tl", owner=True)
async def inline_tl(ult):
try:
match = ult.text.split(maxsplit=1)[1]
except IndexError:
text = f"**It is Telegram TlObjects Searcher.**\n__(Don't use if you don't know what it is!)__\n\n• Example Usage\n`@{asst.me.username} tl GetUserRequest`"
return await ult.answer(
[
await ult.builder.article(
title="How to Use?",
description="Tl Searcher by Ultroid",
url="https://t.me/TheUltroid",
text=text,
)
],
switch_pm="Tl Search 🔍",
switch_pm_param="start",
)
res = []
for key in tlobjects.values():
if match.lower() in key.__name__.lower():
tyyp = "Function" if "tl.functions." in str(key) else "Type"
text = f"**Name:** `{key.__name__}`\n"
text += f"**Category:** `{tyyp}`\n"
text += f"\n`from {key.__module__} import {key.__name__}`\n\n"
args = str(inspect.signature(key))[1:][:-1]
if args:
text += "**Parameter:**\n"
for para in args.split(","):
text += " " * 4 + "`" + para + "`\n"
text += f"\n**Layer:** `{LAYER}`"
res.append(
await ult.builder.article(
title=key.__name__,
description=tyyp,
url="https://t.me/TheUltroid",
text=text[:4000],
)
)
if not res:
mo = f"No Results for {match}!"
else:
mo = f"Showing {len(res)} results!"
await ult.answer(res[:50], switch_pm=mo, switch_pm_param="start")


@in_pattern("gh", owner=True)
async def gh_feeds(ult):
try:
username = ult.text.split(maxsplit=1)[1]
except IndexError:
return await ult.answer(
[],
switch_pm="Enter Github Username to see feeds...",
switch_pm_param="start",
)
if not username.endswith("."):
return await ult.answer(
[], switch_pm="End your query with . to search...", switch_pm_param="start"
)
username = username[:-1]
data = await async_searcher(
f"https://api.github.com/users/{username}/events", re_json=True
)
if not isinstance(data, list):
msg = ""
for ak in list(data.keys()):
msg += ak + ": `" + data[ak] + "`\n"
return await ult.answer(
[
await ult.builder.article(
title=data["message"], text=msg, link_preview=False
)
],
cache_time=300,
switch_pm="Error!!!",
switch_pm_param="start",
)
res = []
res_ids = []
for cont in data[:50]:
text = f"<b><a href='https://github.com/{username}'>@{username}</a></b>"
title = f"@{username}"
extra = None
if cont["type"] == "PushEvent":
text += " pushed in"
title += " pushed in"
dt = cont["payload"]["commits"][-1]
url = "https://github.com/" + dt["url"].split("/repos/")[-1]
extra = f"\n-> <b>message:</b> <code>{dt['message']}</code>"
elif cont["type"] == "IssueCommentEvent":
title += " commented at"
text += " commented at"
url = cont["payload"]["comment"]["html_url"]
elif cont["type"] == "CreateEvent":
title += " created"
text += " created"
url = "https://github.com/" + cont["repo"]["name"]
elif cont["type"] == "PullRequestEvent":
if (
cont["payload"]["pull_request"].get("user", {}).get("login")
!= username.lower()
):
continue
url = cont["payload"]["pull_request"]["html_url"]
text += " created a pull request in"
title += " created a pull request in"
elif cont["type"] == "ForkEvent":
text += " forked"
title += " forked"
url = cont["payload"]["forkee"]["html_url"]
else:
continue
repo = cont["repo"]["name"]
repo_url = "https://github.com/" + repo
title += " " + repo
text += f" <b><a href='{repo_url}'>{repo}</a></b>"
if extra:
text += extra
thumb = wb(cont["actor"]["avatar_url"], 0, "image/jpeg", [])
article = await ult.builder.article(
title=title,
text=text,
url=repo_url,
parse_mode="html",
link_preview=False,
thumb=thumb,
buttons=[
Button.url("View", url),
Button.switch_inline("Search again", query=ult.text, same_peer=True),
],
)
if article.id not in res_ids:
res_ids.append(article.id)
res.append(article)
if res:
msg = f"Showing {len(res)} feeds!"
else:
msg = "Nothing Found"
await ult.answer(res, cache_time=5000, switch_pm=msg, switch_pm_param="start")
2 changes: 1 addition & 1 deletion assistant/manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.

from pyUltroid._misc._decorators import ultroid_cmd
from pyUltroid.functions.helper import inline_mention
from pyUltroid.misc._decorators import ultroid_cmd

from .. import *
4 changes: 2 additions & 2 deletions assistant/manager/stickermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import random

from pyUltroid.functions.misc import create_quotly
from pyUltroid.functions.misc import Quotly
from pyUltroid.functions.tools import TgConverter
from telethon import errors
from telethon.errors.rpcerrorlist import StickersetInvalidError
Expand Down Expand Up @@ -54,7 +54,7 @@ async def kang_cmd(ult):
image = TgConverter.resize_photo_sticker(dl)
image.save(name, "WEBP")
elif reply.text:
dl = await create_quotly(reply)
dl = await Quotly().create_quotly(reply)
else:
return await ult.eor("`Reply to sticker or text to add it in your pack...`")
if not emoji:
Expand Down
2 changes: 1 addition & 1 deletion assistant/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from datetime import datetime

from pytz import timezone as tz
from pyUltroid._misc import SUDO_M, owner_and_sudos
from pyUltroid.dB.asst_fns import *
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
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.9"
services:
worker:
build: .
environment:
REDIS_URI: $REDIS_URI
REDIS_PASSWORD: $REDIS_PASSWORD
SESSION: $SESSION
API_ID: $API_ID # defaults to None
API_HASH: $API_HASH # defaults to None
MONGO_URI: $MONGO_URI # defaults to None
DATABASE_URL: $DATABASE_URL # defaults to None
16 changes: 16 additions & 0 deletions install-termux
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Ultroid - UserBot
# Copyright (C) 2021-2022 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.

if [ -d "resources" ]
then
echo "Current directory Identified.."
else
apt install git -y
git clone https://github.com/TeamUltroid/Ultroid
cd Ultroid
fi
bash resources/startup/termux.sh
Loading

0 comments on commit 90ad564

Please sign in to comment.