Skip to content

Commit

Permalink
Reverting the sql
Browse files Browse the repository at this point in the history
revert sql
  • Loading branch information
xditya authored Dec 10, 2020
2 parents 6de372a + 623bc7b commit 5c93430
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 268 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN if [ ! -e /usr/bin/python ]; then ln -sf /usr/bin/python3 /usr/bin/python; f
RUN rm -r /root/.cache
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt install -y ./google-chrome-stable_current_amd64.deb && rm google-chrome-stable_current_amd64.deb
RUN wget https://chromedriver.storage.googleapis.com/86.0.4240.22/chromedriver_linux64.zip && unzip chromedriver_linux64.zip && chmod +x chromedriver && mv -f chromedriver /usr/bin/ && rm chromedriver_linux64.zip
RUN git clone https://github.com/xditya/TeleBot /root/telebot
RUN git clone -b beta https://github.com/xditya/TeleBot /root/telebot
RUN mkdir /root/telebot/bin/
WORKDIR /root/telebot/
RUN chmod +x /usr/local/bin/*
Expand Down
65 changes: 11 additions & 54 deletions telebot/plugins/globalban.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# Imported by @its_xditya

from telethon.events import ChatAction
from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
from telethon.tl.types import MessageEntityMentionName

from telebot import CMD_HELP, bot
from telebot.plugins.sql_helper.gban_sql import *

from . import TELE_NAME
from telebot.utils import admin_cmd

client = bot

Expand Down Expand Up @@ -70,14 +70,14 @@ async def get_user_from_id(user, event):
async def handler(tele):
if tele.user_joined or tele.user_added:
try:
from telebot.plugins.sql_helper.gban_sql import is_gbanned
from telebot.plugins.sql_helper.gmute_sql import is_gmuted

guser = await tele.get_user()
gbanned = is_gbanned(guser.id)
gmuted = is_gmuted(guser.id)
except BaseException:
return
if gbanned:
for i in gbanned:
if gmuted:
for i in gmuted:
if i.sender == str(guser.id):
chat = await tele.get_chat()
admin = chat.admin_rights
Expand Down Expand Up @@ -129,7 +129,7 @@ async def gspider(rk):
if user.id == 719195224:
return await rkp.edit("**Error! cant gban this user.**")
try:
from telebot.plugins.sql_helper.gban_sql import gban
from telebot.plugins.sql_helper.gmute_sql import gmute
except BaseException:
pass
try:
Expand All @@ -151,7 +151,7 @@ async def gspider(rk):
else:
await rkp.edit(f"**Reply to a user !! **")
try:
if gban(user.id) is False:
if gmute(user.id) is False:
return await rkp.edit(f"**Error! User probably already gbanned.**")
except BaseException:
pass
Expand Down Expand Up @@ -193,7 +193,7 @@ async def gspider(rk):
if user.id == 719195224:
return await rkp.edit(f"**Error! cant ungban this user.**")
try:
from telebot.plugins.sql_helper.gban_sql import ungban
from telebot.plugins.sql_helper.gmute_sql import ungmute
except BaseException:
pass
try:
Expand All @@ -215,7 +215,7 @@ async def gspider(rk):
else:
await rkp.edit(f"**Reply to a user !! **")
try:
if ungban(user.id) is False:
if ungmute(user.id) is False:
return await rkp.edit(f"**Error! User probably already ungbanned.**")
except BaseException:
pass
Expand All @@ -233,46 +233,3 @@ async def gspider(rk):
"
}
)


@telebot.on(admin_cmd(pattern="listgbanned"))
@telebot.on(sudo_cmd(pattern="listgbanned", allow_sudo=True))
async def list(event):
try:
from telebot.plugins.sql_helper.gban_sql import all_gbanned
except BaseException:
await event.edit("Error. SQL Not found!")
return
doing = await eor(event, "`Making a list of GBanned Users`")
allgbanned = all_gbanned()
userlist = f"List of GBanned users by {TELE_NAME}\n"
if len(allgbanned) > 0:
for i in allgbanned:
userlist += f"✘ [{i.sender}](tg://user?id={i.sender})"
else:
userlist = f"`{TELE_NAME} has not GBanned anyone!`"
if len(userlist) > 4095:
with io.BytesIO(str.encode(userlist)) as gbanned_list:
gbanned_list.name = "GBanned.text"
await telebot.send_file(
event.chat_id,
gbanned_list,
force_document=True,
allow_cache=False,
caption=f"List of GBanned Users by {TELE_NAME}",
reply_to=event,
)
await event.delete()
else:
await doing.edit(userlist)


CMD_HELP.update(
{
"gban": ".gban <username/userid/reply to a user>\
\nUse - Global ban the person in all groups, channels , block in pm , add gban watch (use with solution)\
\n\n.ungban <username/userid/reply to a user>\
\nUse - UnbGan user from all groups, channels , remove user from gban watch.\
\n\n.listgbanned\nUse - List all gbanned users."
}
)
131 changes: 34 additions & 97 deletions telebot/plugins/gmute.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
# TeleBot - UserBot
# Copyright (C) 2020 TeleBot

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import asyncio

from telebot.plugins import OWNER_ID, TELE_NAME
from telebot.plugins.sql_helper.gmute_sql import all_gmuted, gmute, is_gmuted, ungmute
from telebot.telebotConfig import Var
from telebot import CMD_HELP
from telebot.plugins.sql_helper.mute_sql import is_muted, mute, unmute
from telebot.utils import admin_cmd


@telebot.on(admin_cmd(pattern=r"gmute ?(\d+)?"))
async def gmoot(event):
tele = await eor(event, "`GMuting user...`")
@telebot.on(admin_cmd(outgoing=True, pattern=r"gmute ?(\d+)?"))
@telebot.on(sudo_cmd(allow_sudo=True, pattern=r"gmute ?(\d+)?"))
async def startgmute(event):
private = False
if event.fwd_from:
return
reply = await event.get_reply_message()
userid = reply.sender_id
if userid == OWNER_ID:
await tele.edit(r"Are you dumb nigga? Why would you mute yourself!!")
return
elif event.is_private:
await tele.edit("Globally muted [user](tg://user?id={})".format(userid))
await eor(event, "Unexpected issues or ugly errors may occur!")
await asyncio.sleep(3)
private = True
reply = await event.get_reply_message()
Expand All @@ -44,42 +23,29 @@ async def gmoot(event):
elif private is True:
userid = event.chat_id
else:
return await tele.edit("`Reply to a person or give me his id to GMute!!`")
return await eor(
event, "Please reply to a user or add their into the command to gmute them."
)
event.chat_id
await event.get_chat()
if is_gmuted(userid, "gmute"):
return await tele.edit(
"This [user](tg://user?id={}) is already GMuted!!".format(userid)
)
if is_muted(userid, "gmute"):
return await eor(event, "This user is already gmuted")
try:
gmute(userid, "gmute")
mute(userid, "gmute")
except Exception as e:
await tele.edit("**Error**\n" + str(e))
await eor(event, "Error occured!\nError is " + str(e))
else:
await tele.edit(
"**GMuted!**\nUserID - {}\nLink - [here](tg://user?id={})".format(
userid, userid
)
)
try:
await telebot.send_message(
Var.PRIVATE_GROUP_ID,
"#GMute\nUserID - {}\nLink - [here](tg://user?id={})".format(
userid, userid
),
)
except BaseException:
pass
await eor(event, "Silence now. **Successfully gmuted that person**")


@telebot.on(admin_cmd(pattern=r"ungmute ?(\d+)?"))
@telebot.on(admin_cmd(outgoing=True, pattern=r"ungmute ?(\d+)?"))
@telebot.on(sudo_cmd(allow_sudo=True, pattern=r"ungmute ?(\d+)?"))
async def endgmute(event):
private = False
tele = await eor(event, "`UnGMuting user...`")
if event.fwd_from:
return
elif event.is_private:
await tele.edit("UnGMuted user")
await eor(event, "Unexpected issues or ugly errors may occur!")
await asyncio.sleep(3)
private = True
reply = await event.get_reply_message()
Expand All @@ -90,59 +56,30 @@ async def endgmute(event):
elif private is True:
userid = event.chat_id
else:
return await tele.edit("`Reply to a person or give me his id to UnGMute!!`")
return await eor(
event,
"Please reply to a user or add their into the command to ungmute them.",
)
event.chat_id
if not is_gmuted(userid, "gmute"):
return await tele.edit("Hmm.. This person is not GMuted, yet!")
if not is_muted(userid, "gmute"):
return await eor(event, "This user is not gmuted")
try:
ungmute(userid, "gmute")
unmute(userid, "gmute")
except Exception as e:
await tele.edit("**Error**\n" + str(e))
await eor(event, "Error occured!\nError is " + str(e))
else:
await tele.edit(
"**UnGMuted!**\nUserID - {}\nLink - [here](tg://user?id={})".format(
userid, userid
)
)
try:
await telebot.send_message(
Var.PRIVATE_GROUP_ID,
"#UnGMute\nUserID - {}\nLink - [here](tg://user?id={})".format(
userid, userid
),
)
except BaseException:
pass
await eor(event, "Successfully ungmuted that person")


@command(incoming=True)
async def watcher(event):
if is_gmuted(event.sender_id, "gmute"):
if is_muted(event.sender_id, "gmute"):
await event.delete()


@telebot.on(admin_cmd(pattern="listgmuted"))
@telebot.on(sudo_cmd(pattern="listgmuted", allow_sudo=True))
async def list(event):
doing = await eor(event, "`Making a list of GMuted Users`")
allgmuted = all_gmuted()
userlist = f"List of GMuted users by {TELE_NAME}\n"
if len(allgmuted) > 0:
for i in allgmuted:
userlist += f"✘ [{i.sender}](tg://user?id={i.sender})"
else:
userlist = f"{TELE_NAME} has not GMuted anyone!"
if len(userlist) > 4095:
with io.BytesIO(str.encode(userlist)) as gmuted_list:
gmuted_list.name = "GMuted.text"
await telebot.send_file(
event.chat_id,
gmuted_list,
force_document=True,
allow_cache=False,
caption=f"List of GMuted Users by {TELE_NAME}",
reply_to=event,
)
await event.delete()
else:
await doing.edit(userlist)
CMD_HELP.update(
{
"gmute": ".gmute <reply to user>\nUse - Globally mute the person (across all chats).\
\n\n.ungmute <reply to user>\nUse - Globally UnMute the person."
}
)
Loading

0 comments on commit 5c93430

Please sign in to comment.