Skip to content

Commit

Permalink
Formated
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Sep 19, 2023
1 parent bc268cd commit 5a9e169
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 97 deletions.
13 changes: 3 additions & 10 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@

if not os.path.exists(folder):
os.makedirs(folder)
if (
os.path.exists(f"{folder}/logs.txt")
and os.stat(f"{folder}/logs.txt").st_size > 0
):
if os.path.exists(f"{folder}/logs.txt") and os.stat(f"{folder}/logs.txt").st_size > 0:
with open(f"{folder}/logs.txt", "w") as f:
f.truncate(0)
print(
f'{colored("[INFO]", "blue")}: LOG FILE WAS FLUSHED SUCCESSFULLY'
)
print(f'{colored("[INFO]", "blue")}: LOG FILE WAS FLUSHED SUCCESSFULLY')
f.close()
elif not os.path.exists(f"{folder}/logs.txt"):
try:
Expand Down Expand Up @@ -51,9 +46,7 @@
api_hash=config.API_HASH,
bot_token=config.BOT_TOKEN,
)
_factory = GroupCallFactory(
assistant, GroupCallFactory.MTPROTO_CLIENT_TYPE.PYROGRAM
)
_factory = GroupCallFactory(assistant, GroupCallFactory.MTPROTO_CLIENT_TYPE.PYROGRAM)
on_call = _factory.get_group_call()
assistant.start()
kreacher.start()
4 changes: 1 addition & 3 deletions bot/callbacks/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ async def _(client: Client, callback: CallbackQuery):
"\U0001F9D9 ᴀᴅᴅ ᴍᴇ",
url=f"https://t.me/{config:BOT_USERNAME}?startgroup=true",
),
InlineKeyboardButton(
"/U0002753 ʜᴇʟᴘ", callback_data="help"
),
InlineKeyboardButton("/U0002753 ʜᴇʟᴘ", callback_data="help"),
]
]
),
Expand Down
4 changes: 1 addition & 3 deletions bot/callbacks/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ async def _(client: Client, callback: CallbackQuery):
"\u25B6\uFE0F",
callback_data="pause_or_resume",
),
InlineKeyboardButton(
"\u23ED\uFE0F", callback_data="next"
),
InlineKeyboardButton("\u23ED\uFE0F", callback_data="next"),
],
]
),
Expand Down
8 changes: 0 additions & 8 deletions bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@ def __init__(self):
load_dotenv(path)
self.API_HASH = os.getenv("API_HASH")
self.API_ID = os.getenv("API_ID")
self.ASSISTANT_ID = os.getenv("ASSISTANT_ID")
self.AUTO_LEAVE = os.getenv("AUTO_LEAVING_ASSISTANT")
self.AUTO_LEAVE_TIME = os.getenv("AUTO_LEAVE_ASSISTANT_TIME")
self.BOT_OWNER = os.getenv("BOT_OWNER")
self.BOT_TOKEN = os.getenv("BOT_TOKEN")
self.BOT_USERNAME = os.getenv("BOT_USERNAME")
self.CHANNEL = os.getenv("CHANNEL")
self.CMD_IMG = os.getenv("CMD_IMG")
self.ES_MOVIES_CHANNEL = os.getenv("ES_MOVIES_CHANNEL")
self.ES_SERIES_CHANNEL = os.getenv("ES_SERIES_CHANNEL")
self.HEROKU_MODE = os.getenv("HEROKU_MODE")
self.MANAGEMENT_MODE = os.getenv("MANAGEMENT_MODE")
self.MANTAINER = os.getenv("MANTAINER")
self.SESSION_STRING = os.getenv("SESSION_STRING")
self.START_IMG = os.getenv("START_IMG")
self.SUPPORT = os.getenv("SUPPORT")


config = Config()
4 changes: 1 addition & 3 deletions bot/helpers/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ async def skip_current(chat):
if media_type == "audio":
await VOICE_CHATS[chat.id].start_audio(url, repeat=False)
elif media_type == "video":
await VOICE_CHATS[chat.id].start_video(
url, with_audio=True, repeat=False
)
await VOICE_CHATS[chat.id].start_video(url, with_audio=True, repeat=False)
pop_an_item(chat)
return [name, link, media_type]

Expand Down
4 changes: 1 addition & 3 deletions bot/helpers/pong.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ async def execution_time(seconds):
for unit, div in TIME_DURATION_UNITS:
amount, seconds = divmod(int(seconds), div)
if amount > 0:
parts.append(
"{}{}{}".format(amount, unit, "" if amount == 1 else "s")
)
parts.append("{}{}{}".format(amount, unit, "" if amount == 1 else "s"))
return ", ".join(parts)
2 changes: 1 addition & 1 deletion bot/modals/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ async def new_invoice(message: Message, net: str, sub_type: str):
"subscription": sub_type,
"userId": message.from_user.id,
}
)
)
2 changes: 1 addition & 1 deletion bot/modals/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ async def new_invoice(message: Message, net: str, sub_type: str):
"subscription": sub_type,
"userId": message.from_user.id,
}
)
)
4 changes: 1 addition & 3 deletions bot/plugins/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ async def _(client: Client, message: Message):
[
InlineKeyboardButton(
"Help and Commands!",
url="t.me/{}?start=help".format(
config.BOT_USERNAME
),
url="t.me/{}?start=help".format(config.BOT_USERNAME),
)
]
]
Expand Down
12 changes: 2 additions & 10 deletions bot/plugins/commands/me.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,8 @@ async def _(client: Client, message: Message):
if user[0]["subscription"]
else InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"\U0001f4b3 ɴᴏʀᴍᴀʟ", callback_data="normal"
)
],
[
InlineKeyboardButton(
"\U0001f4b3 ᴘʀᴇᴍɪᴜᴍ", callback_data="premium"
)
],
[InlineKeyboardButton("\U0001f4b3 ɴᴏʀᴍᴀʟ", callback_data="normal")],
[InlineKeyboardButton("\U0001f4b3 ᴘʀᴇᴍɪᴜᴍ", callback_data="premium")],
]
)
)
Expand Down
13 changes: 3 additions & 10 deletions bot/plugins/commands/play_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ async def _(client: Client, message: Message):
)
msg = await message.reply("\u23F3 **__Processing...__**")
await sleep(2)
file_type = message.reply_to_message.document.mime_type.split("/", 1)[
1
]
book = os.path.join(
c, f"../../downloads/books/{str(uuid.uuid4())}.{file_type}"
)
file_type = message.reply_to_message.document.mime_type.split("/", 1)[1]
book = os.path.join(c, f"../../downloads/books/{str(uuid.uuid4())}.{file_type}")

await msg.edit("\U0001f4be **__Downloading...__**")
f = await message.reply_to_message.download(
Expand Down Expand Up @@ -79,10 +75,7 @@ async def _(client: Client, message: Message):
if "." in page_number:
return await msg.edit("__Only integer numbers allowed__")
for index, item in enumerate(epub.get_items(), start=1):
if (
index == int(page_number)
and item.get_type() == ITEM_DOCUMENT
):
if index == int(page_number) and item.get_type() == ITEM_DOCUMENT:
h.feed(item.get_body_content().decode())
text += h.text
await sleep(2)
Expand Down
20 changes: 5 additions & 15 deletions bot/plugins/commands/play_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
async def _(client: Client, message: Message):
QUEUE = await load_pkl(queues, "rb", "dict")
data = await user_info(message.from_user)
download_as = os.path.join(
c, f"../../downloads/songs/{str(uuid.uuid4())}.mp3"
)
download_as = os.path.join(c, f"../../downloads/songs/{str(uuid.uuid4())}.mp3")
if message.chat.type == ChatType.PRIVATE:
return await message.reply(
"**__Mr. Wizard, this command can only be used in groups or channels__** \U0001f937\U0001f3fb\u200D\u2642\uFE0F"
Expand Down Expand Up @@ -110,9 +108,7 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"\u23EA", callback_data="back"
),
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
Expand Down Expand Up @@ -144,9 +140,7 @@ async def _(client: Client, message: Message):
progress=progress,
progress_args=(client, message.chat, msg),
)
proto = (
f"https://t.me/c/{message.chat.id}/{message.reply_to_message.id}"
)
proto = f"https://t.me/c/{message.chat.id}/{message.reply_to_message.id}"
msg_mention = proto.replace("/c/-100", "/c/")
if message.chat.id in QUEUE:
# pos = add_to_queue(message.chat, name, url, ref, "audio")
Expand All @@ -158,16 +152,12 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"\u23EA", callback_data="back"
),
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
),
InlineKeyboardButton(
"\u23ED\uFE0F", callback_data="next"
),
InlineKeyboardButton("\u23ED\uFE0F", callback_data="next"),
],
[
InlineKeyboardButton(
Expand Down
20 changes: 5 additions & 15 deletions bot/plugins/commands/play_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ async def _(client: Client, message: Message):
try:
msg = await message.reply("\u23F3 **__Processing...__**")
await sleep(2)
download_as = os.path.join(
c, f"../../downloads/videos/{str(uuid.uuid4())}.mp4"
)
download_as = os.path.join(c, f"../../downloads/videos/{str(uuid.uuid4())}.mp4")
if not message.reply_to_message and " " not in message.text:
return await msg.edit(
"❗ __Master, try with an: \n\nLive stream link.\n\nYouTube video/ link.\n\nReply to an video to start video streaming!__",
Expand All @@ -59,9 +57,7 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"\u23EA", callback_data="back"
),
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
Expand Down Expand Up @@ -120,9 +116,7 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"\u23EA", callback_data="back"
),
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
Expand Down Expand Up @@ -157,16 +151,12 @@ async def _(client: Client, message: Message):
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"\u23EA", callback_data="back"
),
InlineKeyboardButton("\u23EA", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
callback_data="pause_or_resume",
),
InlineKeyboardButton(
"\u23ED\uFE0F", callback_data="next"
),
InlineKeyboardButton("\u23ED\uFE0F", callback_data="next"),
],
],
),
Expand Down
4 changes: 1 addition & 3 deletions bot/plugins/commands/speedtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ async def _(client: Client, message: Message):
**__Sponsor:__** {result['server']['sponsor']}
**__Latency__**: {result['server']['latency']}
**__Ping__**: {result['ping']}"""
await kreacher.send_photo(
chat.id, photo=result["share"], caption=output
)
await kreacher.send_photo(chat.id, photo=result["share"], caption=output)
return await msg.delete()
except Exception as e:
return await msg.edit(
Expand Down
4 changes: 1 addition & 3 deletions bot/plugins/commands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ async def _(client: Client, message: Message):
"\U0001f52e ᴀᴅᴅ ᴍᴇ",
url=f"https://t.me/{config.BOT_USERNAME}?startgroup=true",
),
InlineKeyboardButton(
"\u2139\uFE0F ʜᴇʟᴘ", callback_data="help"
),
InlineKeyboardButton("\u2139\uFE0F ʜᴇʟᴘ", callback_data="help"),
]
]
),
Expand Down
4 changes: 1 addition & 3 deletions bot/plugins/commands/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ async def _(client: Client, message: Message):
progress_args=(client, message.chat, msg),
)
if VOICE_CHATS.get(message.chat.id) is None:
await msg.edit(
"\U0001fa84 **__Joining the voice chat...__**"
)
await msg.edit("\U0001fa84 **__Joining the voice chat...__**")
await on_call.join(message.chat.id)
VOICE_CHATS[message.chat.id] = on_call
await sleep(2)
Expand Down
4 changes: 1 addition & 3 deletions bot/tasks/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ async def send_log():
user.id,
"__Master, Master, the log file was flushed successfully.__",
)
print(
f'{colored("[INFO]", "blue")}: LOG FILE WAS FLUSHED SUCCESSFULLY'
)
print(f'{colored("[INFO]", "blue")}: LOG FILE WAS FLUSHED SUCCESSFULLY')

except Exception as e:
await kreacher.send_message(
Expand Down

0 comments on commit 5a9e169

Please sign in to comment.