Skip to content

Commit

Permalink
Ultroid v0.0.8 | 17-6-21
Browse files Browse the repository at this point in the history
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Danish <danish@ultroid.tech>
Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: divkix <divkix@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: Programming Error <error@notavailable.live>
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
  • Loading branch information
10 people authored Jun 17, 2021
1 parent 4f0cb66 commit 4e65f21
Show file tree
Hide file tree
Showing 119 changed files with 2,730 additions and 5,508 deletions.
21 changes: 12 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
.env
venv/
__pycache__
ultroid.session-journal
ultroid.session
*.session-journal
*.session
build
*.mp3
*.webm
*.webp
*.mp4
*.tgs
.vscode/*
/*.jpg
/*.png
/*.mp4
addons/
ultroid.log
*.log
target/npmlist.json
package-lock.json
# Directories
addons/
__pycache__/
venv/
node_modules/
glitch_me/
.idea
venv/
.idea/
.vscode/
temp/
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
# Copyright (C) 2021 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/>.

FROM programmingerror/ultroid:v0.0.2
FROM programmingerror/ultroid:b0.1

ENV TZ=Asia/Kolkata
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get autoremove --purge

RUN git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/

WORKDIR /root/TeamUltroid/

RUN pip3 install -r requirements.txt
RUN npm install -g npm@7.12.1 -g
RUN pip3 install --no-cache-dir -r requirements.txt
RUN npm install -g npm@7.16.0 -g
RUN npm install
RUN npm run build
6 changes: 1 addition & 5 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@
}
},
"formation": {
"worker": {
"ultroid": {
"quantity": 1,
"size": "free"
},
"web": {
"quantity": 0,
"size": "free"
}
}
}
2 changes: 1 addition & 1 deletion assistant/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
# Copyright (C) 2021 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
Expand Down
59 changes: 54 additions & 5 deletions assistant/api_setter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
# Copyright (C) 2021 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
Expand All @@ -16,15 +16,14 @@ async def apiset(event):
await event.edit(
get_string("ast_1"),
buttons=[
[Button.inline("Remove.bg", data="rmbg")],
[Button.inline("Remove.bg API", data="rmbg")],
[Button.inline("DEEP API", data="dapi")],
[Button.inline("OCR API", data="oapi")],
[Button.inline("« Back", data="setter")],
],
)


# remove.bg api


@callback("rmbg")
@owner
async def rmbgapi(event):
Expand All @@ -48,3 +47,53 @@ async def rmbgapi(event):
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)


@callback("dapi")
@owner
async def rmbgapi(event):
await event.delete()
pru = event.sender_id
var = "DEEP_API"
name = "DEEP AI API Key"
async with event.client.conversation(pru) as conv:
await conv.send_message("Get Your Deep Api from deepai.org and send here.")
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button("apiset"),
)
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)


@callback("oapi")
@owner
async def rmbgapi(event):
await event.delete()
pru = event.sender_id
var = "OCR_API"
name = "OCR API Key"
async with event.client.conversation(pru) as conv:
await conv.send_message("Get Your OCR api from ocr.space Send Send Here.")
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button("apiset"),
)
else:
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
92 changes: 70 additions & 22 deletions assistant/inlinestuff.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
# Copyright (C) 2021 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/>.

import base64
import os
import urllib
from random import choice
from re import compile as re_compile
from re import findall
from urllib.request import urlopen

import requests
from bs4 import BeautifulSoup
Expand All @@ -19,6 +20,8 @@
from telethon import Button
from telethon.tl.types import InputWebDocument as wb

from plugins._inline import SUP_BUTTONS

from . import *
from . import humanbytes as hb

Expand Down Expand Up @@ -153,15 +156,7 @@ async def repo(e):
description="Userbot | Telethon",
thumb=wb(ultpic, 0, "image/jpeg", []),
text="• **ULTROID USERBOT** •",
buttons=[
[
Button.url("Repo", url="https://github.com/TeamUltroid/Ultroid"),
Button.url(
"Addons", url="https://github.com/TeamUltroid/UltroidAddons"
),
],
[Button.url("Support", url="t.me/UltroidSupport")],
],
buttons=SUP_BUTTONS,
),
]
await e.answer(res, switch_pm="Ultroid Repo.", switch_pm_param="start")
Expand Down Expand Up @@ -426,22 +421,75 @@ async def _(e):
await e.answer(modss, switch_pm="Search Mod Applications.", switch_pm_param="start")


@in_pattern("clipart")
@in_pattern("ebooks")
@in_owner
async def clip(e):
try:
quer = e.text.split(" ", maxsplit=1)[1]
except IndexError:
await e.answer([], switch_pm="ClipArt Search.", switch_pm_param="start")
await e.answer(
[], switch_pm="Enter Query to Look for EBook", switch_pm_param="start"
)
return
quer = quer.replace(" ", "+")
sear = f"https://clipartix.com/search/{quer}"
html = urlopen(sear)
bs = BeautifulSoup(html, "html.parser", from_encoding="utf-8")
resul = bs.find_all("img", "attachment-full size-full")
sear = f"http://www.gutenberg.org/ebooks/search/?query={quer}&submit_search=Go%21"
magma = requests.get(sear).content
bs = BeautifulSoup(magma, "html.parser", from_encoding="utf-8")
out = bs.find_all("img")
Alink = bs.find_all("a", "link")
if len(out) == 0:
return await e.answer(
[], switch_pm="No Results Found !", switch_pm_param="start"
)
buil = e.builder
dont_take = [
"Authors",
"Did you mean",
"Sort Alpha",
"Sort by",
"Subjects",
"Bookshelves",
]
hm = []
for res in resul:
hm += [buil.photo(include_media=True, file=res["src"])]
await e.answer(
hm, gallery=True, switch_pm="Clipart Searcher.", switch_pm_param="start"
)
titles = []
for num in Alink:
try:
rt = num.find("span", "title").text
if not rt.startswith(tuple(dont_take)):
titles.append(rt)
except BaseException:
pass
for rs in range(len(out)):
if "/cache/epub" in out[rs]["src"]:
link = out[rs]["src"]
num = link.split("/")[3]
hm.append(
buil.document(
title=titles[rs],
description="GutenBerg Search",
file="https://gutenberg.org" + link.replace("small", "medium"),
text=f"**• Ebook Search**\n\n->> `{titles[rs]}`",
buttons=Button.inline("Get as Doc", data=f"ebk_{num}"),
)
)
await e.answer(hm, switch_pm="Ebooks Search", switch_pm_param="start")


@callback(re_compile("ebk_(.*)"))
async def eupload(event):
match = event.pattern_match.group(1).decode("utf-8")
await event.answer("Uploading..")
try:
await event.edit(
file=f"https://www.gutenberg.org/files/{match}/{match}-pdf.pdf"
)
except BaseException:
book = "Ultroid-Book.epub"
urllib.request.urlretrieve(
"https://www.gutenberg.org/ebooks/132.epub.images", book
)
fn, media, _ = await asst._file_to_media(
book, thumb="resources/extras/ultroid.jpg"
)
await event.edit(file=media)
os.remove(book)
2 changes: 1 addition & 1 deletion assistant/localization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
# Copyright (C) 2021 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
Expand Down
Loading

0 comments on commit 4e65f21

Please sign in to comment.