diff --git a/userbot/__main__.py b/userbot/__main__.py index 682618a16..96044afcc 100644 --- a/userbot/__main__.py +++ b/userbot/__main__.py @@ -19,7 +19,7 @@ from userbot.modules import ALL_MODULES for module_name in ALL_MODULES: imported_module = importlib.import_module("userbot.modules." + module_name) -LOGS.info('Your Bot is alive! Test it by typing .alive on any chat. Should you need assistance, head to https://t.me/userbot_support. Your Bot Version is 2.1-b') +LOGS.info('Your Bot is alive! Test it by typing .alive on any chat. Should you need assistance, head to https://t.me/userbot_support. Your Bot Version is 2.1') if len(sys.argv) not in (1,3,4): bot.disconnect() else: diff --git a/userbot/modules/admin.py b/userbot/modules/admin.py index d3fbae41f..16531f4bf 100644 --- a/userbot/modules/admin.py +++ b/userbot/modules/admin.py @@ -173,10 +173,53 @@ async def unmute(e): async def muter(e): try: from userbot.modules.sql_helper.spam_mute_sql import is_muted + from userbot.modules.sql_helper.gmute_sql import is_gmuted except: return L = is_muted(e.chat_id) + K = is_gmuted(e.sender_id) if L: for i in L: if str(i.sender) == str(e.sender_id): await e.delete() + for i in K: + if i.sender == str(e.sender_id): + await e.delete() + +@bot.on(events.NewMessage(outgoing=True, pattern="^.ungmute$")) +@bot.on(events.MessageEdited(outgoing=True, pattern="^.ungmute$")) +async def unmute(e): + if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): + try: + from userbot.modules.sql_helper.gmute_sql import ungmute + except: + await e.edit('`Running on Non-SQL Mode!`') + ungmute(str((await e.get_reply_message()).sender_id)) + await e.edit("```Ungmuted Successfully```") + + +@bot.on(events.NewMessage(outgoing=True, pattern="^.gspider$")) +@bot.on(events.MessageEdited(outgoing=True, pattern="^.gspider$")) +async def spider(e): + if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): + if (await e.get_reply_message()).sender_id in BRAIN_CHECKER: + await e.edit("`Mute Error! Couldn't mute this user`") + return + try: + from userbot.modules.sql_helper.gmute_sql import gmute + except Exception as er: + print(er) + await e.edit("`Running on Non-SQL mode!`") + return + gmute(str((await e.get_reply_message()).sender_id)) + await e.edit("`Spiderman nabs him!`") + time.sleep(5) + await e.delete() + await bot.send_file( + e.chat_id, "https://image.ibb.co/mNtVa9/ezgif_2_49b4f89285.gif" + ) + if LOGGER: + await bot.send_message( + LOGGER_GROUP, + str((await e.get_reply_message()).sender_id) + " was muted.", + ) diff --git a/userbot/modules/afk.py b/userbot/modules/afk.py index c21868dee..eb249849a 100644 --- a/userbot/modules/afk.py +++ b/userbot/modules/afk.py @@ -11,25 +11,25 @@ async def mention_afk(e): global ISAFK if e.message.mentioned and not (await e.get_sender()).bot: if ISAFK: - if e.chat_id not in USERS: + if e.sender_id not in USERS: await e.reply( "Sorry! My boss is AFK due to ```" + AFKREASON + "```. Would ping him to look into the message soon😉" ) - USERS.update({e.chat_id: 1}) + USERS.update({e.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 - elif e.chat_id in USERS: - if USERS[e.chat_id] % 5 == 0: + elif e.sender_id in USERS: + if USERS[e.sender_id] % 5 == 0: await e.reply( "Sorry! But my boss is still not here. Try to ping him a little later. I am sorry😖. He told me he was busy with ```" + AFKREASON + "```" ) - USERS[e.chat_id] = USERS[e.chat_id] + 1 + USERS[e.sender_id] = USERS[e.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: - USERS[e.chat_id] = USERS[e.chat_id] + 1 + USERS[e.sender_id] = USERS[e.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 @@ -40,25 +40,25 @@ async def afk_on_pm(e): global COUNT_MSG if e.is_private and not (await e.get_sender()).bot: if ISAFK: - if e.chat_id not in USERS: + if e.sender_id not in USERS: await e.reply( "Sorry! My boss is AFK due to ```" + AFKREASON + "``` I'll ping him to look into the message soon😉" ) - USERS.update({e.chat_id: 1}) + USERS.update({e.sender_id: 1}) COUNT_MSG = COUNT_MSG + 1 - elif e.chat_id in USERS: - if USERS[e.chat_id] % 5 == 0: + elif e.sender_id in USERS: + if USERS[e.sender_id] % 5 == 0: await e.reply( "Sorry! But my boss is still not here. Try to ping him a little later. I am sorry😖. He told me he was busy with ```" + AFKREASON + "```" ) - USERS[e.chat_id] = USERS[e.chat_id] + 1 + USERS[e.sender_id] = USERS[e.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 else: - USERS[e.chat_id] = USERS[e.chat_id] + 1 + USERS[e.sender_id] = USERS[e.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 @@ -72,18 +72,13 @@ async def not_afk(e): global AFKREASON ISAFK = False await e.edit("I'm no longer AFK.") - await e.respond( + x=await e.respond( "`You recieved " + str(COUNT_MSG) + " messages while you were away. Check log for more details. This auto-generated message shall be self destructed in 2 seconds.`" ) time.sleep(2) - i = 1 - async for message in bot.iter_messages(e.chat_id, from_user="me"): - if i > 1: - break - i = i + 1 - await message.delete() + await x.delete() if LOGGER: await bot.send_message( LOGGER_GROUP, diff --git a/userbot/modules/evaluators.py b/userbot/modules/evaluators.py index bee4acdf7..5d65aa632 100644 --- a/userbot/modules/evaluators.py +++ b/userbot/modules/evaluators.py @@ -1,7 +1,7 @@ import inspect import hastebin import subprocess -from userbot import LOGGER, LOGGER_GROUP +from userbot import * from telethon import TelegramClient, events from userbot import bot diff --git a/userbot/modules/memes.py b/userbot/modules/memes.py index ae80bc258..191ee1848 100644 --- a/userbot/modules/memes.py +++ b/userbot/modules/memes.py @@ -150,8 +150,8 @@ async def faces(e): if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): textx = await e.get_reply_message() message=e.text - if message[4:]: - message = str(message[6:]) + if message[5:]: + message = str(message[5:]) elif textx: message = textx message = str(message.message) diff --git a/userbot/modules/misc.py b/userbot/modules/misc.py index e279584f4..7c951c6b2 100644 --- a/userbot/modules/misc.py +++ b/userbot/modules/misc.py @@ -257,7 +257,7 @@ async def sysdetails(e): @bot.on(events.MessageEdited(outgoing=True, pattern="^.botversion$")) async def bot_ver(e): if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): - await e.edit("`UserBot Version: Modular r2.1-b`") + await e.edit("`UserBot Version: Modular r2.1`") @bot.on(events.NewMessage(outgoing=True, pattern="^.userid$")) diff --git a/userbot/modules/scrapers.py b/userbot/modules/scrapers.py index ff7465fec..bf022fbbd 100644 --- a/userbot/modules/scrapers.py +++ b/userbot/modules/scrapers.py @@ -38,7 +38,7 @@ async def img_sampler(e): await bot.send_file(await bot.get_input_entity(e.chat_id), lst) end = round(time.time() * 1000) msstartend = int(end) - int(start) - await e.edit("Done. Time taken: " + str(msstartend) + "s") + await e.delete() @bot.on(events.NewMessage(outgoing=True, pattern=r"^.google (.*)")) @@ -48,11 +48,8 @@ async def gsearch(e): match = e.pattern_match.group(1) result_ = subprocess.run(["gsearch", match], stdout=subprocess.PIPE) result = str(result_.stdout.decode()) - await bot.send_message( - await bot.get_input_entity(e.chat_id), - message="**Search Query:**\n`" + match + "`\n\n**Result:**\n" + result, - reply_to=e.id, - link_preview=False, + await e.edit( + "**Search Query:**\n`" + match + "`\n\n**Result:**\n" + result ) if LOGGER: await bot.send_message( @@ -67,11 +64,8 @@ async def wiki(e): if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): match = e.pattern_match.group(1) result = wikipedia.summary(match) - await bot.send_message( - await bot.get_input_entity(e.chat_id), - message="**Search:**\n`" + match + "`\n\n**Result:**\n" + result, - reply_to=e.id, - link_preview=False, + await e.edit( + "**Search:**\n`" + match + "`\n\n**Result:**\n" + result ) if LOGGER: await bot.send_message( diff --git a/userbot/modules/screencapture.py b/userbot/modules/screencapture.py index b7207c086..61072eb7b 100644 --- a/userbot/modules/screencapture.py +++ b/userbot/modules/screencapture.py @@ -12,8 +12,6 @@ @bot.on(events.MessageEdited(pattern=r".screencapture (.*)", outgoing=True)) async def _(e): if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): - if e.fwd_from: - return if SCREEN_SHOT_LAYER_ACCESS_KEY is None: await e.edit( "Need to get an API key from https://screenshotlayer.com/product \nModule stopping!" diff --git a/userbot/modules/sql_helper/gmute_sql.py b/userbot/modules/sql_helper/gmute_sql.py new file mode 100644 index 000000000..264a08a32 --- /dev/null +++ b/userbot/modules/sql_helper/gmute_sql.py @@ -0,0 +1,39 @@ +try: + from userbot.modules.sql_helper import SESSION, BASE +except ImportError: + raise Exception("Hello!") + +from sqlalchemy import Column, String, UnicodeText, Boolean, Integer, distinct, func + + +class GMute(BASE): + __tablename__ = "gmute" + sender = Column(String(14), primary_key=True) + + def __init__(self, sender): + self.sender = str(sender) + + +GMute.__table__.create(checkfirst=True) + + +def is_gmuted(sender_id): + try: + return SESSION.query(GMute).all() + except: + return None + finally: + SESSION.close() + + +def gmute(sender): + adder = GMute(str(sender)) + SESSION.add(adder) + SESSION.commit() + + +def ungmute(sender): + rem = SESSION.query(GMute).get((str(sender))) + if rem: + SESSION.delete(rem) + SESSION.commit()