Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
94033a5
Update version.py
HellBoy-OP Aug 29, 2021
7373b2a
Update vars.py
HellBoy-OP Aug 30, 2021
5c081a8
Update gcast.py
HellBoy-OP Aug 30, 2021
183240c
Update admins.py
HellBoy-OP Aug 30, 2021
3d7a237
Update admins.py
HellBoy-OP Aug 30, 2021
fb3b6fa
Update invite.py
HellBoy-OP Aug 30, 2021
ec98a7c
Update admins.py
HellBoy-OP Aug 31, 2021
011096f
Update afk.py
HellBoy-OP Aug 31, 2021
6c77399
Update afk.py
HellBoy-OP Aug 31, 2021
b8fbf51
Update afk.py
HellBoy-OP Aug 31, 2021
34e2080
Update google.py
HellBoy-OP Aug 31, 2021
29ac4c4
Update google.py
HellBoy-OP Aug 31, 2021
2c9a72d
Create config_str.py
HellBoy-OP Aug 31, 2021
91e395a
Update __init__.py
HellBoy-OP Aug 31, 2021
b0d5ba0
Update heroku.py
HellBoy-OP Aug 31, 2021
3383a6b
Update __init__.py
HellBoy-OP Aug 31, 2021
d958ed7
Update heroku.py
HellBoy-OP Aug 31, 2021
d72a012
Create reload.sh
HellBoy-OP Aug 31, 2021
479a8d4
Update start.sh
HellBoy-OP Aug 31, 2021
057c0ca
Update hell_config.py
HellBoy-OP Aug 31, 2021
365e8c7
Delete hell_config.py
HellBoy-OP Aug 31, 2021
191eea8
Create hell_config.py
HellBoy-OP Aug 31, 2021
d9617d0
Update vars.py
HellBoy-OP Aug 31, 2021
76104fa
Update __init__.py
HellBoy-OP Aug 31, 2021
8cfb72e
Update cmds.py
HellBoy-OP Aug 31, 2021
0f7151c
Update __init__.py
HellBoy-OP Aug 31, 2021
820b299
Update sudo.py
HellBoy-OP Aug 31, 2021
16e7325
Update start.sh
HellBoy-OP Aug 31, 2021
abecced
Update bot.py
HellBoy-OP Aug 31, 2021
f17c185
Uff
HellBoy-OP Aug 31, 2021
02c19bd
Update config_str.py
HellBoy-OP Aug 31, 2021
848c09c
Update hell_config.py
HellBoy-OP Aug 31, 2021
6a6f37c
Update gcast.py
HellBoy-OP Aug 31, 2021
9c6abae
Update heroku.py
HellBoy-OP Aug 31, 2021
bd10b70
Update protecc.py
HellBoy-OP Aug 31, 2021
92708db
Update __init__.py
HellBoy-OP Sep 1, 2021
0eb9f4f
Update __init__.py
HellBoy-OP Sep 1, 2021
0c8e6f7
Update __init__.py
HellBoy-OP Sep 1, 2021
72e1755
Update __init__.py
HellBoy-OP Sep 1, 2021
1105de6
Update convert.py
HellBoy-OP Sep 1, 2021
8a4bc90
Update __init__.py
HellBoy-OP Sep 1, 2021
b608d43
Update __init__.py
HellBoy-OP Sep 1, 2021
17177ac
Update __init__.py
HellBoy-OP Sep 1, 2021
972a232
Update plug.py
HellBoy-OP Sep 1, 2021
174c149
Update plug.py
HellBoy-OP Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 40 additions & 26 deletions hellbot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import heroku3
import os
import sys
import time
import datetime

from distutils.util import strtobool as sb
from logging import DEBUG, INFO, basicConfig, getLogger

import heroku3
from dotenv import load_dotenv
from requests import get
from telethon import TelegramClient
from telethon.network.connection.tcpabridged import ConnectionTcpAbridged
from telethon.sessions import StringSession

from hellbot.config import Config

StartTime = datetime.datetime.now()

StartTime = time.time()
CONSOLE_LOGGER_VERBOSE = sb(os.environ.get("CONSOLE_LOGGER_VERBOSE", "False"))


if CONSOLE_LOGGER_VERBOSE:
basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
Expand All @@ -25,9 +25,44 @@
else:
basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=INFO)


LOGS = getLogger(__name__)


if Config.HELLBOT_SESSION:
session = StringSession(str(Config.HELLBOT_SESSION))
else:
session = "hellbot"


try:
Hell = TelegramClient(
session=session,
api_id=Config.APP_ID,
api_hash=Config.API_HASH,
connection=ConnectionTcpAbridged,
auto_reconnect=True,
connection_retries=None,
)
except Exception as e:
print(f"HELLBOT_SESSION - {e}")
sys.exit()


HellBot = TelegramClient(
session="Hell-TBot",
api_id=Config.APP_ID,
api_hash=Config.API_HASH,
connection=ConnectionTcpAbridged,
auto_reconnect=True,
connection_retries=None,
).start(bot_token=Config.BOT_TOKEN)


bot = Hell
tbot = HellBot

try:
if Config.HEROKU_API_KEY is not None or Config.HEROKU_APP_NAME is not None:
HEROKU_APP = heroku3.from_key(Config.HEROKU_API_KEY).apps()[
Expand All @@ -39,27 +74,6 @@
HEROKU_APP = None


if Config.HELLBOT_SESSION:
session_name = str(Config.HELLBOT_SESSION)
try:
if session_name.endswith("="):
bot = TelegramClient(
StringSession(session_name), Config.APP_ID, Config.API_HASH
)
else:
bot = TelegramClient(
"BOT_TOKEN", api_id=Config.APP_ID, api_hash=Config.API_HASH
).start(bot_token=Config.HELLBOT_SESSION)
except Exception as e:
LOGS.warn(f"HELLBOT_SESSION - {str(e)}")
sys.exit()
else:
session_name = "startup"
bot = TelegramClient(session_name, Config.APP_ID, Config.API_HASH)

tbot = TelegramClient('hellbot', api_id=Config.APP_ID, api_hash=Config.API_HASH).start(bot_token=Config.BOT_TOKEN)


# global variables
CMD_LIST = {}
CMD_HELP = {}
Expand Down
1 change: 1 addition & 0 deletions hellbot/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .config_str import config_list
from .vars import Config
14 changes: 14 additions & 0 deletions hellbot/config/config_str.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
config_list = [
"ALIVE_MSG",
"ALIVE_PIC",
"BAN_PIC",
"BAN_TEXT",
"BIO_MSG",
"BL_CHAT",
"BUTTONS_IN_HELP",
"CUSTOM_PMPERMIT",
"HELP_PIC",
"PMPERMIT_PIC",
"STICKER_PACKNAME",
"YOUR_NAME",
]
4 changes: 0 additions & 4 deletions hell_config.py → hellbot/config/hell_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
from telethon.tl.types import ChatBannedRights


class Config(object):
LOGGER = True
ABUSE = os.environ.get("ABUSE", None)
Expand Down Expand Up @@ -110,6 +109,3 @@ class Production(Config):

class Development(Config):
LOGGER = True


# hellbot
9 changes: 4 additions & 5 deletions hellbot/config/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import os

ENV = bool(os.environ.get("ENV", False))

if ENV:
from hell_config import Config
if os.path.exists("config.py"):
from config import Development as Config
else:
if os.path.exists("config.py"):
from config import Development as Config
from .hell_config import Config


# hellbot
22 changes: 22 additions & 0 deletions hellbot/helpers/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,26 @@ def deEmojify(inputString: str) -> str:
return re.sub(EMOJI_PATTERN, "", inputString)


async def get_time(seconds: int) -> str:
count = 0
up_time = ""
time_list = []
time_suffix_list = ["s", "m", "h", "days"]
while count < 4:
count += 1
remainder, result = divmod(seconds, 60) if count < 3 else divmod(seconds, 24)
if seconds == 0 and remainder == 0:
break
time_list.append(int(result))
seconds = int(remainder)
hmm = len(time_list)
for x in range(hmm):
time_list[x] = str(time_list[x]) + time_suffix_list[x]
if len(time_list) == 4:
up_time += time_list.pop() + ", "
time_list.reverse()
up_time += ":".join(time_list)
return up_time


# hellbot
6 changes: 4 additions & 2 deletions hellbot/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import datetime
import time

from hellbot import *
from hellbot.config import Config
from hellbot.helpers import *
from hellbot.utils import *
from hellbot.random_strings import *
from hellbot.version import __hell__
from hellbot.sql.gvar_sql import gvarstat
from telethon import version


Expand Down Expand Up @@ -40,8 +43,7 @@ async def get_user_id(ids):
else:
abuse_m ="Disabled"

START_TIME = datetime.datetime.now()
uptime = f"{str(datetime.datetime.now() - START_TIME).split('.')[0]}"

my_channel = Config.MY_CHANNEL or "Its_HellBot"
my_group = Config.MY_GROUP or "HellBot_Chat"
if "@" in my_channel:
Expand Down
51 changes: 41 additions & 10 deletions hellbot/plugins/admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from telethon.tl.functions.channels import EditAdminRequest, EditBannedRequest, EditPhotoRequest
from telethon.tl.functions.messages import UpdatePinnedMessageRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import ChatAdminRights, ChatBannedRights, MessageEntityMentionName, MessageMediaPhoto
from telethon.tl.types import ChatAdminRights, ChatBannedRights, ChannelParticipantsAdmins, MessageEntityMentionName, MessageMediaPhoto

from . import *
from hellbot.sql.mute_sql import is_muted, mute, unmute
Expand Down Expand Up @@ -178,6 +178,7 @@ async def demote(dmod):
f"CHAT: {dmod.chat.title}(`{dmod.chat_id}`)",
)


@command(incoming=True)
async def watcher(event):
if is_muted(event.sender_id, event.chat_id):
Expand Down Expand Up @@ -207,10 +208,14 @@ async def muth(hell):
await eor(hell, f"**Error **\n`{str(e)}`")
else:
await eor(hell, "**Chup Reh Lawde 🥴\n`**`-´)⊃━☆゚.*・。゚ **`")
else:
elif hell.is_group:
hellevent = await eor(hell, "`Muting...`")
input_str = hell.pattern_match.group(1)
chat = await hell.get_chat()
admin_ = []
async for admins in bot.iter_participants(chat, filter=ChannelParticipantsAdmins):
x = admins.id
admin_.append(x)
if hell.reply_to_msg_id:
userid = (await hell.get_reply_message()).sender_id
name = (await hell.client.get_entity(userid)).first_name
Expand All @@ -225,11 +230,22 @@ async def muth(hell):
userid = (await hell.client.get_entity(input_str)).id
name = (await hell.client.get_entity(userid)).first_name
else:
return await eod(hellevent, "I Need a user to mute!!", 5)
return await eod(hellevent, "I Need a user to mute!!")
if userid == ForGo10God:
return await eod(hellevent, "Nashe me hai kya lawde", 5)
return await eod(hellevent, "Nashe me hai kya lawde")
if str(userid) in DEVLIST:
return await eod(hellevent, "**Error Muting God**", 7)
if ForGo10God not in admin_:
return await eod(hellevent, NO_PERM)
if userid in admin_:
if is_muted(userid, hell.chat_id):
return await hellevent.edit("Admin already muted ♪~(´ε` )")
try:
mute(userid, hell.chat_id)
except Exception as e:
await hellevent.edit(f"**Error :** \n\n`{e}`")
else:
return await hellevent.edit(f"**🌝 Muted admin** [{name}](tg://user?id={userid}) **in** `{chat.title}` (~‾▿‾)~")
try:
await hell.client.edit_permissions(
chat.id,
Expand All @@ -249,8 +265,8 @@ async def muth(hell):
f"\nUSER: [{name}](tg://user?id={userid})\n"
f"CHAT: {chat.title}",
)


@bot.on(hell_cmd(pattern=r"unmute ?(.*)"))
@bot.on(sudo_cmd(pattern=r"unmute ?(.*)", allow_sudo=True))
async def nomuth(evn):
Expand All @@ -270,10 +286,14 @@ async def nomuth(evn):
await eor(evn,
"Abb boll bsdk."
)
else:
elif evn.is_group:
hellevent = await eor(evn, "`Unmuting...`")
input_str = evn.pattern_match.group(1)
chat = await evn.get_chat()
admin_ = []
async for admins in bot.iter_participants(chat, filter=ChannelParticipantsAdmins):
x = admins.id
admin_.append(x)
if evn.reply_to_msg_id:
userid = (await evn.get_reply_message()).sender_id
name = (await evn.client.get_entity(userid)).first_name
Expand All @@ -288,7 +308,18 @@ async def nomuth(evn):
userid = (await evn.client.get_entity(input_str)).id
name = (await evn.client.get_entity(userid)).first_name
else:
return await eod(hellevent, "I need a user to unmute!!", 3)
return await eod(hellevent, "I need a user to unmute!!")
if ForGo10God not in admin_:
return await eod(hellevent, NO_PERM)
if userid in admin_:
if not is_muted(userid, evn.chat_id):
return await hellevent.edit("Not even muted.")
try:
unmute(userid, evn.chat_id)
except Exception as e:
await hellevent.edit(f"**Error :** \n\n`{e}`")
else:
return await hellevent.edit("**Successfully Unmuted** [{name}](tg://user?id={userid}) **in** `{chat.title}`")
try:
await evn.client.edit_permissions(
chat.id,
Expand Down Expand Up @@ -599,9 +630,9 @@ async def get_user_from_id(user, event):
).add_command(
"unban", "<username/reply>", "Removes the ban from the person in the chat."
).add_command(
"mute", "<reply>/<userid or username>", "Mutes the person in the group. Works on non-admins only"
"mute", "<reply>/<userid or username>", "Mutes mentioned user in current PM/Group. Mutes non-admins by restricting their rights and mutes admins by deleting their new messages."
).add_command(
"unmute", "<reply>/<userid or username>", "Unmutes the person muted in that group."
"unmute", "<reply>/<userid or username>", "Unmutes the person muted in that PM/Group."
).add_command(
"pin", "<reply> or .pin loud", "Pins the replied message in Group"
).add_command(
Expand Down
Loading