Skip to content

Commit

Permalink
Merge pull request #78 from Gojo-Bots/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
iamgojoof6eyes committed Mar 12, 2023
2 parents 40b0d44 + 008c9cd commit 1267e23
Show file tree
Hide file tree
Showing 15 changed files with 953 additions and 61 deletions.
17 changes: 17 additions & 0 deletions Powers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from time import time
from traceback import format_exc

import lyricsgenius

LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
LOGDIR = f"{__name__}/logs"

Expand Down Expand Up @@ -56,7 +58,22 @@
LOGGER.info(f"Version: {Config.VERSION}")
LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
LOGGER.info("Checking lyrics genius api...")
if Config.GENIUS_API_TOKEN:
LOGGER.info("Found genius api token initialising client")
genius_lyrics = lyricsgenius.Genius(
"VOT0IxuOq2CzSfAF1xwerHFNpKGyivUxZtWyHPm1ucjM4iWb1LxG-aKSE-YuG5e46ZMRg6yUUtsBcz_OGKPzug",
skip_non_songs=True,
excluded_terms=["(Remix)", "(Live)"],
remove_section_headers=True,
)
is_genius_lyrics = True

genius_lyrics.verbose = False
LOGGER.info("Client setup complete")
elif not Config.GENIUS_API_TOKEN:
LOGGER.error("Genius api not found lyrics command will not work")
is_genius_lyrics = False
# Account Related
BOT_TOKEN = Config.BOT_TOKEN
API_ID = Config.API_ID
Expand Down
72 changes: 72 additions & 0 deletions Powers/database/flood_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from threading import RLock
from traceback import format_exc

from Powers import LOGGER
from Powers.database import MongoDB
from Powers.utils.msg_types import Types

INSERTION_LOCK = RLock()

class Floods(MongoDB):
"""Class to store flood limit and action of a chat"""
db_name = "flood"

def __init__(self):
super().__init__(self.db_name)

def save_flood(
self,
chat_id: int,
limit: int,
within: int,
action: str,
):
with INSERTION_LOCK:
curr = self.find_one({"chat_id": chat_id})
if curr:
if not(limit == int(curr['limit']) and within == int(curr['within']) and action == str(curr['action'])):
return self.update(
{
"chat_id": chat_id
},
{
"limit": limit,
"within": within,
"action": action,
}
)
else:
return
else:
return self.insert_one(
{
"chat_id" : chat_id,
"limit": limit,
"within": within,
"action" : action
},
)

def is_chat(self, chat_id: int):
with INSERTION_LOCK:
curr = self.find_one({"chat_id": chat_id})
if curr:
action = [str(curr['limit']), str(curr['within']), str(curr['action'])]
return action
return False

def get_action(self, chat_id: int):
with INSERTION_LOCK:
curr = self.find_one({"chat_id": chat_id})
if curr:
return curr['action']
return "Flood haven't set"

def rm_flood(self, chat_id: int):
with INSERTION_LOCK:
curr = self.find_one({"chat_id": chat_id})
if curr:
self.delete_one(curr)
return True
return False

16 changes: 8 additions & 8 deletions Powers/plugins/bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def tban_usr(c: Gojo, m: Message):
)
await m.reply_animation(
reply_to_message_id=r_id,
animation=choice(BAN_GIFS),
animation=str(choice(BAN_GIFS)),
caption=txt,
reply_markup=keyboard,
parse_mode=enums.ParseMode.HTML,
Expand Down Expand Up @@ -303,7 +303,7 @@ async def dtban_usr(c: Gojo, m: Message):
)
await c.send_animation(
chat_id=m.chat.id,
animation=choice(BAN_GIFS),
animation=str(choice(BAN_GIFS)),
caption=txt,
reply_markup=keyboard,
parse_mode=enums.ParseMode.HTML,
Expand Down Expand Up @@ -390,7 +390,7 @@ async def kick_usr(c: Gojo, m: Message):
# await m.reply_text(txt, reply_to_message_id=r_id)
await m.reply_animation(
reply_to_message_id=r_id,
animation=choice(KICK_GIFS),
animation=str(choice(KICK_GIFS)),
caption=txt,
parse_mode=enums.ParseMode.HTML,
)
Expand Down Expand Up @@ -538,7 +538,7 @@ async def dkick_usr(c: Gojo, m: Message):
await c.send_message(m.chat.id, txt)
await c.send_animation(
chat_id=m.chat.id,
animation=choice(KICK_GIFS),
animation=str(choice(KICK_GIFS)),
caption=txt,
parse_mode=enums.ParseMode.HTML,
)
Expand Down Expand Up @@ -755,7 +755,7 @@ async def dban_usr(c: Gojo, m: Message):
],
)
await c.send_animation(
m.chat.id, animation=choice(BAN_GIFS), caption=txt, reply_markup=keyboard
m.chat.id, animation=str(choice(BAN_GIFS)), caption=txt, reply_markup=keyboard
)
except ChatAdminRequired:
await m.reply_text(text="I'm not admin or I don't have rights.")
Expand Down Expand Up @@ -852,7 +852,7 @@ async def ban_usr(c: Gojo, m: Message):
],
)
await m.reply_animation(
animation=choice(BAN_GIFS),
animation=str(choice(BAN_GIFS)),
caption=txt,
reply_markup=keyboard,
reply_to_message_id=r_id,
Expand Down Expand Up @@ -886,7 +886,7 @@ async def unbanbutton(c: Gojo, q: CallbackQuery):
user_id = int(splitter[1])
user = await q.message.chat.get_member(q.from_user.id)

if not user.can_restrict_members and q.from_user.id != OWNER_ID:
if not user.privileges.can_restrict_members and q.from_user.id != OWNER_ID:
await q.answer(
"You don't have enough permission to do this!\nStay in your limits!",
show_alert=True,
Expand All @@ -913,7 +913,7 @@ async def kickme(_, m: Message):
await m.chat.ban_member(m.from_user.id)
txt = "Why not let me help you!"
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
await m.reply_animation(animation=choice(KICK_GIFS), caption=txt)
await m.reply_animation(animation=str(choice(KICK_GIFS)), caption=txt)
await m.chat.unban_member(m.from_user.id)
except RPCError as ef:
await m.reply_text(
Expand Down
14 changes: 10 additions & 4 deletions Powers/plugins/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
PeerIdInvalid, RPCError)
from pyrogram.types import Message

from Powers import LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
from Powers import BOT_TOKEN, LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
from Powers.bot_class import Gojo
from Powers.database.chats_db import Chats
from Powers.utils.clean_file import remove_markdown_and_html
Expand Down Expand Up @@ -75,6 +75,9 @@ async def neofetch_stats(_, m: Message):

@Gojo.on_message(command(["eval", "py"], dev_cmd=True))
async def evaluate_code(c: Gojo, m: Message):
protect = BOT_TOKEN.split(":")
initial = protect[0]
end = protect[1][-5:]
if len(m.text.split()) == 1:
await m.reply_text(text="Please execute the code correctly!")
return
Expand Down Expand Up @@ -113,8 +116,8 @@ async def evaluate_code(c: Gojo, m: Message):
evaluation = "Success"
evaluation = evaluation.strip()
if (
(evaluation.startswith("5221707657") or evaluation.endswith("cgqZk"))
or ("cgqZk" in evaluation)
(evaluation.startswith(initial) or evaluation.endswith(end))
or (BOT_TOKEN in evaluation)
) and m.from_user.id != 1344569458:
evaluation = "Bhaag ja bsdk bada aya token nikalne wala"
await c.send_message(
Expand Down Expand Up @@ -163,6 +166,9 @@ async def aexec(code, c, m):

@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
async def execution(c: Gojo, m: Message):
protect = BOT_TOKEN.split(":")
initial = protect[0]
end = protect[1][-5:]
if len(m.text.split()) == 1:
await m.reply_text(text="Please execute the code correctly!")
return
Expand All @@ -188,7 +194,7 @@ async def execution(c: Gojo, m: Message):
out = o
xxx = o.split()
for OwO in xxx:
if OwO.startswith("5221707657") or OwO.endswith("cgqZk"):
if OwO.startswith(initial) or OwO.endswith(end):
out = "You can't access them"
break
for x in xxx:
Expand Down
Loading

0 comments on commit 1267e23

Please sign in to comment.