Skip to content

Commit

Permalink
Releasing 2.1, also has fixes for known issues, and gspider also added
Browse files Browse the repository at this point in the history
Signed-off-by: baalajmaestro <[email protected]>
  • Loading branch information
baalajimaestro committed Jan 11, 2019
1 parent e77e415 commit f2d3f2b
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 37 deletions.
2 changes: 1 addition & 1 deletion userbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
43 changes: 43 additions & 0 deletions userbot/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)
33 changes: 14 additions & 19 deletions userbot/modules/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion userbot/modules/evaluators.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions userbot/modules/memes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion userbot/modules/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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$"))
Expand Down
16 changes: 5 additions & 11 deletions userbot/modules/scrapers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (.*)"))
Expand All @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions userbot/modules/screencapture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
39 changes: 39 additions & 0 deletions userbot/modules/sql_helper/gmute_sql.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit f2d3f2b

Please sign in to comment.