diff --git a/Dockerfile b/Dockerfile
index bacc310..0d27297 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,17 +4,18 @@
# PLease read the GNU Affero General Public License in .
FROM ultroidteam/ultroid:0.0.3
-RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
- dpkg -i ./google-chrome-stable_current_amd64.deb; apt -fqqy install && \
- rm ./google-chrome-stable_current_amd64.deb
-RUN wget -O chromedriver.zip http://chromedriver.storage.googleapis.com/$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip && \
- unzip chromedriver.zip chromedriver -d /usr/bin/ && \
- rm chromedriver.zip
+#RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
+# dpkg -i ./google-chrome-stable_current_amd64.deb; apt -fqqy install && \
+# rm ./google-chrome-stable_current_amd64.deb
+#RUN wget -O chromedriver.zip http://chromedriver.storage.googleapis.com/$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip && \
+# unzip chromedriver.zip chromedriver -d /usr/bin/ && \
+# rm chromedriver.zip
RUN curl --silent --location https://deb.nodesource.com/setup_15.x | bash -
-RUN apt-get install -y nodejs sudo
+RUN apt-get install -y nodejs
RUN git clone https://github.com/TeamUltroid/Ultroid.git /root/TeamUltroid/
-WORKDIR /root/TeamUltroid/
RUN git clone https://github.com/1Danish-00/glitch_me.git && pip install -e ./glitch_me
+WORKDIR /root/TeamUltroid/
RUN pip install -r requirements.txt
-RUN npm install -g npm@7.7.0 && npm install
+RUN rm -rf /usr/local/lib/python3.9/site-packages/.wh*
+RUN npm install -g npm@7.9.0 && npm install
RUN npm run build
diff --git a/README.md b/README.md
index 6fc40dd..25dcd36 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
### Local Deploy - Easy Method
- Linux - `bash -c "$(curl -fsSL https://git.io/JY9UM)"`
- Windows - `cd desktop ; wget https://del.dog/raw/ultroid-termux -o locals.py ; python locals.py`
-- Termux - `sh -c "$(curl -fsSL https://del.dog/raw/ultroid-termux)"`
+- Termux - `sh -c "$(curl -fsSL https://del.dog/raw/ultroid-termux-deploy)"`
### Local Deploy - Traditional Method
- Get your [Necessary Variables](#Necessary-Variables)
diff --git a/assistant/inlinestuff.py b/assistant/inlinestuff.py
index fd60bcf..3d61829 100644
--- a/assistant/inlinestuff.py
+++ b/assistant/inlinestuff.py
@@ -121,7 +121,7 @@ async def _(e):
text=f"**File:**\n{file_name}",
buttons=bitton,
)
- except:
+ except BaseException:
lnk = e.builder.article(
title="fl2lnk",
text="File not found",
diff --git a/assistant/othervars.py b/assistant/othervars.py
index 8df87a1..7b9b6fb 100644
--- a/assistant/othervars.py
+++ b/assistant/othervars.py
@@ -783,12 +783,43 @@ async def chbot(event):
buttons=[
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oɴ", data="onchbot")],
[Button.inline("Cʜᴀᴛ Bᴏᴛ Oғғ", data="ofchbot")],
+ [Button.inline("Bᴏᴛ Wᴇʟᴄᴏɴᴇ", data="bwel")],
[Button.inline("« Bᴀᴄᴋ", data="setter")],
],
link_preview=False,
)
+@callback("bwel")
+@owner
+async def name(event):
+ await event.delete()
+ pru = event.sender_id
+ var = "STARTMSG"
+ name = "Bot Welcome Message:"
+ async with event.client.conversation(pru) as conv:
+ await conv.send_message(
+ "**BOT WELCOME MSG**\nEnter the msg which u want to show when someone start your assistant Bot.\n\nUse /cancel to terminate the operation.",
+ )
+ 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("chatbot"),
+ )
+ else:
+ await setit(event, var, themssg)
+ await conv.send_message(
+ "{} changed to {}".format(
+ name,
+ themssg,
+ ),
+ buttons=get_back_button("chatbot"),
+ )
+
+
@callback("onchbot")
@owner
async def chon(event):
diff --git a/assistant/start.py b/assistant/start.py
index 1d0c38b..9d1dd3e 100644
--- a/assistant/start.py
+++ b/assistant/start.py
@@ -10,6 +10,7 @@ from datetime import datetime
from pyUltroid.functions.asst_fns import *
from pyUltroid.misc._decorators import sed
from telethon import Button, events
+from telethon.utils import get_display_name
from plugins import *
@@ -28,14 +29,23 @@ async def assistant(event):
if not is_added(event.sender_id) and event.sender_id not in sed:
add_user(event.sender_id)
ok = ""
- if udB.get("PMBOT") == "True":
- ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
if event.is_private and event.sender_id in sed:
return
- await event.reply(
- f"Hey there, this is Ultroid Assistant of {OWNER_NAME}!\n\n{ok}",
- buttons=[Button.url("Know More", url="https://t.me/TeamUltroid")],
- )
+ if not udB.get("STARTMSG"):
+ if udB.get("PMBOT") == "True":
+ ok = "You can contact my master using this bot!!\n\nSend your Message, I will Deliver it To Master."
+ await event.reply(
+ f"Hey there, this is Ultroid Assistant of {OWNER_NAME}!\n\n{ok}",
+ buttons=[Button.url("Know More", url="https://t.me/TeamUltroid")],
+ )
+ else:
+ u = await event.client.get_entity(event.chat_id)
+ me = f"[{ultroid_bot.me.first_name}](tg://user?id={ultroid_bot.uid})"
+ mention = f"[{get_display_name(u)}](tg://user?id={u.id})"
+ await event.reply(
+ Redis("STARTMSG").format(me=me, mention=mention),
+ buttons=[Button.url("Know More", url="https://t.me/TeamUltroid")],
+ )
@asst_cmd("start ?(.*)")
diff --git a/plugins/_help.py b/plugins/_help.py
index 801fdef..1a01a43 100644
--- a/plugins/_help.py
+++ b/plugins/_help.py
@@ -26,7 +26,7 @@ async def ult(ult):
output = f"**Plugin** - `{plug}`\n"
for i in HELP[plug]:
output += i
- output += "\n© @TheUltroid"
+ output += "\n© @TeamUltroid"
await eor(ult, output)
elif plug in CMD_HELP:
kk = f"Plugin Name-{plug}\n\n✘ Commands Available -\n\n"
diff --git a/plugins/_tagnotifs.py b/plugins/_tagnotifs.py
index ed1e7b2..cbc30ae 100644
--- a/plugins/_tagnotifs.py
+++ b/plugins/_tagnotifs.py
@@ -18,8 +18,11 @@ from . import *
),
)
async def all_messages_catcher(e):
- if udB.get("TAG_LOG") is not None:
- NEEDTOLOG = int(udB.get("TAG_LOG"))
+ if udB.get("TAG_LOG"):
+ try:
+ NEEDTOLOG = int(udB.get("TAG_LOG"))
+ except Exception:
+ return LOGS.warning("you given Wrong Grp/Channel ID in TAG_LOG.")
x = await ultroid_bot.get_entity(e.sender_id)
if x.bot or x.verified:
return
diff --git a/plugins/admintools.py b/plugins/admintools.py
index 964d9a3..2b5b8c5 100644
--- a/plugins/admintools.py
+++ b/plugins/admintools.py
@@ -30,6 +30,12 @@
• `{i}unpin (all) `
Unpin the message(s) in the chat.
+• `{i}pinned`
+ Get pinned message in the current chat.
+
+• `{i}listpinned`
+ Get all pinned messages in current chat.
+
• `{i}purge `
Purge all messages from the replied message.
@@ -51,7 +57,7 @@ import asyncio
from telethon.errors import BadRequestError
from telethon.errors.rpcerrorlist import UserIdInvalidError
from telethon.tl.functions.channels import EditAdminRequest
-from telethon.tl.types import ChatAdminRights
+from telethon.tl.types import ChatAdminRights, InputMessagesFilterPinned
from . import *
@@ -427,4 +433,48 @@ async def editer(edit):
i = i + 1
+@ultroid_cmd(pattern="pinned")
+async def get_pinned(event):
+ x = await eor(event, get_string("com_1"))
+ chat_id = (str(event.chat_id)).replace("-100", "")
+ chat_name = (await event.get_chat()).title
+ tem = ""
+ c = 0
+
+ async for i in ultroid.iter_messages(
+ event.chat_id, filter=InputMessagesFilterPinned
+ ):
+ c += 1
+ tem += f"The pinned message in {chat_name} can be found here."
+ if c == 1:
+ return await x.edit(tem, parse_mode="html")
+
+ if tem == "":
+ return await eod(x, "There is no pinned message in chat!", time=5)
+
+
+@ultroid_cmd(pattern="listpinned")
+async def get_all_pinned(event):
+ x = await eor(event, get_string("com_1"))
+ chat_id = (str(event.chat_id)).replace("-100", "")
+ chat_name = (await event.get_chat()).title
+ a = ""
+ c = 1
+ async for i in ultroid.iter_messages(
+ event.chat_id, filter=InputMessagesFilterPinned
+ ):
+ a += f"{c}. Go to message.\n"
+ c += 1
+
+ if c == 1:
+ m = f"The pinned message in {chat_name}:\n\n"
+ else:
+ m = f"List of pinned message(s) in {chat_name}:\n\n"
+
+ if a == "":
+ return await eod(x, "There is no message pinned in this group!", time=5)
+
+ await x.edit(m + a, parse_mode="html")
+
+
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
diff --git a/plugins/afk.py b/plugins/afk.py
index e7599ae..ef210de 100644
--- a/plugins/afk.py
+++ b/plugins/afk.py
@@ -42,6 +42,10 @@ LOG = Var.LOG_CHANNEL
@ultroid_bot.on(events.NewMessage(outgoing=True))
@ultroid_bot.on(events.MessageEdited(outgoing=True))
async def set_not_afk(event):
+ if event.is_private:
+ if Redis("PMSETTING") == "True":
+ if not is_approved(event.chat_id):
+ return
global USER_AFK
global afk_time
global last_afk_message
@@ -106,11 +110,10 @@ async def set_not_afk(event):
events.NewMessage(incoming=True, func=lambda e: bool(e.mentioned or e.is_private)),
)
async def on_afk(event):
- if event.fwd_from:
- return
if event.is_private:
- if not is_approved(event.chat_id):
- return
+ if Redis("PMSETTING") == "True":
+ if not is_approved(event.chat_id):
+ return
global USER_AFK
global afk_time
global last_afk_message
@@ -156,8 +159,6 @@ async def on_afk(event):
@ultroid_cmd(pattern=r"afk ?(.*)")
async def _(event):
- if event.fwd_from:
- return
reply = await event.get_reply_message()
global USER_AFK
global afk_time
diff --git a/plugins/blacklist.py b/plugins/blacklist.py
index ee90241..6922833 100644
--- a/plugins/blacklist.py
+++ b/plugins/blacklist.py
@@ -34,7 +34,7 @@ async def af(e):
if e.is_group:
if not e._chat.admin_rights:
return await eod(e, "`You are Not Admin Here`")
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
chat = e.chat_id
if not (wrd):
return await eod(e, "`Give the word to blacklist..`")
@@ -48,7 +48,7 @@ async def rf(e):
if e.is_group:
if not e._chat.admin_rights:
return await eod(e, "`You are Not Admin Here`")
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
chat = e.chat_id
if not wrd:
return await eod(e, "`Give the word to remove from blacklist..`")
@@ -71,12 +71,9 @@ async def lsnote(e):
@ultroid_bot.on(events.NewMessage(incoming=True))
async def bl(e):
- if e.is_group:
- if not e._chat.admin_rights:
- return
- xx = e.text
chat = e.chat_id
x = get_blacklist(int(chat))
+ xx = (e.text).lower()
if x and xx:
if " " in xx:
xx = xx.split(" ")
diff --git a/plugins/bot.py b/plugins/bot.py
index c815043..af1cdd7 100644
--- a/plugins/bot.py
+++ b/plugins/bot.py
@@ -124,7 +124,11 @@ async def cmds(event):
pattern="restart$",
)
async def restartbt(ult):
- await restart(ult)
+ if not Var.HEROKU_API:
+ await eor(ult, "`Restarting..`")
+ await bash("pkill python3 && python3 -m pyUltroid")
+ else:
+ await restart(ult)
@ultroid_cmd(
@@ -144,6 +148,7 @@ async def _(ult):
await ultroid.send_file(
ult.chat_id,
file="ultroid.log",
+ thumb="resources/extras/logo_rdm.png",
caption=f"**Ultroid Logs.**\nPasted [here](https://nekobin.com/{key}) too!",
)
await xx.edit("Done")
diff --git a/plugins/broadcast.py b/plugins/broadcast.py
index c75ae9c..980752c 100644
--- a/plugins/broadcast.py
+++ b/plugins/broadcast.py
@@ -32,8 +32,9 @@ from . import *
@ultroid_cmd(pattern="add ?(.*)", allow_sudo=False)
async def broadcast_adder(event):
- if not event.text[4] == " ": # weird fix
- return
+ if len(event.text) > 4:
+ if not event.text[4] == " ": # weird fix
+ return
msgg = event.pattern_match.group(1)
x = await eor(event, get_string("bd_1"))
aldone = new = crsh = 0
@@ -93,8 +94,9 @@ async def broadcast_adder(event):
@ultroid_cmd(pattern="rem ?(.*)", allow_sudo=False)
async def broadcast_remover(event):
- if not event.text[4] == " ": # weird fix
- return
+ if len(event.text) > 4:
+ if not event.text[4] == " ": # weird fix
+ return
chat_id = event.pattern_match.group(1)
x = await eor(event, get_string("com_1"))
if chat_id == "all":
@@ -130,7 +132,7 @@ async def list_all(event):
name = ""
try:
name = (await ultroid.get_entity(int(channel))).title
- except:
+ except BaseException:
name = ""
msg += f"=> **{name}** [`{channel}`]\n"
msg += f"\nTotal {get_no_channels()} channels."
diff --git a/plugins/channelhacks.py b/plugins/channelhacks.py
index 7aa8931..2727d9f 100644
--- a/plugins/channelhacks.py
+++ b/plugins/channelhacks.py
@@ -88,9 +88,9 @@ async def _(e):
return
async for msg in ultroid_bot.iter_messages(int(c), reverse=True):
try:
- await asyncio.sleep(0.5)
+ await asyncio.sleep(0.7)
await ultroid_bot.send_message(int(d), msg)
- except:
+ except BaseException:
pass
await z.edit("Done")
@@ -158,7 +158,7 @@ async def list_all(event):
name = ""
try:
name = (await ultroid.get_entity(int(channel))).title
- except:
+ except BaseException:
name = ""
msg += f"=> **{name}** [`{channel}`]\n"
msg += f"\nTotal {get_no_source_channels()} channels."
@@ -242,7 +242,7 @@ async def list_all(event):
name = ""
try:
name = (await ultroid.get_entity(int(channel))).title
- except:
+ except BaseException:
name = ""
msg += f"=> **{name}** [`{channel}`]\n"
msg += f"\nTotal {get_no_destinations()} channels."
diff --git a/plugins/core.py b/plugins/core.py
index be0bf0d..a33e50c 100644
--- a/plugins/core.py
+++ b/plugins/core.py
@@ -42,7 +42,7 @@ async def inline_handler(event):
input_str = event.pattern_match.group(1)
plug = [*PLUGINS]
plugs = []
- if input_str == None or input_str == "":
+ if input_str is None or input_str == "":
for i in plug:
try:
plugs.append(
diff --git a/plugins/dm.py b/plugins/dm.py
index 49a9168..ec41f5d 100644
--- a/plugins/dm.py
+++ b/plugins/dm.py
@@ -16,6 +16,9 @@ from . import *
@ultroid_cmd(pattern="dm ?(.*)")
async def dm(e):
+ if len(e.text) > 3:
+ if not e.text[3] == " ": # weird fix
+ return
d = e.pattern_match.group(1)
c = d.split(" ")
try:
diff --git a/plugins/filter.py b/plugins/filter.py
index a2415af..f41e044 100644
--- a/plugins/filter.py
+++ b/plugins/filter.py
@@ -14,7 +14,7 @@
• `{i}remfilter `
Remove the filtered user..
-• `{i}listfilters`
+• `{i}listfilter`
list all filters.
"""
@@ -29,15 +29,11 @@ from . import *
@ultroid_cmd(pattern="addfilter ?(.*)")
async def af(e):
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
wt = await e.get_reply_message()
chat = e.chat_id
if not (wt and wrd):
return await eor(e, "`Use this command word to set as filter and reply...`")
- try:
- rem_filter(int(chat), wrd)
- except:
- pass
if wt and wt.media:
wut = mediainfo(wt.media)
if wut.startswith(("pic", "gif")):
@@ -65,7 +61,7 @@ async def af(e):
@ultroid_cmd(pattern="remfilter ?(.*)")
async def rf(e):
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
chat = e.chat_id
if not wrd:
return await eor(e, "`Give the filter to remove..`")
@@ -85,7 +81,7 @@ async def lsnote(e):
@ultroid_bot.on(events.NewMessage())
async def fl(e):
- xx = e.text
+ xx = (e.text).lower()
chat = e.chat_id
x = get_filter(int(chat))
if x:
diff --git a/plugins/glitch.py b/plugins/glitch.py
index f006b7e..5f50020 100644
--- a/plugins/glitch.py
+++ b/plugins/glitch.py
@@ -22,8 +22,11 @@ from . import *
@ultroid_cmd(pattern="glitch$")
async def _(e):
reply = await e.get_reply_message()
- if not reply.media:
- return await eor(e, "reply to any media")
+ if not (reply and reply.media):
+ return await eor(e, "Reply to any media")
+ wut = mediainfo(reply.media)
+ if not wut.startswith(("pic", "sticker")):
+ return await eor(e, "`Unsupported Media`")
xx = await eor(e, "`Gliching...`")
ok = await bot.download_media(reply.media)
cmd = f"glitch_me gif --line_count 200 -f 10 -d 50 '{ok}' ult.gif"
diff --git a/plugins/globaltools.py b/plugins/globaltools.py
index d8bce79..69736fb 100644
--- a/plugins/globaltools.py
+++ b/plugins/globaltools.py
@@ -66,7 +66,7 @@ async def _(e):
try:
await e.client.edit_permissions(ggban.id, userid, view_messages=True)
chats += 1
- except:
+ except BaseException:
pass
ungban(userid)
await xx.edit(
@@ -113,7 +113,7 @@ async def _(e):
try:
await e.client.edit_permissions(ggban.id, userid, view_messages=False)
chats += 1
- except:
+ except BaseException:
pass
gban(userid)
await xx.edit(
@@ -139,7 +139,7 @@ async def gcast(event):
try:
done += 1
await ultroid_bot.send_message(chat, msg)
- except:
+ except BaseException:
er += 1
await kk.edit(f"Done in {done} chats, error in {er} chat(s)")
@@ -162,7 +162,7 @@ async def gucast(event):
try:
done += 1
await ultroid_bot.send_message(chat, msg)
- except:
+ except BaseException:
er += 1
await kk.edit(f"Done in {done} chats, error in {er} chat(s)")
@@ -200,7 +200,7 @@ async def gkick(e):
try:
await ultroid_bot.kick_participant(gkick.id, userid)
chats += 1
- except:
+ except BaseException:
pass
await xx.edit(f"`Gkicked` [{name}](tg://user?id={userid}) `in {chats} chats.`")
@@ -240,7 +240,7 @@ async def _(e):
try:
await e.client.edit_permissions(onmute.id, userid, send_messages=False)
chats += 1
- except:
+ except BaseException:
pass
gmute(userid)
await xx.edit(f"`Gmuted` [{name}](tg://user?id={userid}) `in {chats} chats.`")
@@ -277,7 +277,7 @@ async def _(e):
try:
await e.client.edit_permissions(hurr.id, userid, send_messages=True)
chats += 1
- except:
+ except BaseException:
pass
ungmute(userid)
await xx.edit(f"`Ungmuted` [{name}](tg://user?id={userid}) `in {chats} chats.`")
@@ -299,7 +299,7 @@ async def _(e):
gban_watch = f"`Gbanned User` [{user.first_name}](tg://user?id={user.id}) `Spotted\n"
gban_watch += f"Banned Successfully`"
await e.reply(gban_watch)
- except:
+ except BaseException:
pass
diff --git a/plugins/google.py b/plugins/google.py
index ff3f4ed..9f3ebca 100644
--- a/plugins/google.py
+++ b/plugins/google.py
@@ -77,7 +77,7 @@ async def goimg(event):
}
pth = gi.download(args)
ok = pth[0][query]
- await event.client.send_file(event.chat_id, ok, album=True)
+ await event.client.send_file(event.chat_id, ok, caption=query, album=True)
rmtree(f"./resources/downloads/{query}/")
await nn.delete()
diff --git a/plugins/greetings.py b/plugins/greetings.py
index 2c7b990..8158b38 100644
--- a/plugins/greetings.py
+++ b/plugins/greetings.py
@@ -15,7 +15,7 @@
• `{i}clearwelcome`
Delete the welcome in the current chat.
-• `{i}getwelcome`
+• `{i}getwelcome`
Get the welcome message in the current chat.
---- GoodByes ----
@@ -25,13 +25,10 @@
• `{i}cleargoodbye`
Delete the goodbye in the current chat.
-• `{i}getgoodbye`
+• `{i}getgoodbye`
Get the goodbye message in the current chat.
"""
-Note = "\n\nNote: `{mention}`, `{group}`, `{count}`, `{name}`, `{fullname}`, `{username}`, `{userid}` can be used as formatting parameters.\n\n"
-
-
import os
from telegraph import upload_file as uf
@@ -39,6 +36,8 @@ from telethon.utils import get_display_name, pack_bot_file_id
from . import *
+Note = "\n\nNote: `{mention}`, `{group}`, `{count}`, `{name}`, `{fullname}`, `{username}`, `{userid}` can be used as formatting parameters.\n\n"
+
@ultroid_cmd(pattern="setwelcome")
async def setwel(event):
@@ -68,7 +67,7 @@ async def setwel(event):
else:
add_welcome(event.chat_id, None, m)
await eor(x, "`Welcome note saved`")
- elif r.text:
+ elif r and r.text:
add_welcome(event.chat_id, r.message, None)
await eor(x, "`Welcome note saved`")
else:
@@ -119,18 +118,21 @@ async def _(event):
msgg = wel["welcome"]
med = wel["media"]
userid = user.id
- await event.reply(
- msgg.format(
- mention=mention,
- group=title,
- count=count,
- name=name,
- fullname=fullname,
- username=username,
- userid=userid,
- ),
- file=med,
- )
+ if msgg:
+ await event.reply(
+ msgg.format(
+ mention=mention,
+ group=title,
+ count=count,
+ name=name,
+ fullname=fullname,
+ username=username,
+ userid=userid,
+ ),
+ file=med,
+ )
+ else:
+ await event.reply(file=med)
@ultroid_cmd(pattern="setgoodbye")
@@ -161,7 +163,7 @@ async def setgb(event):
else:
add_goodbye(event.chat_id, None, m)
await eor(x, "`Goodbye note saved`")
- elif r.text:
+ elif r and r.text:
add_goodbye(event.chat_id, r.message, None)
await eor(x, "`Goddbye note saved`")
else:
@@ -212,18 +214,21 @@ async def _(event):
msgg = wel["goodbye"]
med = wel["media"]
userid = user.id
- await event.reply(
- msgg.format(
- mention=mention,
- group=title,
- count=count,
- name=name,
- fullname=fullname,
- username=username,
- userid=userid,
- ),
- file=med,
- )
+ if msgg:
+ await event.reply(
+ msgg.format(
+ mention=mention,
+ group=title,
+ count=count,
+ name=name,
+ fullname=fullname,
+ username=username,
+ userid=userid,
+ ),
+ file=med,
+ )
+ else:
+ await event.reply(file=med)
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}" + Note})
diff --git a/plugins/groups.py b/plugins/groups.py
index 8301590..e81b1cc 100644
--- a/plugins/groups.py
+++ b/plugins/groups.py
@@ -17,10 +17,16 @@
from telethon.tl import functions
-from telethon.tl.types import (ChannelParticipantsKicked, ChatBannedRights,
- UserStatusEmpty, UserStatusLastMonth,
- UserStatusLastWeek, UserStatusOffline,
- UserStatusOnline, UserStatusRecently)
+from telethon.tl.types import (
+ ChannelParticipantsKicked,
+ ChatBannedRights,
+ UserStatusEmpty,
+ UserStatusLastMonth,
+ UserStatusLastWeek,
+ UserStatusOffline,
+ UserStatusOnline,
+ UserStatusRecently,
+)
from . import *
@@ -41,7 +47,7 @@ async def _(event):
try:
await event.client.edit_permissions(event.chat_id, i, view_messages=True)
p += 1
- except:
+ except BaseException:
pass
await eod(xx, "{title}: {p} unbanned")
@@ -83,7 +89,7 @@ async def _(event):
)
c += 1
y -= 1
- except:
+ except BaseException:
pass
if isinstance(i.status, UserStatusLastMonth):
m += 1
@@ -94,7 +100,7 @@ async def _(event):
)
c += 1
m -= 1
- except:
+ except BaseException:
pass
if isinstance(i.status, UserStatusLastWeek):
w += 1
@@ -105,7 +111,7 @@ async def _(event):
)
c += 1
w -= 1
- except:
+ except BaseException:
pass
if isinstance(i.status, UserStatusOffline):
o += 1
@@ -116,7 +122,7 @@ async def _(event):
)
c += 1
o -= 1
- except:
+ except BaseException:
pass
if isinstance(i.status, UserStatusOnline):
q += 1
@@ -127,7 +133,7 @@ async def _(event):
)
c += 1
q -= 1
- except:
+ except BaseException:
pass
if isinstance(i.status, UserStatusRecently):
r += 1
@@ -138,7 +144,7 @@ async def _(event):
)
c += 1
r -= 1
- except:
+ except BaseException:
pass
if i.bot:
b += 1
@@ -149,7 +155,7 @@ async def _(event):
)
c += 1
b -= 1
- except:
+ except BaseException:
pass
elif i.deleted:
d += 1
@@ -160,7 +166,7 @@ async def _(event):
)
c += 1
d -= 1
- except:
+ except BaseException:
pass
elif i.status is None:
n += 1
@@ -171,7 +177,7 @@ async def _(event):
)
c += 1
n -= 1
- except:
+ except BaseException:
pass
required_string = ""
if input_str:
diff --git a/plugins/mediainfo.py b/plugins/mediainfo.py
new file mode 100644
index 0000000..ebfe9bc
--- /dev/null
+++ b/plugins/mediainfo.py
@@ -0,0 +1,38 @@
+# Ultroid - UserBot
+# Copyright (C) 2020 TeamUltroid
+#
+# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
+# PLease read the GNU Affero General Public License in
+# .
+
+"""
+✘ Commands Available -
+
+• `{i}mediainfo `
+ To get info about it.
+"""
+
+import os
+
+from . import *
+
+
+
+@ultroid_cmd(pattern="mediainfo$")
+async def mi(e):
+ r = await e.get_reply_message()
+ if not (r and r.media):
+ return await eod(e, "`Reply to any media`")
+ xx = mediainfo(r.media)
+ murl = r.media.stringify()
+ url = html("Mediainfo", "Ultroid", f"{murl}")
+ ee = await eor(e, f"**[{xx}]({url})**\n\n`Loading More...`", link_preview=False)
+ dl = await ultroid_bot.download_media(r.media)
+ out, er = await bash(f"mediainfo {dl}")
+ os.remove(dl)
+ if er:
+ return await ee.edit(f"**[{xx}]({url})**", link_preview=False)
+ await ee.edit(f"**[{xx}]({url})**\n\n{out}")
+
+
+HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})
diff --git a/plugins/mute.py b/plugins/mute.py
index 1ae42ee..e0110af 100644
--- a/plugins/mute.py
+++ b/plugins/mute.py
@@ -73,7 +73,7 @@ async def startmute(event):
return await eor(xx, "`No proper admin rights...`", time=5)
elif "creator" in vars(chat):
pass
- elif private == True:
+ elif private:
pass
else:
return await eod(xx, "`No proper admin rights...`", time=5)
@@ -128,11 +128,11 @@ async def _(e):
huh = e.text.split(" ")
try:
tme = huh[1]
- except:
+ except BaseException:
return await eod(xx, "`Time till mute?`", time=5)
try:
input = huh[2]
- except:
+ except BaseException:
pass
chat = await e.get_chat()
if e.reply_to_msg_id:
diff --git a/plugins/notes.py b/plugins/notes.py
index b31dd40..d973042 100644
--- a/plugins/notes.py
+++ b/plugins/notes.py
@@ -35,17 +35,13 @@ async def an(e):
if e.is_group:
if not e._chat.admin_rights:
return await eod(e, "`You Are Not Admin Here.", time=5)
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
wt = await e.get_reply_message()
chat = e.chat_id
if not (wt and wrd):
return await eod(e, "`Use this Command with Reply and word to use a note.`")
if "#" in wrd:
wrd = wrd.replace("#", "")
- try:
- rem_note(int(chat), wrd)
- except:
- pass
if wt and wt.media:
wut = mediainfo(wt.media)
if wut.startswith(("pic", "gif")):
@@ -77,7 +73,7 @@ async def rn(e):
if e.is_group:
if not e._chat.admin_rights:
return await eod(e, "`You Are Not Admin Here.", time=5)
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
chat = e.chat_id
if not wrd:
return await eod(e, "`Give me the note handler which you want to remove.`")
@@ -102,13 +98,10 @@ async def lsnote(e):
@ultroid_bot.on(events.NewMessage())
async def notes(e):
- if e.is_group:
- if not e._chat.admin_rights:
- return
xx = e.text
if not xx.startswith("#"):
return
- xx = xx.replace("#", "")
+ xx = (xx.replace("#", "")).lower()
chat = e.chat_id
x = get_notes(int(chat))
if x:
diff --git a/plugins/pmpermit.py b/plugins/pmpermit.py
index 6431ad8..2c548e5 100644
--- a/plugins/pmpermit.py
+++ b/plugins/pmpermit.py
@@ -19,8 +19,15 @@
• `{i}unblock`
To Unblock Someone in PM.
+
+• `{i}nologpm`
+ To stop logging from that user.
+
+• `{i}logpm`
+ Start logging again from that user.
"""
+from pyUltroid.functions.logusers_db import *
from pyUltroid.functions.pmpermit_db import *
from telethon import events
from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
@@ -82,15 +89,48 @@ PMCMDS = [
# =================================================================
-@ultroid_bot.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
+@ultroid_cmd(
+ pattern="logpm$",
+)
+async def _(e):
+ if not e.is_private:
+ return await eod(e, "`Use me in Private.`", time=3)
+ if is_logger(str(e.chat_id)):
+ nolog_user(str(e.chat_id))
+ return await eod(e, "`Now I Will log msgs from here.`", time=3)
+ else:
+ return await eod(e, "`Wasn logging msgs from here.`", time=3)
+
+
+@ultroid_cmd(
+ pattern="nologpm$",
+)
+async def _(e):
+ if not e.is_private:
+ return await eod(e, "`Use me in Private.`", time=3)
+ if not is_logger(str(e.chat_id)):
+ log_user(str(e.chat_id))
+ return await eod(e, "`Now I Won't log msgs from here.`", time=3)
+ else:
+ return await eod(e, "`Wasn't logging msgs from here.`", time=3)
+
+
+@ultroid_bot.on(
+ events.NewMessage(
+ incoming=True,
+ func=lambda e: e.is_private,
+ ),
+)
async def permitpm(event):
user = await event.get_chat()
if user.bot or user.is_self or user.verified:
return
+ if is_logger(user.id):
+ return
if Redis("PMLOG") == "True":
pl = udB.get("PMLOGGROUP")
if pl is not None:
- return await event.forward_to(pl)
+ return await event.forward_to(int(pl))
await event.forward_to(Var.LOG_CHANNEL)
@@ -99,7 +139,12 @@ if sett is None:
sett = True
if sett == "True" and sett != "False":
- @ultroid_bot.on(events.NewMessage(outgoing=True, func=lambda e: e.is_private))
+ @ultroid_bot.on(
+ events.NewMessage(
+ outgoing=True,
+ func=lambda e: e.is_private,
+ ),
+ )
async def autoappr(e):
miss = await e.get_chat()
if miss.bot or miss.is_self or miss.verified or Redis("AUTOAPPROVE") != "True":
@@ -123,7 +168,12 @@ if sett == "True" and sett != "False":
f"#AutoApproved\nßecoz of outgoing msg\nUser - [{name0}](tg://user?id={e.chat_id})",
)
- @ultroid_bot.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
+ @ultroid_bot.on(
+ events.NewMessage(
+ incoming=True,
+ func=lambda e: e.is_private,
+ ),
+ )
async def permitpm(event):
user = await event.get_chat()
if user.bot or user.is_self or user.verified:
@@ -147,6 +197,8 @@ if sett == "True" and sett != "False":
if user.id in LASTMSG:
prevmsg = LASTMSG[user.id]
if event.text != prevmsg:
+ if "PMSecurity" in event.text:
+ return
async for message in event.client.iter_messages(
user.id,
search=UND,
@@ -242,7 +294,9 @@ if sett == "True" and sett != "False":
f"[{name0}](tg://user?id={user.id}) was Blocked for spamming.",
)
- @ultroid_cmd(pattern="(a|approve)(?: |$)")
+ @ultroid_cmd(
+ pattern="(a|approve)(?: |$)",
+ )
async def approvepm(apprvpm):
if apprvpm.reply_to_msg_id:
reply = await apprvpm.get_reply_message()
@@ -301,7 +355,9 @@ if sett == "True" and sett != "False":
else:
await apprvpm.edit(NO_REPLY)
- @ultroid_cmd(pattern="(da|disapprove)(?: |$)")
+ @ultroid_cmd(
+ pattern="(da|disapprove)(?: |$)",
+ )
async def disapprovepm(e):
if e.reply_to_msg_id:
reply = await e.get_reply_message()
@@ -352,7 +408,9 @@ if sett == "True" and sett != "False":
else:
await e.edit(NO_REPLY)
- @ultroid_cmd(pattern="block$")
+ @ultroid_cmd(
+ pattern="block$",
+ )
async def blockpm(block):
if block.reply_to_msg_id:
reply = await block.get_reply_message()
@@ -391,7 +449,9 @@ if sett == "True" and sett != "False":
f"#BLOCKED\nUser: [{name0}](tg://user?id={uid})",
)
- @ultroid_cmd(pattern="unblock$")
+ @ultroid_cmd(
+ pattern="unblock$",
+ )
async def unblockpm(unblock):
if unblock.reply_to_msg_id:
reply = await unblock.get_reply_message()
diff --git a/plugins/profile.py b/plugins/profile.py
index 7a6bd5b..d79a1f3 100644
--- a/plugins/profile.py
+++ b/plugins/profile.py
@@ -28,8 +28,7 @@ import asyncio
import os
from telethon.tl import functions
-from telethon.tl.functions.photos import (DeletePhotosRequest,
- GetUserPhotosRequest)
+from telethon.tl.functions.photos import DeletePhotosRequest, GetUserPhotosRequest
from telethon.tl.types import InputPhoto
from . import *
diff --git a/plugins/snips.py b/plugins/snips.py
index a4f98e8..3584c01 100644
--- a/plugins/snips.py
+++ b/plugins/snips.py
@@ -31,16 +31,12 @@ from . import *
@ultroid_cmd(pattern="addsnip ?(.*)")
async def an(e):
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
wt = await e.get_reply_message()
if not (wt and wrd):
return await eor(e, "Give word to set as snip and reply to a message.")
if "$" in wrd:
wrd = wrd.replace("$", "")
- try:
- rem_snip(int(chat), wrd)
- except:
- pass
if wt and wt.media:
wut = mediainfo(wt.media)
if wut.startswith(("pic", "gif")):
@@ -69,7 +65,7 @@ async def an(e):
@ultroid_cmd(pattern="remsnip ?(.*)")
async def rs(e):
- wrd = e.pattern_match.group(1)
+ wrd = (e.pattern_match.group(1)).lower()
if not wrd:
return await eor(e, "Give the word to remove...")
if wrd.startswith("$"):
@@ -82,7 +78,7 @@ async def rs(e):
async def lsnote(e):
x = list_snip()
if x:
- sd = "SNIPS Found In This Chats Are\n\n"
+ sd = "SNIPS Found :\n\n"
await eor(e, sd + x)
else:
await eor(e, "No Snips Found Here")
@@ -90,7 +86,7 @@ async def lsnote(e):
@ultroid_bot.on(events.NewMessage(outgoing=True))
async def notes(e):
- xx = e.text
+ xx = (e.text).lower()
if not xx.startswith("$"):
return
xx = xx.replace("$", "")
diff --git a/plugins/stickertools.py b/plugins/stickertools.py
index f511485..3e5f2d9 100644
--- a/plugins/stickertools.py
+++ b/plugins/stickertools.py
@@ -39,10 +39,12 @@ from os import remove
import cv2
import numpy as np
from PIL import Image, ImageDraw
-from telethon.errors import (ChatSendInlineForbiddenError,
- ChatSendStickersForbiddenError)
-from telethon.tl.types import (DocumentAttributeFilename,
- DocumentAttributeSticker, MessageMediaPhoto)
+from telethon.errors import ChatSendInlineForbiddenError, ChatSendStickersForbiddenError
+from telethon.tl.types import (
+ DocumentAttributeFilename,
+ DocumentAttributeSticker,
+ MessageMediaPhoto,
+)
from . import *
@@ -231,7 +233,7 @@ async def hehe(args):
" A Telegram user has created the Sticker Set."
not in htmlstr
):
- async with ultroid_bot.conversation("Stickers") as conv:
+ async with ultroid_bot.conversation("@Stickers") as conv:
await conv.send_message("/addsticker")
await conv.get_response()
await ultroid_bot.send_read_acknowledge(conv.chat_id)
diff --git a/plugins/sudo.py b/plugins/sudo.py
index 3841bef..6e2c03b 100644
--- a/plugins/sudo.py
+++ b/plugins/sudo.py
@@ -30,18 +30,15 @@ from . import *
pattern="addsudo ?(.*)",
)
async def _(ult):
- if Var.BOT_MODE == True:
+ if Var.BOT_MODE:
try:
if ult.sender_id != Var.OWNER_ID:
- return await eor(
- ult,
- "You are sudo user, You cant add other sudo user.",
- )
+ return await eod(ult, "`Sudo users can't add new sudos!`", time=10)
except BaseException:
pass
else:
if ult.sender_id != ultroid_bot.uid:
- return await eor(ult, "You are sudo user, You cant add other sudo user.")
+ return await eod(ult, "`Sudo users can't add new sudos!`", time=10)
ok = await eor(ult, "`Updating SUDO Users List ...`")
if ult.reply_to_msg_id:
replied_to = await ult.get_reply_message()
@@ -60,7 +57,7 @@ async def _(ult):
f"**Added [{user.user.first_name}](tg://user?id={id}) as SUDO User**",
)
else:
- return await ok.edit("`SEEMS LIKE THIS FUNCTION CHOOSE TO BROKE ITSELF`")
+ return await ok.edit("`SEEMS LIKE THIS FUNCTION CHOOSE TO BREAK ITSELF`")
args = ult.pattern_match.group(1).strip()
@@ -115,7 +112,7 @@ async def _(ult):
pattern="delsudo ?(.*)",
)
async def _(ult):
- if Var.BOT_MODE == True:
+ if Var.BOT_MODE:
try:
if ult.sender_id != Var.OWNER_ID:
return await eor(
diff --git a/plugins/tools.py b/plugins/tools.py
index 37749a6..c1a7be8 100644
--- a/plugins/tools.py
+++ b/plugins/tools.py
@@ -46,8 +46,7 @@ import cv2
import emoji
from googletrans import Translator
from telethon.errors.rpcerrorlist import YouBlockedUserError
-from telethon.tl.types import (ChannelParticipantAdmin,
- ChannelParticipantsBots, User)
+from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantsBots, User
from telethon.utils import pack_bot_file_id
from . import *
diff --git a/plugins/updater.py b/plugins/updater.py
index be0228f..85e871d 100644
--- a/plugins/updater.py
+++ b/plugins/updater.py
@@ -86,9 +86,9 @@ async def upstream(ups):
repo = Repo.init()
origin = repo.create_remote("upstream", off_repo)
origin.fetch()
- repo.create_head("main", origin.refs.main)
- repo.heads.main.set_tracking_branch(origin.refs.main)
- repo.heads.main.checkout(True)
+ repo.create_head("dev", origin.refs.dev)
+ repo.heads.dev.set_tracking_branch(origin.refs.dev)
+ repo.heads.dev.checkout(True)
ac_br = repo.active_branch.name
try:
repo.create_remote("upstream", off_repo)
@@ -115,6 +115,7 @@ async def upstream(ups):
reply_to=ups.id,
)
remove(f"ultroid_updates.txt")
+ return
else:
return await eod(pagal, changelog_str, parse_mode="html")
else:
diff --git a/plugins/utilities.py b/plugins/utilities.py
index 1bf0764..104bace 100644
--- a/plugins/utilities.py
+++ b/plugins/utilities.py
@@ -67,10 +67,10 @@ from telegraph import upload_file as uf
from telethon import functions
from telethon.events import NewMessage
from telethon.tl.custom import Dialog
-from telethon.tl.functions.channels import LeaveChannelRequest
+from telethon.tl.functions.channels import LeaveChannelRequest, InviteToChannelRequest
+from telethon.tl.functions.messages import AddChatUserRequest
from telethon.tl.functions.photos import GetUserPhotosRequest
-from telethon.tl.types import (Channel, Chat, InputMediaPoll, Poll, PollAnswer,
- User)
+from telethon.tl.types import Channel, Chat, InputMediaPoll, Poll, PollAnswer, User
from telethon.utils import get_input_location
# =================================================================#
@@ -266,6 +266,8 @@ async def stats(
async def _(event):
xx = await eor(event, "` 《 Pasting to nekobin... 》 `")
input_str = "".join(event.text.split(maxsplit=1)[1:])
+ if not (input_str or event.is_reply):
+ return await xx.edit("`Reply to a Message/Document or Give me Some Text !`")
if input_str:
message = input_str
downloaded_file_name = None
@@ -408,7 +410,7 @@ async def _(ult):
for user_id in to_add_users.split(" "):
try:
await ultroid_bot(
- functions.messages.AddChatUserRequest(
+ AddChatUserRequest(
chat_id=ult.chat_id,
user_id=user_id,
fwd_limit=1000000,
@@ -421,7 +423,7 @@ async def _(ult):
for user_id in to_add_users.split(" "):
try:
await ultroid_bot(
- functions.channels.InviteToChannelRequest(
+ InviteToChannelRequest(
channel=ult.chat_id,
users=[user_id],
),
@@ -590,7 +592,7 @@ async def ipinfo(event):
ipaddr = ""
try:
ipaddr = ip[1]
- except:
+ except BaseException:
return await eod(xx, "`Give me an IP address you noob!`", time=5)
if ipaddr == "":
return
@@ -625,7 +627,7 @@ async def ipinfo(event):
tz,
),
)
- except:
+ except BaseException:
err = det["error"]["title"]
msg = det["error"]["messsage"]
await eod(xx, f"ERROR:\n{err}\n{msg}")
diff --git a/plugins/vcplugin.py b/plugins/vcplugin.py
index 7779801..b3c408d 100644
--- a/plugins/vcplugin.py
+++ b/plugins/vcplugin.py
@@ -33,8 +33,7 @@
"""
-from pyUltroid.functions.vc_sudos import (add_vcsudo, del_vcsudo, get_vcsudos,
- is_vcsudo)
+from pyUltroid.functions.vc_sudos import add_vcsudo, del_vcsudo, get_vcsudos, is_vcsudo
from telethon.tl.functions.channels import GetFullChannelRequest as getchat
from telethon.tl.functions.phone import CreateGroupCallRequest as startvc
from telethon.tl.functions.phone import DiscardGroupCallRequest as stopvc
@@ -72,8 +71,11 @@ async def _(e):
pattern="playvc$",
)
async def _(e):
- await eor(e, "`VC bot started...`")
- await bash("npm start")
+ zz = await eor(e, "`VC bot started...`")
+ er, out = await bash("npm start")
+ LOGS.warning(er)
+ LOGS.info(out)
+ await zz.edit(f"Failed {er}")
@ultroid_cmd(
@@ -92,7 +94,7 @@ async def _(e):
try:
await e.client(invitetovc(call=await get_call(e), users=p))
z += 6
- except:
+ except BaseException:
pass
await ok.edit(f"`Invited {z} users`")
diff --git a/plugins/webshot.py b/plugins/webshot.py
index b8d7b1f..7c58c7c 100644
--- a/plugins/webshot.py
+++ b/plugins/webshot.py
@@ -43,7 +43,7 @@ async def webss(event):
ok = requests.get(lnk).json()
try:
sshot = ok["screenshot"]
- except:
+ except BaseException:
return await eod(xx, "Something Went Wrong :(", time=10)
await xx.reply(
f"**WebShot Generated**\n**URL**: {xurl}",
diff --git a/requirements.txt b/requirements.txt
index 2922402..9fe8617 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,11 @@
-py-Ultroid
+py-Ultroid==2021.4.15
gingerit
Telethon==1.21.1
git+https://github.com/buddhhu/search-engine-parser.git
git+https://github.com/buddhhu/ofox.git
git+https://github.com/ProgrammingError/rextester_py.git
+google-assistant-grpc
+tenacity
+google-assistant-sdk
+
+
diff --git a/resources/extras/local-requirements.txt b/resources/extras/local-requirements.txt
index 632d9f9..0de09ff 100644
--- a/resources/extras/local-requirements.txt
+++ b/resources/extras/local-requirements.txt
@@ -1,7 +1,5 @@
# Local Requirements.
-asyncurban
-cairosvg
carbonnow
emoji
git+https://github.com/buddhhu/search-engine-parser.git
@@ -11,13 +9,10 @@ google-api-python-client==1.7.11
googletrans==3.1.0a0
heroku3
httplib2==0.13.1
-imutils
lottie
-lxml
moviepy
numpy
oauth2client==4.1.3
-opencv-python-headless
Pillow>=7.0.0
play-scraper
psutil
diff --git a/resources/session/ssgen.py b/resources/session/ssgen.py
index 3e3ac55..80d575a 100644
--- a/resources/session/ssgen.py
+++ b/resources/session/ssgen.py
@@ -9,6 +9,10 @@
import os
from time import sleep
+from telethon.errors.rpcerrorlist import ApiIdInvalidError, PhoneNumberInvalidError
+from telethon.sessions import StringSession
+from telethon.sync import TelegramClient
+
# https://www.tutorialspoint.com/how-to-clear-screen-in-python#:~:text=In%20Python%20sometimes%20we%20have,screen%20by%20pressing%20Control%20%2B%20l%20.
if os.name == "posix":
_ = os.system("clear")
@@ -35,7 +39,7 @@ try:
sleep(0.1)
x = "\bFound an existing installation of Telethon...\nSuccessfully Imported.\n\n"
-except:
+except BaseException:
print("Installing Telethon...")
os.system("pip install telethon")
@@ -48,11 +52,7 @@ else:
print(a)
print(x)
-from telethon.errors.rpcerrorlist import (ApiIdInvalidError,
- PhoneNumberInvalidError)
# the imports
-from telethon.sessions import StringSession
-from telethon.sync import TelegramClient
print(
"Get your API ID and API HASH from my.telegram.org or @ScrapperRoBot to proceed.\n\n",
diff --git a/resources/startup/locals.py b/resources/startup/locals.py
index 72007a5..ad69048 100644
--- a/resources/startup/locals.py
+++ b/resources/startup/locals.py
@@ -3,7 +3,8 @@
# Copyright (C) 2020 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
-# Please read the GNU Affero General Public License in .
+# Please read the GNU Affero General Public License in
+# .
# Standalone file for facilitating local deploys.
@@ -72,20 +73,21 @@ def start():
print(all_done)
isitdone = input("\n\nIs it all correct? [y/n]")
if isitdone == "y":
- f = open("Ultroid/.env", "w")
+ # https://github.com/TeamUltroid/Ultroid/blob/31b9eb1f4f8059e0ae66adb74cb6e8174df12eac/resources/startup/locals.py#L35
+ f = open(".env", "w")
f.write(all_done)
f.close
elif isitdone == "n":
print("Oh, let's redo these then -_-")
start()
else:
- f = open("Ultroid/.env", "w")
+ # https://github.com/TeamUltroid/Ultroid/blob/31b9eb1f4f8059e0ae66adb74cb6e8174df12eac/resources/startup/locals.py#L35
+ f = open(".env", "w")
f.write(all_done)
f.close
clear_screen()
print("\nCongrats. All done!\nTime to start the bot!")
print("\nInstalling requirements... This might take a while...")
- os.system("cd Ultroid")
os.system("pip3 install -r ./resources/extras/local-requirements.txt")
clear_screen()
print(a)
@@ -118,7 +120,7 @@ def check_for_py():
"Enter Choice:\n1. Continue, python is installed.\n2. Exit and install python.\n",
),
)
- except:
+ except BaseException:
print("Please run the script again, and enter the choice as a number!!")
exit(0)
if ch == 1:
@@ -133,7 +135,8 @@ def check_for_py():
def gen_session():
print("\nProcessing...")
- os.system("cd Ultroid && python3 resources/session/ssgen.py")
+ # https://github.com/TeamUltroid/Ultroid/blob/31b9eb1f4f8059e0ae66adb74cb6e8174df12eac/resources/startup/locals.py#L35
+ os.system("python3 resources/session/ssgen.py")
return
diff --git a/src/handlers/queue.ts b/src/handlers/queue.ts
index 51088be..1f16526 100644
--- a/src/handlers/queue.ts
+++ b/src/handlers/queue.ts
@@ -24,9 +24,9 @@ export const queueHandler = Composer.command('queue', async ctx => {
queue && queue.length > 0
? queue.map((data, index) => {
const { info, from } = data;
- return `${index + 1} - ${escapeHtml(info.title)} (${getDuration(info.duration)})\nRequested By : ${from.f_name}`
+ return `${index + 1} - ${escapeHtml(info.title)} (${getDuration(info.duration)})\nRequested By : ${from.f_name}\n`
}).join('\n')
: 'The queue is empty.';
await ctx.replyWithHTML(message, { disable_web_page_preview: true });
-});
\ No newline at end of file
+});
diff --git a/src/handlers/skip.ts b/src/handlers/skip.ts
index e6c94c7..56e2b88 100644
--- a/src/handlers/skip.ts
+++ b/src/handlers/skip.ts
@@ -29,7 +29,8 @@ export const skipCBHandler = Composer.action(/^skip:[a-zA-Z0-9.\-_]+$/, checkExp
await ctx.answerCbQuery("Skipped ...");
setTimeout(async () => await ctx.deleteMessage(), 1000);
} else {
- await ctx.answerCbQuery("There's no song playing..")
+ await ctx.answerCbQuery("There's no song playing..");
+ setTimeout(async () => await ctx.deleteMessage(), 1000);
}
})
@@ -42,4 +43,4 @@ export const skipCommand = Composer.command('skip', async ctx => {
const skipped = skip(chat.id);
ctx.reply(skipped ? 'Skipped.' : "There's no song playing.");
-})
\ No newline at end of file
+})
diff --git a/src/tgcalls.ts b/src/tgcalls.ts
index 8c645c7..d0b054c 100644
--- a/src/tgcalls.ts
+++ b/src/tgcalls.ts
@@ -49,6 +49,7 @@ interface CachedConnection {
currentSong: CurrentSong | null;
joinResolve?: (value: JoinVoiceCallResponse) => void;
source?: number;
+ leftVC: boolean
}
const ws = new WebSocket(env.WEBSOCKET_URL);
@@ -68,7 +69,6 @@ ws.on('message', response => {
break;
}
// case 'left_vc': {
- // cache.delete(data.chat.id);
// break;
// }
default:
@@ -161,10 +161,11 @@ const createConnection = async (chat: Chat.SupergroupChat): Promise => {
stream,
queue,
currentSong: null,
+ leftVC: false
};
connection.joinVoiceCall = payload => {
- // cachedConnection.source = payload.source;
+ cachedConnection.source = payload.source;
return new Promise(resolve => {
cachedConnection.joinResolve = resolve;
@@ -216,35 +217,34 @@ const createConnection = async (chat: Chat.SupergroupChat): Promise => {
stream.emit('finish');
}
} else {
- // try {
- // leaveVc(chat.id);
- // } catch (err) {
- // console.error(err);
- // }
+ try {
+ leaveVc(chat.id);
+ } catch (err) {
+ console.error(err);
+ }
cachedConnection.currentSong = null;
}
});
- // stream.on('leave', () => {
- // const data = {
- // _: 'leave',
- // data: {
- // source: cachedConnection.source,
- // chat: chat
- // },
- // };
- // ws.send(JSON.stringify(data));
- // cachedConnection.connection.close();
- // });
+ stream.on('leave', () => {
+ const data = {
+ _: 'leave',
+ data: {
+ source: cachedConnection.source,
+ chat: chat
+ },
+ };
+ ws.send(JSON.stringify(data));
+ cachedConnection.leftVC = true;
+ });
};
-// export const leaveVc = (chatId: number) => {
-// if (cache.has(chatId)) {
-// const { stream } = cache.get(chatId)!;
-// stream.emit('leave');
-// cache.delete(chatId);
-// }
-// return false;
-// }
+export const leaveVc = (chatId: number) => {
+ if (cache.has(chatId)) {
+ const { stream } = cache.get(chatId)!;
+ stream.emit('leave');
+ }
+ return false;
+}
export const addToQueue = async (chat: Chat.SupergroupChat, url: string, by: Queue['from']): Promise => {
if (!cache.has(chat.id)) {
@@ -253,6 +253,11 @@ export const addToQueue = async (chat: Chat.SupergroupChat, url: string, by: Que
}
const connection = cache.get(chat.id)!;
+ if (connection.leftVC) {
+ cache.delete(chat.id);
+ await createConnection(chat);
+ return addToQueue(chat, url, by);
+ }
const { stream, queue } = connection;
let songInfo: DownloadedSong['info'];
diff --git a/vcstarter.py b/vcstarter.py
index 3c40ec1..2422a80 100644
--- a/vcstarter.py
+++ b/vcstarter.py
@@ -6,10 +6,12 @@ from aiohttp import web
from aiohttp.http_websocket import WSMsgType
from pyUltroid import Var, vcbot
from telethon import TelegramClient
-from telethon.errors import ChannelPrivateError
from telethon.tl.functions.channels import GetFullChannelRequest
-from telethon.tl.functions.phone import (GetGroupCallRequest,
- JoinGroupCallRequest)
+from telethon.tl.functions.phone import (
+ GetGroupCallRequest,
+ JoinGroupCallRequest,
+ LeaveGroupCallRequest,
+)
from telethon.tl.types import DataJSON
bot = TelegramClient(None, Var.API_ID, Var.API_HASH).start(bot_token=Var.BOT_TOKEN)
@@ -46,7 +48,7 @@ if vcbot:
return await bot.send_message(data["chat"]["id"], "`" + str(ex) + "`")
try:
call = await vcbot(GetGroupCallRequest(full_chat.full_chat.call))
- except:
+ except BaseException:
call = None
if not call:
return await bot.send_message(
@@ -100,36 +102,45 @@ if vcbot:
},
}
- # async def leave_vc(data):
- # await bot.send_message(Var.LOG_CHANNEL, "Received Leave Request")
- # try:
- # await get_entity(data["chat"]["id"])
- # except Exception as ex:
- # return await bot.send_message(data["chat"]["id"], "`" + str(ex) + "`")
- # try:
- # full_chat = await vcbot(GetFullChannelRequest(chat))
- # except Exception as ex:
- # return await bot.send_message(data["chat"]["id"], "`" + str(ex) + "`")
- # try:
- # call = await vcbot(GetGroupCallRequest(full_chat.full_chat.call))
- # except:
- # call = None
- #
- # try:
- # result = await vcbot(
- # LeaveGroupCallRequest(
- # call=call.call,
- # source=data["source"],
- # ),
- # )
- # await bot.send_message(
- # Var.LOG_CHANNEL,
- # f"`Left Voice Chat in {(await bot.get_entity(data['chat']['id'])).title}`",
- # )
- # except Exception as ex:
- # return await bot.send_message(data["chat"]["id"], "`" + str(ex) + "`")
- #
- # return {"_": "left_vc", "data": {"chat_id": data["chat"]["id"]}}
+ async def leave_vc(data):
+ await bot.send_message(Var.LOG_CHANNEL, "Received Leave Request")
+ try:
+ await get_entity(data["chat"]["id"])
+ except Exception as ex:
+ return await bot.send_message(
+ data["chat"]["id"], "Exception in Get_Entity : `" + str(ex) + "`"
+ )
+ try:
+ full_chat = await vcbot(GetFullChannelRequest(chat))
+ except Exception as ex:
+ return await bot.send_message(
+ data["chat"]["id"],
+ "Exception in GetFullChannelRequest `" + str(ex) + "`",
+ )
+ try:
+ call = full_chat.full_chat.call
+ # call = await vcbot(GetGroupCallRequest(full_chat.full_chat.call))
+ except BaseException:
+ call = None
+
+ try:
+ result = await vcbot(
+ LeaveGroupCallRequest(
+ call=call,
+ source=data["source"],
+ ),
+ )
+ await bot.send_message(
+ Var.LOG_CHANNEL,
+ f"`Left Voice Chat in {(await bot.get_entity(data['chat']['id'])).title}`",
+ )
+ except Exception as ex:
+ return await bot.send_message(
+ data["chat"]["id"],
+ "Exception in LeaveGRoupCallRequest: `" + str(ex) + "`",
+ )
+
+ return {"_": "left_vc", "data": {"chat_id": data["chat"]["id"]}}
async def websocket_handler(request):
ws = web.WebSocketResponse()