From 6468ec80b0d1c243cf0b53ddc87d7c81e3823add Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:07:15 +0530 Subject: [PATCH 01/12] Update version.py --- Eivabot/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Eivabot/version.py b/Eivabot/version.py index a64181b..fd319d3 100644 --- a/Eivabot/version.py +++ b/Eivabot/version.py @@ -1,4 +1,4 @@ -__Eiva__ = "0.0.2.6" +__Eiva__ = "0.0.3" # Those Who Found Error Please Contact Support Group # TeamEiva # kang Ker Ne Aye Ho Pahale Mere Permission Tho Le li Hoti From 6ddd631d1a4ef9e276c410285ad5ee2272640306 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:13:11 +0530 Subject: [PATCH 02/12] Update Eiva_config.py --- Eiva_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Eiva_config.py b/Eiva_config.py index d82b205..c6d19fc 100644 --- a/Eiva_config.py +++ b/Eiva_config.py @@ -97,6 +97,7 @@ class Config((object)): TMP_DOWNLOAD_DIRECTORY = os.environ.get("TMP_DOWNLOAD_DIRECTORY", "./DOWNLOADS/") TZ = os.environ.get("TZ", "Asia/Kolkata") UPSTREAM_REPO = os.environ.get("UPSTREAM_REPO", "https://github.com/TeamEivaBot/EivaBot") + WAIFU_CATCHER = os.environ.get("WAIFU_CATCHER", None) WEATHER_API = os.environ.get("WEATHER_API", None) YOUR_NAME = os.environ.get("YOUR_NAME", None) YOUTUBE_API_KEY = os.environ.get("YOUTUBE_API_KEY", None) From 4fc6c7b6e49aeb5026f40d714d3c18084879773e Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:16:22 +0530 Subject: [PATCH 03/12] Update __init__.py --- Eivabot/plugins/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Eivabot/plugins/__init__.py b/Eivabot/plugins/__init__.py index 883ba86..2f87528 100644 --- a/Eivabot/plugins/__init__.py +++ b/Eivabot/plugins/__init__.py @@ -15,6 +15,7 @@ cjb = "./Eivabot/resources/pics/cjb.jpg" restlo = "./Eivabot/resources/pics/rest.jpeg" shuru = "./Eivabot/resources/pics/shuru.jpg" +shhh = "./Eivabot/resources/pics/chup_madarchod.jpeg" hl = Config.HANDLER shl = Config.SUDO_HANDLER Eiva_ver = __Eiva__ From 10cd44aa988b02254aebde9d77833ec0d9cf8ce6 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:23:46 +0530 Subject: [PATCH 04/12] Update admins.py --- Eivabot/plugins/admins.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Eivabot/plugins/admins.py b/Eivabot/plugins/admins.py index 35ac807..51d5605 100644 --- a/Eivabot/plugins/admins.py +++ b/Eivabot/plugins/admins.py @@ -116,6 +116,7 @@ async def promote(promt): ban_users=True, delete_messages=True, pin_messages=True, + manage_call=True, ) Eivaevent = await eor(promt, "`Promoting User...`") user, rank = await get_user_from_event(promt) @@ -162,6 +163,7 @@ async def demote(dmod): ban_users=None, delete_messages=None, pin_messages=None, + manage_call=True, ) try: await dmod.client(EditAdminRequest(dmod.chat_id, user.id, newrights, rank)) From 4e61f2501417f3163504de678cd1489d4e5a6cc1 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:28:04 +0530 Subject: [PATCH 05/12] Update qbot.py --- Eivabot/plugins/qbot.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Eivabot/plugins/qbot.py b/Eivabot/plugins/qbot.py index d0a3b15..43abc01 100644 --- a/Eivabot/plugins/qbot.py +++ b/Eivabot/plugins/qbot.py @@ -16,10 +16,7 @@ async def _(event): reply_message = await event.get_reply_message() Eiva = event.pattern_match.group(1) chat = "@QuotLyBot" - reply_message.sender - if reply_message.sender.bot: - await eod(event, "```Reply to actual user's message.```") - return + await eor(event, "```Making a Quote...```") async with bot.conversation(chat) as conv: try: From 5a288b4e1da52ce49a9c999bf87126eda3006f6d Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:28:29 +0530 Subject: [PATCH 06/12] Update qbot.py --- Eivabot/plugins/qbot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Eivabot/plugins/qbot.py b/Eivabot/plugins/qbot.py index 43abc01..bd62424 100644 --- a/Eivabot/plugins/qbot.py +++ b/Eivabot/plugins/qbot.py @@ -16,7 +16,6 @@ async def _(event): reply_message = await event.get_reply_message() Eiva = event.pattern_match.group(1) chat = "@QuotLyBot" - await eor(event, "```Making a Quote...```") async with bot.conversation(chat) as conv: try: From 41ca66882fec981c1a6d5e4c896701f45fd910d9 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:34:21 +0530 Subject: [PATCH 07/12] Update telegraph.py --- Eivabot/plugins/telegraph.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Eivabot/plugins/telegraph.py b/Eivabot/plugins/telegraph.py index 6cb06e9..82ae3a9 100644 --- a/Eivabot/plugins/telegraph.py +++ b/Eivabot/plugins/telegraph.py @@ -51,8 +51,8 @@ async def _(event): ms_two = (end - start).seconds os.remove(downloaded_file_name) await eor(event, - "✓ **File uploaded to [telegraph](https://telegra.ph{})** \n✓ **Time Taken :-** `{}` secs \n✓ **By :- {}**".format( - media_urls[0], (ms + ms_two), Eiva_mention, + "✓ **[File uploaded to telegraph](https://telegra.ph{})** \n✓ **Time Taken :-** `{}` secs \n✓ **By :- {}** \n✓ `https://telegra.ph{}`".format( + media_urls[0], (ms + ms_two), Eiva_mention, media_urls[0], ), link_preview=True, ) @@ -81,7 +81,7 @@ async def _(event): ms = (end - start).seconds Eivaboy = f"https://telegra.ph/{response['path']}" await edit_or_reply(event, - f"✓ **Pasted to** [telegraph]({Eivaboy}) \n✓ **Time Taken :-** `{ms}` secs\n✓** By :** {Eiva_mention}", link_preview=True) + f"✓ **[Pasted to telegraph]({Eivaboy})** \n✓ **Time Taken :-** `{ms}` secs\n✓** By :** {Eiva_mention} \n✓ `{Eivaboy}`", link_preview=True) else: await eod(event, "Reply to a message to get a permanent telegra.ph link." From 835155e79506e2f11eaecd294aa85b9c494315c7 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:37:54 +0530 Subject: [PATCH 08/12] Create voice_chat.py --- Eivabot/plugins/voice_chat.py | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Eivabot/plugins/voice_chat.py diff --git a/Eivabot/plugins/voice_chat.py b/Eivabot/plugins/voice_chat.py new file mode 100644 index 0000000..7b33082 --- /dev/null +++ b/Eivabot/plugins/voice_chat.py @@ -0,0 +1,68 @@ +from telethon.tl.functions.channels import GetFullChannelRequest +from telethon.tl.functions.phone import CreateGroupCallRequest +from telethon.tl.functions.phone import DiscardGroupCallRequest +from telethon.tl.functions.phone import GetGroupCallRequest +from telethon.tl.functions.phone import InviteToGroupCallRequest + +from . import * + + +async def getvc(event): + chat_ = await event.client(GetFullChannelRequest(event.chat_id)) + _chat = await event.client(GetGroupCallRequest(chat_.full_chat.call)) + return _chat.call + +def all_users(a, b): + for c in range(0, len(a), b): + yield a[c : c + b] + + +@bot.on(Eiva_cmd(pattern="startvc$")) +@bot.on(sudo_cmd(pattern="startvc$", allow_sudo=True)) +async def _(event): + try: + await event.client(CreateGroupCallRequest(event.chat_id)) + await eor(event, "**🔊 Voice Chat Started Successfully**") + except Exception as e: + await eor(event, f"`{str(e)}`") + + +@bot.on(Eiva_cmd(pattern="endvc$")) +@bot.on(sudo_cmd(pattern="endvc$", allow_sudo=True)) +async def _(event): + try: + await bot(DiscardGroupCallRequest(await getvc(event))) + await eor(event, "**📍 Voice Chat Ended Successfully !!**") + except Exception as e: + await eor(event, f"`{str(e)}`") + + +@bot.on(Eiva_cmd(pattern="vcinvite$")) +@bot.on(sudo_cmd(pattern="vcinvite$", allow_sudo=True)) +async def _(event): + Eiva = await eor(event, "`🧐 Inviting Users To Voice Chat....`") + users = [] + i = 0 + async for j in event.client.iter_participants(event.chat_id): + if not j.bot: + users.append(j.id) + hel_ = list(all_users(users, 6)) + for k in hel_: + try: + await bot(InviteToGroupCallRequest(call=await getvc(event), users=k)) + i += 6 + except BaseException: + pass + await Eiva.edit(f"**🚀 Invited {i} Users to Voice Chat**") + +CmdHelp("voice_chat").add_command( + "startvc", None, "Starts the voice chat in current group." +).add_command( + "endvc", None, "Ends the voice chat in current group." +).add_command( + "vcinvite", None, "Invites members of the current group to voice chat." +).add_info( + "Voice Chat Tools." +).add_warning( + "✅ Harmless Module." +).add() From 4e58ba8bc7e48c655c41b4191b634495477aeab5 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:48:20 +0530 Subject: [PATCH 09/12] Update spam.py --- Eivabot/plugins/spam.py | 66 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/Eivabot/plugins/spam.py b/Eivabot/plugins/spam.py index d806a86..7101089 100644 --- a/Eivabot/plugins/spam.py +++ b/Eivabot/plugins/spam.py @@ -30,8 +30,12 @@ async def bigspam(Eiva): if not Eiva.text[0].isalpha() and Eiva.text[0] not in ("/", "#", "@", "!"): Eiva_msg = Eiva.text Eivabot_count = int(Eiva_msg[9:13]) - Eiva_spam = str(Eiva.text[13:]) - for _ in range(1, Eivabot_count): + reply_msg = await Eiva.get_reply_message() + if reply_msg: + Eiva_spam = reply_msg + else: + Eiva_spam = str(Eiva.text[13:]) + for i in range(1, Eivabot_count): await Eiva.respond(Eiva_spam) await Eiva.delete() await Eiva.client.send_message( @@ -54,6 +58,49 @@ async def spammer(e): await asyncio.sleep(spamDelay) +@bot.on(Eiva_cmd(pattern="uspam ?(.*)")) +@bot.on(sudo_cmd(pattern="uspam ?(.*)", allow_sudo=True)) +async def _(event): + reply_msg = await event.get_reply_message() + Eiva = event.pattern_match.group(1) + if reply_msg: + input_str = reply_msg + else: + input_str = Eiva + await bot.send_message(lg_id, f"#UNLIMITED_SPAM \n\nStarted Unlimited Spam. Will spam till floodwait. Do `{hl}restart` to stop.") + x = 0 + while x < 69: + await bot.send_message(event.chat_id, input_str) + + +# Special Break Spam Module Made By Chirag Bhargava. +# Team EivaBot +@bot.on(Eiva_cmd(pattern="bspam ?(.*)")) +@bot.on(sudo_cmd(pattern="bspam ?(.*)", allow_sudo=True)) +async def spammer(e): + if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): + message = e.text + counter = int(message[7:11]) + reply_msg = await e.get_reply_message() + if reply_msg: + spam_message = reply_msg + else: + spam_message = str(e.text[12:]) + rd = int(counter % 100) + tot = int((counter - rd )/100) + a = 30 + for q in range(tot): + for p in range(100): + await asyncio.wait([e.respond(spam_message)]) + a = a + 2 + await asyncio.sleep(a) + + await e.delete() + await e.client.send_message( + lg_id, f"#BREAK_SPAM \n\nSpammed {counter} messages!!" + ) + + @bot.on(Eiva_cmd(pattern="mspam (.*)")) @bot.on(sudo_cmd(pattern="mspam (.*)", allow_sudo=True)) async def tiny_pic_spam(e): @@ -70,10 +117,11 @@ async def tiny_pic_spam(e): not reply_message or not e.reply_to_msg_id or not reply_message.media + or not reply_message.media ): return await e.edit("```Reply to a pic/sticker/gif/video message```") message = reply_message.media - for _ in range(1, counter): + for i in range(1, counter): await e.client.send_file(e.chat_id, message) except: return await e.reply( @@ -82,13 +130,17 @@ async def tiny_pic_spam(e): CmdHelp("spam").add_command( - "spam", " ", "Sends the text 'X' number of times.", ".spam 99 Eivao" + "spam", " ", "Sends the text 'X' number of times.", "spam 99 Hello" +).add_command( + "mspam", " ", "Sends the replied media (gif/ video/ sticker/ pic) 'X' number of times", "mspam 100 " +).add_command( + "dspam", " ", "Sends the text 'X' number of times in 'Y' seconds of delay", "dspam 5 100 Hello" ).add_command( - "mspam", " ", "Sends the replied media (gif/ video/ sticker/ pic) 'X' number of times", ".mspam 100 " + "uspam", " or ", "Spams the message unlimited times until you get floodwait error.", "uspam Hello" ).add_command( - "dspam", " ", "Sends the text 'X' number of times in 'Y' seconds of delay", ".dspam 5 100 Eivao" + "bspam", " ", "Spams the message X times without floodwait. Breaks the spam count to avoid floodwait.", "bspam 9999 Hello" ).add_command( - "bigspam", " ", "Sends the text 'X' number of times. This what Eivabot iz known for. The Best BigSpam Ever", ".bigspam 5000 Eivao" + "bigspam", " ", "Sends the text 'X' number of times. This what Eivabot iz known for. The Best BigSpam Ever", "bigspam 5000 Hello" ).add_info( "Spammers Commands" ).add_warning( From 3a8480bca14408067cf6c84e5f2fc32340be2a6e Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:52:05 +0530 Subject: [PATCH 10/12] Create protecc.py --- Eivabot/plugins/protecc.py | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Eivabot/plugins/protecc.py diff --git a/Eivabot/plugins/protecc.py b/Eivabot/plugins/protecc.py new file mode 100644 index 0000000..51abbac --- /dev/null +++ b/Eivabot/plugins/protecc.py @@ -0,0 +1,114 @@ +import asyncio +import os +import datetime +import lottie +import urllib +import requests +from asyncio import sleep +from bs4 import BeautifulSoup + +from . import * + +qt = "A qt waifu appeared!" + +def progress(current, total): + logger.info( + "Downloaded {} of {}\nCompleted {}".format( + current, total, (current / total) * 100 + ) + ) + +@bot.on(Eiva_cmd(pattern="pt ?(.*)")) +@bot.on(sudo_cmd(pattern="pt ?(.*)", allow_sudo=True)) +async def _(event): + if event.fwd_from: + return + Eiva = await eor(event, "Hmm..") + BASE_URL = "http://images.google.com" + if event.reply_to_msg_id: + previous_message = await event.get_reply_message() + previous_message_text = previous_message.message + if previous_message.media: + downloaded_file_name = await bot.download_media( + previous_message, Config.TMP_DOWNLOAD_DIRECTORY + ) + SEARCH_URL = "{}/searchbyimage/upload".format(BASE_URL) + multipart = { + "encoded_image": ( + downloaded_file_name, + open(downloaded_file_name, "rb"), + ), + "image_content": "", + } + google_rs_response = requests.post( + SEARCH_URL, files=multipart, allow_redirects=False + ) + the_location = google_rs_response.headers.get("Location") + os.remove(downloaded_file_name) + else: + previous_message_text = previous_message.message + SEARCH_URL = "{}/searchbyimage?image_url={}" + request_url = SEARCH_URL.format(BASE_URL, previous_message_text) + google_rs_response = requests.get(request_url, allow_redirects=False) + the_location = google_rs_response.headers.get("Location") + headers = { + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0" + } + response = requests.get(the_location, headers=headers) + soup = BeautifulSoup(response.text, "html.parser") + prs_div = soup.find_all("div", {"class": "r5a77d"})[0] + prs_anchor_element = prs_div.find("a") + prs_url = BASE_URL + prs_anchor_element.get("href") + prs_text = prs_anchor_element.text + img_size_div = soup.find(id="jHnbRc") + img_size = img_size_div.find_all("div") + OUTPUT_STR = """/protecc {prs_text}""".format( + **locals()) + await Eiva.edit(OUTPUT_STR, parse_mode="HTML", link_preview=False) + + +@bot.on(events.NewMessage(incoming=True)) +async def reverse(event): + if not event.media: + return + if not qt in event.text: + return + if not event.sender_id == 792028928: + return + if Config.WAIFU_CATCHER != "TRUE": + return + dl = await bot.download_media(event.media, "resources/") + file = {"encoded_image": (dl, open(dl, "rb"))} + grs = requests.post( + "https://www.google.com/searchbyimage/upload", files=file, allow_redirects=False + ) + loc = grs.headers.get("Location") + response = requests.get( + loc, + headers={ + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0" + }, + ) + qtt = BeautifulSoup(response.text, "html.parser") + div = qtt.find_all("div", {"class": "r5a77d"})[0] + alls = div.find("a") + text = alls.text + try: + if "cg" in text: + return + if "fictional character" in text: + return + except: + pass + await bot.send_message(event.chat_id, f"/protecc@loli_harem_bot {text}") + await sleep(2) + os.remove(dl) + + +CmdHelp("protecc").add_command( + "pt", "", "Auto Protecc the waifu." +).add_info( + "Waifu Protecc." +).add_warning( + "✅ Harmless Module." +).add() From 8bfe0544275ecf9a6718bcefa058387c88b7f7e4 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:55:51 +0530 Subject: [PATCH 11/12] Update memify.py --- Eivabot/plugins/memify.py | 130 +++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 45 deletions(-) diff --git a/Eivabot/plugins/memify.py b/Eivabot/plugins/memify.py index 67460f9..0ac9257 100644 --- a/Eivabot/plugins/memify.py +++ b/Eivabot/plugins/memify.py @@ -6,6 +6,7 @@ import re import textwrap import lottie +import asyncio from PIL import Image, ImageDraw, ImageEnhance, ImageFont, ImageOps @@ -20,51 +21,88 @@ @bot.on(Eiva_cmd(pattern="mmf ?(.*)", outgoing=True)) @bot.on(sudo_cmd(pattern="mmf ?(.*)", allow_sudo=True)) async def _(event): - if event.fwd_from: + _reply = await event.get_reply_message() + msg = event.pattern_match.group(1) + if not (_reply and (_reply.media)): + hel_ = await eod(event, "`Can't memify this 🥴`") return - if not event.reply_to_msg_id: - await eod(event, "You need to reply to an image with .mmf` 'text on top' ; 'text on bottom'") - return - await eor(event, "🤪 **Memifying...**") - reply = await event.get_reply_message() - imgs = await bot.download_media(reply.media, path) - img = cv2.VideoCapture(imgs) - tal, semx = img.read() - cv2.imwrite("kraken.webp", semx) - text = event.pattern_match.group(1) - webp_file = await draw_meme_text("kraken.webp", text) - await event.client.send_file( - event.chat_id, webp_file, reply_to=event.reply_to_msg_id + Eiva = await _reply.download_media() + if Eiva.endswith((".tgs")): + hel_ = await eor(event, "**Memifying 🌚🌝**") + cmd = ["lottie_convert.py", Eiva, "pic.png"] + file = "pic.png" + process = await asyncio.create_subprocess_exec( + *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE + ) + stdout, stderr = await process.communicate() + stderr.decode().strip() + stdout.decode().strip() + elif Eiva.endswith((".webp", ".png")): + hel_ = await eor(event, "**Memifying 🌚🌝**") + pics = Image.open(Eiva) + pics.save("pic.png", format="PNG", optimize=True) + file = "pic.png" + else: + hel_ = await eor(event, "**Memifying 🌚🌝**") + img = cv2.VideoCapture(Eiva) + tal, semx = img.read() + cv2.imwrite("pic.png", semx) + file = "pic.png" + output = await draw_meme_text(file, msg) + await bot.send_file( + event.chat_id, output, force_document=False, reply_to=event.reply_to_msg_id ) - await event.delete() - shutil.rmtree(path) - os.remove("kraken.webp") - os.remove(webp_file) + await hel_.delete() + try: + os.remove(Eiva) + os.remove(file) + os.remove(output) + except BaseException: + pass @bot.on(Eiva_cmd(pattern="mms ?(.*)", outgoing=True)) @bot.on(sudo_cmd(pattern="mms ?(.*)", allow_sudo=True)) -async def sed(Eivaboy): - if Eivaboy.fwd_from: - return - if not Eivaboy.reply_to_msg_id: - await eod(Eivaboy, "You need to reply to an image with .mms` 'text on top' ; 'text on bottom'") +async def _(event): + _reply = await event.get_reply_message() + msg = event.pattern_match.group(1) + if not (_reply and (_reply.media)): + hel_ = await eod(event, "`Can't memify this 🥴`") return - await eor(Eivaboy, "🤪 **Memifying...**") - reply = await Eivaboy.get_reply_message() - imgs = await bot.download_media(reply.media, path) - img = cv2.VideoCapture(imgs) - tal, semx = img.read() - cv2.imwrite("kraken.webp", semx) - text = Eivaboy.pattern_match.group(1) - photo = await draw_meme("kraken.webp", text) - await Eivaboy.client.send_file( - Eivaboy.chat_id, photo, reply_to=Eivaboy.reply_to_msg_id + Eiva = await _reply.download_media() + if Eiva.endswith((".tgs")): + hel_ = await eor(event, "**Memifying 🌚🌝**") + cmd = ["lottie_convert.py", Eiva, "pic.png"] + file = "pic.png" + process = await asyncio.create_subprocess_exec( + *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE + ) + stdout, stderr = await process.communicate() + stderr.decode().strip() + stdout.decode().strip() + elif Eiva.endswith((".webp", ".png")): + hel_ = await eor(event, "**Memifying 🌚🌝**") + pic = Image.open(Eiva) + pic.save("pic.png", format="PNG", optimize=True) + file = "pic.png" + else: + hel_ = await eor(event, "**Memifying 🌚🌝**") + img = cv2.VideoCapture(Eiva) + tal, semx = img.read() + cv2.imwrite("pic.png", semx) + file = "pic.png" + output = await draw_meme(file, msg) + await bot.send_file( + event.chat_id, output, force_document=False, reply_to=event.reply_to_msg_id ) - await Eivaboy.delete() - shutil.rmtree(path) - os.remove("kraken.webp") - os.remove(photo) + await hel_.delete() + try: + os.remove(Eiva) + os.remove(file) + except BaseException: + pass + os.remove(pic) + @bot.on(Eiva_cmd(pattern="doge(?: |$)(.*)", outgoing=True)) @bot.on(sudo_cmd(pattern="doge(?: |$)(.*)", allow_sudo=True)) @@ -73,10 +111,11 @@ async def nope(kraken): if not Eiva: if kraken.is_reply: (await kraken.get_reply_message()).message - elif Config.ABUSE == "ON": - return await eor(kraken, "Abe chumtiye kuch likhne ke liye de") else: - return await eor(kraken, "Doge need some text to make sticker.") + if Config.ABUSE == "ON": + return await eor(kraken, "Abe chumtiye kuch likhne ke liye de") + else: + return await eor(kraken, "Doge need some text to make sticker.") troll = await bot.inline_query("DogeStickerBot", f"{(deEmojify(Eiva))}") if troll: @@ -100,10 +139,11 @@ async def nope(kraken): if not Eiva: if kraken.is_reply: (await kraken.get_reply_message()).message - elif Config.ABUSE == "ON": - return await eor(kraken, "Abe chumtiye kuch likhne ke liye de") else: - return await eor(kraken, "Doge need some text to make sticker.") + if Config.ABUSE == "ON": + return await eor(kraken, "Abe chumtiye kuch likhne ke liye de") + else: + return await eor(kraken, "Doge need some text to make sticker.") troll = await bot.inline_query("GooglaxBot", f"{(deEmojify(Eiva))}") if troll: @@ -121,9 +161,9 @@ async def nope(kraken): CmdHelp("memify").add_command( - "mmf", " ; ", "Memifies the replied image/gif/sticker with your text and sends output in sticker format.", "mmf hii ; Eivao" + "mmf", " ; ", "Memifies the replied image/gif/sticker with your text and sends output in sticker format.", "mmf hii ; Hello" ).add_command( - "mms", " ; ", "Memifies the replied image/gif/sticker with your text and sends output in image format.", "mms hii ; Eivao" + "mms", " ; ", "Memifies the replied image/gif/sticker with your text and sends output in image format.", "mms hii ; Hello" ).add_command( "doge", "", "Makes A Sticker of Doge with given text." ).add_command( From 13cbb119ec457197d1750d15c92113af724f0721 Mon Sep 17 00:00:00 2001 From: Phoenix Error <88020281+PhoenixError@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:59:14 +0530 Subject: [PATCH 12/12] Update global.py --- Eivabot/plugins/global.py | 212 +++++++++++++++++++++++++++++++++----- 1 file changed, 187 insertions(+), 25 deletions(-) diff --git a/Eivabot/plugins/global.py b/Eivabot/plugins/global.py index 8c3b65e..98ceefe 100644 --- a/Eivabot/plugins/global.py +++ b/Eivabot/plugins/global.py @@ -1,12 +1,164 @@ +import asyncio from telethon import events from telethon.tl.functions.channels import EditAdminRequest -from telethon.tl.types import ChatAdminRights -import asyncio +from telethon.tl.types import ChatAdminRights, ChannelParticipantsAdmins, ChatBannedRights, MessageEntityMentionName, MessageMediaPhoto +from telethon.errors.rpcerrorlist import UserIdInvalidError, MessageTooLongError +from telethon.tl.functions.channels import EditAdminRequest, EditBannedRequest, EditPhotoRequest +from telethon.tl.functions.messages import UpdatePinnedMessageRequest + from Eivabot.sql.gban_sql import is_gbanned, gbaner, ungbaner, all_gbanned from Eivabot.sql import gmute_sql as gsql from . import * +async def get_full_user(event): + args = event.pattern_match.group(1).split(':', 1) + extra = None + if event.reply_to_msg_id and not len(args) == 2: + previous_message = await event.get_reply_message() + user_obj = await event.client.get_entity(previous_message.sender_id) + extra = event.pattern_match.group(1) + elif len(args[0]) > 0: + user = args[0] + if len(args) == 2: + extra = args[1] + if user.isnumeric(): + user = int(user) + if not user: + await eor(event, "Need a user to do this...") + return + if event.message.entities is not None: + probable_user_mention_entity = event.message.entities[0] + if isinstance(probable_user_mention_entity, + MessageEntityMentionName): + user_id = probable_user_mention_entity.user_id + user_obj = await event.client.get_entity(user_id) + return user_obj + try: + user_obj = await event.client.get_entity(user) + except Exception as err: + return await eor(event, f"**ERROR !!**\n\n`{str(err)}`") + return user_obj, extra + + +async def get_user_from_id(user, event): + if isinstance(user, str): + user = int(user) + try: + user_obj = await event.client.get_entity(user) + except (TypeError, ValueError) as err: + await event.edit(str(err)) + return None + return user_obj + + + +@bot.on(Eiva_cmd(pattern="gpro ?(.*)")) +@bot.on(sudo_cmd(pattern="gpro ?(.*)", allow_sudo=True)) +async def _(Eivaevent): + i = 0 + sender = await Eivaevent.get_sender() + me = await Eivaevent.client.get_me() + Eiva = await eor(Eivaevent, "`Promoting globally...`") + my_mention = "[{}](tg://user?id={})".format(me.first_name, me.id) + f"@{me.username}" if me.username else my_mention + await Eivaevent.get_chat() + if Eivaevent.is_private: + user = Eivaevent.chat + rank = Eivaevent.pattern_match.group(1) + else: + Eivaevent.chat.title + try: + user, rank = await get_full_user(Eivaevent) + except: + pass + if me == user: + k = await Eiva.edit("You can't promote yourself...") + return + try: + if not rank: + rank = "ㅤ" + except: + return await Eiva.edit("**ERROR !!**") + if user: + telchanel = [d.entity.id + for d in await Eivaevent.client.get_dialogs() + if (d.is_group or d.is_channel) + ] + rgt = ChatAdminRights(add_admins=False, + invite_users=True, + change_info=False, + ban_users=True, + delete_messages=True, + pin_messages=True) + for x in telchanel: + try: + await Eivaevent.client(EditAdminRequest(x, user, rgt, rank)) + i += 1 + await Eiva.edit(f"**Promoting User in :** `{i}` Chats...") + except: + pass + else: + await Eiva.edit(f"**Reply to a user !!**") + await Eiva.edit( + f"[{user.first_name}](tg://user?id={user.id}) **Was Promoted Globally In** `{i}` **Chats !!**" + ) + await bot.send_message(Config.LOGGER_ID, f"#GPROMOTE \n\n**Globally Promoted User :** [{user.first_name}](tg://user?id={user.id}) \n\n**Total Chats :** `{i}`") + + +@bot.on(Eiva_cmd(pattern="gdem ?(.*)")) +@bot.on(sudo_cmd(pattern="gdem ?(.*)", allow_sudo=True)) +async def _(Eivaevent): + i = 0 + sender = await Eivaevent.get_sender() + me = await Eivaevent.client.get_me() + Eiva = await eor(Eivaevent, "`Demoting Globally...`") + my_mention = "[{}](tg://user?id={})".format(me.first_name, me.id) + f"@{me.username}" if me.username else my_mention + await Eivaevent.get_chat() + if Eivaevent.is_private: + user = Eivaevent.chat + rank = Eivaevent.pattern_match.group(1) + else: + Eivaevent.chat.title + try: + user, rank = await get_full_user(Eivaevent) + except: + pass + if me == user: + k = await Eiva.edit("You can't Demote yourself !!") + return + try: + if not rank: + rank = "ㅤ" + except: + return await Eiva.edit("**ERROR !!**") + if user: + telchanel = [d.entity.id + for d in await Eivaevent.client.get_dialogs() + if (d.is_group or d.is_channel) + ] + rgt = ChatAdminRights(add_admins=None, + invite_users=None, + change_info=None, + ban_users=None, + delete_messages=None, + pin_messages=None) + for x in telchanel: + try: + await Eivaevent.client(EditAdminRequest(x, user, rgt, rank)) + i += 1 + await Eiva.edit(f"**Demoting Globally In Chats :** `{i}`") + except: + pass + else: + await Eiva.edit(f"**Reply to a user !!**") + await Eiva.edit( + f"[{user.first_name}](tg://user?id={user.id}) **Was Demoted Globally In** `{i}` **Chats !!**" + ) + await bot.send_message(Config.LOGGER_ID, f"#GDEMOTE \n\n**Globally Demoted :** [{user.first_name}](tg://user?id={user.id}) \n\n**Total Chats :** `{i}`") + + @bot.on(Eiva_cmd(pattern=r"gban ?(.*)")) @bot.on(sudo_cmd(pattern=r"gban ?(.*)", allow_sudo=True)) async def _(event): @@ -35,10 +187,10 @@ async def _(event): return await eod(Eiva, "**To gban a user i need a userid or reply to his/her message!!**") name = (await event.client.get_entity(userid)).first_name chats = 0 - if userid == 1320929227: + if userid == ForGo10God: return await eod(Eiva, "🥴 **Nashe me hai kya lawde ‽**") if str(userid) in DEVLIST: - return await eod(Eiva, "😑 **GBan my Devloper ?¿ Really‽**") + return await eod(Eiva, "😑 **GBan my creator ?¿ Really‽**") if is_gbanned(userid): return await eod( Eiva, @@ -60,6 +212,7 @@ async def _(event): ogmsg += f"\n**🔰 Reason :** `{reason}`" if Config.ABUSE == "ON": await bot.send_file(event.chat_id, cjb, caption=gmsg) + await Eiva.delete() else: await Eiva.edit(ogmsg) @@ -109,22 +262,22 @@ async def already(event): @bot.on(events.ChatAction) async def _(event): - if not event.user_joined and not event.added_by: - return - user = await event.get_user() - chat = await event.get_chat() - if is_gbanned(str(user.id)) and chat.admin_rights: - try: - await event.client.edit_permissions( - chat.id, - user.id, - view_messages=False, - ) - gban_watcher = f"⚠️⚠️**Warning**⚠️⚠️\n\n`Gbanned User Joined the chat!!`\n**⚜️ Victim Id :** [{user.first_name}](tg://user?id={user.id})\n" - gban_watcher += f"**🔥 Action 🔥** \n`Banned this piece of shit....` **AGAIN!**" - await event.reply(gban_watcher) - except BaseException: - pass + if event.user_joined or event.added_by: + user = await event.get_user() + chat = await event.get_chat() + if is_gbanned(str(user.id)): + if chat.admin_rights: + try: + await event.client.edit_permissions( + chat.id, + user.id, + view_messages=False, + ) + gban_watcher = f"⚠️⚠️**Warning**⚠️⚠️\n\n`Gbanned User Joined the chat!!`\n**⚜️ Victim Id :** [{user.first_name}](tg://user?id={user.id})\n" + gban_watcher += f"**🔥 Action 🔥** \n`Banned this piece of shit....` **AGAIN!**" + await event.reply(gban_watcher) + except BaseException: + pass @bot.on(Eiva_cmd(pattern=r"gkick ?(.*)")) @@ -141,7 +294,7 @@ async def gkick(event): return await eod(Eiva, "`Reply to some msg or add their id.`") name = (await event.client.get_entity(userid)).first_name chats = 0 - if userid == Royal_King7: + if userid == ForGo10God: return await eod(Eiva, "**🥴 Nashe me hai kya lawde!!**") if str(userid) in DEVLIST: return await eod(Eiva, "**😪 I'm not going to gkick my developer!!**") @@ -155,6 +308,7 @@ async def gkick(event): gkmsg = f"🏃 **Globally Kicked** [{name}](tg://user?id={userid})'s butts !! \n\n📝 **Chats :** `{chats}`" if Config.ABUSE == "ON": await bot.send_file(event.chat_id, cjb, caption=gkmsg) + await Eiva.delete() else: await Eiva.edit(gkmsg) @@ -174,7 +328,7 @@ async def gm(event): userid = event.pattern_match.group(1) elif reply is not None: userid = reply.sender_id - elif private: + elif private is True: userid = event.chat_id else: return await eod(event, "Need a user to gmute. Reply or give userid to gmute them..") @@ -184,7 +338,7 @@ async def gm(event): return await eod(event, "This kid is already Gmuted.") try: if str(userid) in DEVLIST: - return await eod(event, "**Sorry I'm not going to gmute my Devloper..**") + return await eod(event, "**Sorry I'm not going to gmute them..**") except: pass try: @@ -192,7 +346,11 @@ async def gm(event): except Exception as e: await eod(event, "Error occured!\nError is " + str(e)) else: - await eor(event, "Shhh.... Now keep quiet !!") + if Config.ABUSE == "ON": + await bot.send_file(event.chat_id, shhh, caption="**Chup Madarcod... Bilkul Chup 🤫**") + await event.delete() + else: + await eor(event, "🤫 Shhh... **Don't speak Now !!**") @@ -211,7 +369,7 @@ async def endgmute(event): userid = event.pattern_match.group(1) elif reply is not None: userid = reply.sender_id - elif private: + elif private is True: userid = event.chat_id else: return await eod(event,"Please reply to a user or add their into the command to ungmute them.") @@ -244,6 +402,10 @@ async def watcher(event): "gmute", " or ", "Globally Mutes the User." ).add_command( "ungmute", " or ", "Globally Unmutes the gmutes user." +).add_command( + "gpro", " or ", "Globally Promotes the mentioned user in all the chats you are admin with Add Admins permission." +).add_command( + "gdem", " or ", "Globally Demotes the mentioned user in all the chats you have rights to demoted that user." ).add_info( "Global Admin Tool." ).add_warning(