Skip to content

Commit

Permalink
Ultroid v0.3 fixes
Browse files Browse the repository at this point in the history
Co-authored-by: Amit Sharma <[email protected]>
  • Loading branch information
New-dev0 and buddhhu authored Jan 1, 2022
1 parent 0df53ca commit d82cc7d
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 82 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://deploy.ultroid.tech)

## Deploy to Railway
Get the [Necessary Variables](#Necessary-Variables) and then click the button below!

[![Deploy on Railway](https://railway.app/button.svg)](https://deploy.ultroid.tech/railway)

## Deploy Locally
- [Traditional Method](#local-deploy---traditional-method)
- [Easy Method](#local-deploy---easy-method)
Expand Down
9 changes: 5 additions & 4 deletions assistant/callbackstuffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,18 @@ async def _(e):
async def _(e):
if not e.is_private:
return
await e.edit(
msg = (
"Send your FOLDER ID\n\n"
+ "For FOLDER ID:\n"
+ "1. Open Google Drive App.\n"
+ "2. Create Folder.\n"
+ "3. Make that folder public.\n"
+ "4. Send link of that folder."
)
async with asst.conversation(e.sender_id) as conv:
reply = conv.wait_event(events.NewMessage(from_users=e.sender_id))
repl = await reply
await e.delete()
async with asst.conversation(e.sender_id, timeout=150) as conv:
await conv.send_message(msg)
repl = await conv.get_response()
id = repl.text
if id.startswith("https"):
id = id.split("?id=")[-1]
Expand Down
3 changes: 1 addition & 2 deletions plugins/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ async def _help(ult):
except BotMethodInvalidError:
z = []
for x in LIST.values():
for y in x:
z.append(y)
z.extend(x)
cmd = len(z) + 10
if udB.get_key("MANAGER") and udB.get_key("DUAL_HNDLR") == "/":
_main_help_menu[2:3] = [[Button.inline("• Manager Help •", "mngbtn")]]
Expand Down
2 changes: 1 addition & 1 deletion plugins/_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async def uptd_plugin(event):

@callback(data="doupdate", owner=True)
async def _(event):
if not updater():
if not await updater():
return await event.answer(get_string("inline_9"), cache_time=0, alert=True)
if not INLINE_PIC:
return await event.answer(f"Do '{HNDLR}update' to update..")
Expand Down
2 changes: 2 additions & 0 deletions plugins/_userlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ async def upd_edits(event):
if event.chat_id not in TAG_EDITS:
if event.sender_id == udB.get_key("TAG_LOG"):
return
if event.is_private:
return
entities = event.get_entities_text()
if entities:
is_self = False
Expand Down
9 changes: 6 additions & 3 deletions plugins/admintools.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ async def uunban(ult):
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)
Expand Down Expand Up @@ -206,9 +208,9 @@ async def kck(ult):
await xx.edit(text)


@ultroid_cmd(pattern="tban ?(.*)", manager=True, require="ban_users")
@ultroid_cmd(pattern="tban ?(.*)", admins_only=True, manager=True, require="ban_users")
async def tkicki(e):
huh = e.text.split(" ")
huh = e.text.split()
inputt = None
try:
tme = huh[1]
Expand Down Expand Up @@ -240,7 +242,7 @@ async def tkicki(e):
return await e.eor(str(m))


@ultroid_cmd(pattern="pin$", manager=True, require="pin_messages")
@ultroid_cmd(pattern="pin$", admins_only=True, manager=True, require="pin_messages")
async def pin(msg):
if not msg.is_reply:
return await eor(msg, get_string("pin_1"))
Expand All @@ -260,6 +262,7 @@ async def pin(msg):

@ultroid_cmd(
pattern="unpin($| (.*))",
admins_only=True,
manager=True,
require="pin_messages",
)
Expand Down
112 changes: 61 additions & 51 deletions plugins/channelhacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""
✘ Commands Available
🔹 `{i}shift <from channel> | <to channel>`
This will transfer all old post from channel A to channel B.
(u can use username or id of channel too)
Expand Down Expand Up @@ -50,24 +49,32 @@
rem_destination,
rem_source_channel,
)
from telethon.errors.rpcerrorlist import FloodWaitError
from telethon.utils import get_display_name, get_peer_id

from . import asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd

ERROR = {}

@ultroid_bot.on(events.NewMessage())
async def _(e):
if udB.get_key("AUTOPOST") != "True":

async def autopost_func(e):
if not udB.get_key("AUTOPOST"):
return
x = get_source_channels()
th = await e.get_chat()
if str(th.id) not in x:
if get_peer_id(th) not in x:
return
y = get_destinations()
for ys in y:
try:
await ultroid_bot.send_message(int(ys), e.message)
await e.client.send_message(int(ys), e.message)
except Exception as ex:
await asst.send_message(int(udB.get_key("LOG_CHANNEL")), str(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)


@ultroid_cmd(pattern="shift (.*)")
Expand All @@ -76,44 +83,43 @@ async def _(e):
z = await e.eor(get_string("com_1"))
a, b = x.split("|")
try:
c = int(a)
c = await e.client.parse_id(a)
except Exception:
try:
c = (await e.client.get_entity(a)).id
except Exception:
await z.edit(get_string("cha_1"))
return
await z.edit(get_string("cha_1"))
return
try:
d = int(b)
except Exception:
try:
d = (await e.client.get_entity(b)).id
except Exception:
await z.edit(get_string("cha_1"))
return
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 BaseException:
pass
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")


@ultroid_cmd(pattern="asource (.*)")
async def source(e):
x = e.pattern_match.group(1)
try:
y = int(x)
except Exception:
if not x:
y = e.chat_id
else:
try:
y = int((await ultroid_bot.get_entity(x)).id)
except Exception as es:
print(es)
y = await e.client.parse_id(x)
except Exception as er:
LOGS.exception(er)
return
if not is_source_channel_added(y):
add_source_channel(y)
await e.eor(get_string("cha_2"))
ultroid_bot.add_handler(autopost_func, events.NewMessage())
elif is_source_channel_added(y):
await e.eor(get_string("cha_3"))

Expand All @@ -127,14 +133,14 @@ async def dd(event):
udB.del_key("CH_SOURCE")
await x.edit(get_string("cha_4"))
return
try:
y = int(chat_id)
except Exception:
if chat_id:
try:
y = int((await event.client.get_entity(chat_id)).id)
except Exception as es:
print(es)
y = await e.client.parse_id(chat_id)
except Exception as er:
LOGS.exception(er)
return
else:
y = event.chat_id
if is_source_channel_added(y):
rem_source_channel(y)
await eor(x, get_string("cha_5"), time=3)
Expand All @@ -148,15 +154,15 @@ async def dd(event):
@ultroid_cmd(pattern="listsource")
async def list_all(event):
x = await event.eor(get_string("com_1"))
channels = get_source_channels()
num = get_no_source_channels()
if num == 0:
if not num:
return await eor(x, "No chats were added.", time=5)
msg = get_string("cha_8")
channels = get_source_channels()
for channel in channels:
name = ""
try:
name = (await event.client.get_entity(int(channel))).title
name = get_display_name(await event.client.get_entity(int(channel)))
except BaseException:
name = ""
msg += f"\n=> **{name}** [`{channel}`]"
Expand All @@ -181,14 +187,14 @@ async def list_all(event):
@ultroid_cmd(pattern="adest (.*)")
async def destination(e):
x = e.pattern_match.group(1)
try:
y = int(x)
except Exception:
if x:
try:
y = int((await e.client.get_entity(x)).id)
except Exception as es:
print(es)
y = await e.client.parse_id(x)
except Exception as er:
LOGS.exception(er)
return
else:
y = e.chat_id
if not is_destination_added(y):
add_destination(y)
await e.eor("Destination added succesfully")
Expand All @@ -205,14 +211,14 @@ async def dd(event):
udB.del_key("CH_DESTINATION")
await x.edit("Destinations database cleared.")
return
try:
y = int(chat_id)
except Exception:
if chat_id:
try:
y = int((await event.client.get_entity(chat_id)).id)
except Exception as es:
print(es)
y = await e.client.parse_id(chat_id)
except Exception as er:
LOGS.exception(er)
return
else:
y = event.chat_id
if is_destination_added(y):
rem_destination(y)
await eor(x, "Destination removed from database")
Expand All @@ -235,7 +241,7 @@ async def list_all(event):
for channel in channels:
name = ""
try:
name = (await ultroid_bot.get_entity(int(channel))).title
name = get_display_name(await ultroid_bot.get_entity(int(channel)))
except BaseException:
name = ""
msg += f"\n=> **{name}** [`{channel}`]"
Expand All @@ -255,3 +261,7 @@ async def list_all(event):
await x.delete()
else:
await x.edit(msg)


if udB.get_key("AUTOPOST"):
ultroid_bot.add_handler(autopost_func, events.NewMessage())
3 changes: 2 additions & 1 deletion plugins/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,12 @@ async def _(event):
fullsudo=True,
)
async def _(event):
GDrive = GDriveManager()
if not os.path.exists(GDrive.token_file):
return await event.eor(get_string("gdrive_6").format(asst.me.username))
if GDrive.folder_id:
await event.eor(
"`Here is Your G-Drive Folder link : `\n"
"`Your G-Drive Folder link : `\n"
+ "https://drive.google.com/folderview?id="
+ GDrive.folder_id,
)
Expand Down
11 changes: 7 additions & 4 deletions plugins/glitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
•`{i}glitch <replt to media>`
Expand All @@ -27,11 +26,15 @@ async def _(e):
reply = await e.get_reply_message()
if not (reply and reply.media):
return await e.eor(get_string("cvt_3"))
xx = await e.eor(get_string("glitch_1"))
wut = mediainfo(reply.media)
if not wut.startswith(("pic", "sticker")):
return await e.eor(get_string("com_4"))
xx = await e.eor(get_string("glitch_1"))
ok = await e.client.download_media(reply.media)
if reply.document and reply.document.thumbs:
ok = await reply.download_media(thumb=-1)
else:
return await xx.eor(get_string("com_4"))
else:
ok = await reply.download_media()
cmd = f"glitch_me gif --line_count 200 -f 10 -d 50 '{ok}' ult.gif"
stdout, stderr = await bash(cmd)
await e.reply(file="ult.gif", force_document=False)
Expand Down
Loading

0 comments on commit d82cc7d

Please sign in to comment.