Skip to content

Commit

Permalink
Some Code Format Fixes (TeamYukki#82)
Browse files Browse the repository at this point in the history
* Add Workflows

* PyLint:Auto Fixes

Co-authored-by: NotReallyShikhar <[email protected]>
  • Loading branch information
Pranav-Saraswat and NotReallyShikhar authored Feb 18, 2022
1 parent 4c2fcc1 commit 03845a6
Show file tree
Hide file tree
Showing 66 changed files with 727 additions and 963 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PyLint

on: [push, pull_request]

jobs:
PEP8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: Install Python lint libraries
run: |
pip install autopep8 autoflake isort black
- name: Check for showstoppers
run: |
autopep8 --verbose --in-place --recursive --aggressive --aggressive --ignore=W605. *.py
- name: Remove unused imports and variables
run: |
autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports .
- name: lint with isort and black
run: |
isort .
black .
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'PyLint:Auto Fixes'
commit_options: '--no-verify'
repository: .
commit_user_name: NotReallyShikhar
commit_user_email: [email protected]
commit_author: NotReallyShikhar <[email protected]>
13 changes: 11 additions & 2 deletions Yukki/Core/Clients/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
from pyrogram import Client

from config import (API_HASH, API_ID, BOT_TOKEN, LOG_SESSION, STRING1, STRING2,
STRING3, STRING4, STRING5)
from config import (
API_HASH,
API_ID,
BOT_TOKEN,
LOG_SESSION,
STRING1,
STRING2,
STRING3,
STRING4,
STRING5,
)

app = Client(
"YukkiMusicBot",
Expand Down
4 changes: 2 additions & 2 deletions Yukki/Core/PyTgCalls/Downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def my_hook(d):
mystic.edit(
f"**{MUSIC_BOT_NAME} Downloader**\n\n**Title:** {title[:50]}:\n**FileSize:** {size}\n\n**<u>Downloaded:</u>**\n**Speed:** {speed}\n**ETA:** {eta} Seconds\n\n\n{percentage} ▓▓▓▓▓▓▓▓▓▓▓▓ 100%"
)
except Exception as e:
except Exception:
pass
if per > 250:
if flex[str(bytesx)] == 2:
Expand All @@ -66,7 +66,7 @@ def my_hook(d):
if d["status"] == "finished":
try:
taken = d["_elapsed_str"]
except Exception as e:
except Exception:
taken = "00:00"
size = d["_total_bytes_str"]
mystic.edit(
Expand Down
6 changes: 2 additions & 4 deletions Yukki/Core/PyTgCalls/Tgdownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pyrogram.errors.exceptions import FloodWait

from Yukki import MUSIC_BOT_NAME, app, db_mem
from Yukki import MUSIC_BOT_NAME, app
from Yukki.Utilities.formatters import bytes
from Yukki.Utilities.ping import get_readable_time

Expand Down Expand Up @@ -43,9 +43,7 @@ async def progress(current, total):
await mystic.edit(text)
except FloodWait as e:
await asyncio.sleep(e.x)
left_time[message.message_id] = datetime.now() + timedelta(
seconds=5
)
left_time[message.message_id] = datetime.now() + timedelta(seconds=5)

speed_counter[message.message_id] = time.time()
left_time[message.message_id] = datetime.now()
Expand Down
55 changes: 26 additions & 29 deletions Yukki/Core/PyTgCalls/Yukki.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
import asyncio
import os
import time
from asyncio import QueueEmpty

from pyrogram.errors import FloodWait, MessageNotModified
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
InlineKeyboardMarkup, KeyboardButton, Message,
ReplyKeyboardMarkup, ReplyKeyboardRemove)
from pyrogram.types import InlineKeyboardMarkup
from pytgcalls import PyTgCalls, StreamType
from pytgcalls.types import Update
from pytgcalls.types.input_stream import (AudioVideoPiped, InputAudioStream,
InputStream)
from pytgcalls.types.input_stream.quality import (HighQualityAudio,
HighQualityVideo,
LowQualityVideo,
MediumQualityVideo)
from pytgcalls.types.stream import StreamAudioEnded, StreamVideoEnded

from config import STRING1, STRING2, STRING3, STRING4, STRING5, get_queue
from Yukki import (ASS_CLI_1, ASS_CLI_2, ASS_CLI_3, ASS_CLI_4, ASS_CLI_5,
MUSIC_BOT_NAME, app, db_mem)
from pytgcalls.types.input_stream import AudioVideoPiped, InputAudioStream, InputStream
from pytgcalls.types.input_stream.quality import (
HighQualityAudio,
HighQualityVideo,
LowQualityVideo,
MediumQualityVideo,
)
from pytgcalls.types.stream import StreamAudioEnded

from config import get_queue
from Yukki import (
ASS_CLI_1,
ASS_CLI_2,
ASS_CLI_3,
ASS_CLI_4,
ASS_CLI_5,
MUSIC_BOT_NAME,
app,
db_mem,
)
from Yukki.Core.PyTgCalls import Queues
from Yukki.Core.PyTgCalls.Converter import convert
from Yukki.Core.PyTgCalls.Downloader import download
from Yukki.Database import (get_assistant, remove_active_chat,
remove_active_video_chat)
from Yukki.Inline import (audio_markup, audio_timer_markup_start,
primary_markup, secondary_markup2, timer_markup)
from Yukki.Database import get_assistant, remove_active_chat, remove_active_video_chat
from Yukki.Inline import audio_markup, primary_markup, secondary_markup2
from Yukki.Utilities.changers import time_to_seconds
from Yukki.Utilities.chat import specialfont_to_normal
from Yukki.Utilities.theme import check_theme
Expand Down Expand Up @@ -585,9 +588,7 @@ async def playout_end(pytgclients, chat_id):
try:
await pytgclients.change_stream(
chat_id,
AudioVideoPiped(
ytlink, HighQualityAudio(), stream_quality
),
AudioVideoPiped(ytlink, HighQualityAudio(), stream_quality),
)
except:
return await app.send_message(
Expand Down Expand Up @@ -654,12 +655,8 @@ async def playout_end(pytgclients, chat_id):
c_title = db_mem[afk]["chat_title"]
user_id = db_mem[afk]["user_id"]
chat_title = await specialfont_to_normal(c_title)
thumb = await gen_thumb(
thumbnail, title, user_id, theme, chat_title
)
buttons = primary_markup(
afk, user_id, duration_min, duration_min
)
thumb = await gen_thumb(thumbnail, title, user_id, theme, chat_title)
buttons = primary_markup(afk, user_id, duration_min, duration_min)
await mystic.delete()
mention = db_mem[afk]["username"]
finaltext = await app.send_photo(
Expand Down
57 changes: 39 additions & 18 deletions Yukki/Database/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
from .assistant import (_get_assistant, get_as_names, get_assistant,
save_assistant)
from .auth import (_get_authusers, add_nonadmin_chat, delete_authuser,
get_authuser, get_authuser_count, get_authuser_names,
is_nonadmin_chat, remove_nonadmin_chat, save_authuser)
from .assistant import _get_assistant, get_as_names, get_assistant, save_assistant
from .auth import (
_get_authusers,
add_nonadmin_chat,
delete_authuser,
get_authuser,
get_authuser_count,
get_authuser_names,
is_nonadmin_chat,
remove_nonadmin_chat,
save_authuser,
)
from .blacklistchat import blacklist_chat, blacklisted_chats, whitelist_chat
from .chats import (add_served_chat, get_served_chats, is_served_chat,
remove_served_chat)
from .gban import (add_gban_user, get_gbans_count, is_gbanned_user,
remove_gban_user)
from .chats import add_served_chat, get_served_chats, is_served_chat, remove_served_chat
from .gban import add_gban_user, get_gbans_count, is_gbanned_user, remove_gban_user
from .onoff import add_off, add_on, is_on_off
from .playlist import (_get_playlists, delete_playlist, get_playlist,
get_playlist_names, save_playlist)
from .pmpermit import (approve_pmpermit, disapprove_pmpermit,
is_pmpermit_approved)
from .queue import (add_active_chat, get_active_chats, is_active_chat,
is_music_playing, music_off, music_on, remove_active_chat)
from .playlist import (
_get_playlists,
delete_playlist,
get_playlist,
get_playlist_names,
save_playlist,
)
from .pmpermit import approve_pmpermit, disapprove_pmpermit, is_pmpermit_approved
from .queue import (
add_active_chat,
get_active_chats,
is_active_chat,
is_music_playing,
music_off,
music_on,
remove_active_chat,
)
from .start import _get_start, get_start, get_start_names, save_start
from .sudo import add_sudo, get_sudoers, remove_sudo
from .theme import _get_theme, get_theme, save_theme
from .videocalls import (add_active_video_chat, get_active_video_chats,
get_video_limit, is_active_video_chat,
remove_active_video_chat, set_video_limit)
from .videocalls import (
add_active_video_chat,
get_active_video_chats,
get_video_limit,
is_active_video_chat,
remove_active_video_chat,
set_video_limit,
)
6 changes: 1 addition & 5 deletions Yukki/Database/blacklistchat.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from typing import Dict, List, Union

from Yukki import db

blacklist_chatdb = db.blacklistChat


async def blacklisted_chats() -> list:
chats = blacklist_chatdb.find({"chat_id": {"$lt": 0}})
return [
chat["chat_id"] for chat in await chats.to_list(length=1000000000)
]
return [chat["chat_id"] for chat in await chats.to_list(length=1000000000)]


async def blacklist_chat(chat_id: int) -> bool:
Expand Down
2 changes: 0 additions & 2 deletions Yukki/Database/chats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

from Yukki import db

chatsdb = db.chats
Expand Down
2 changes: 0 additions & 2 deletions Yukki/Database/gban.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

from Yukki import db

gbansdb = db.gban
Expand Down
2 changes: 0 additions & 2 deletions Yukki/Database/onoff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

from Yukki import db

onoffdb = db.onoffper
Expand Down
8 changes: 2 additions & 6 deletions Yukki/Database/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ async def get_playlist_names(chat_id: int, type: str) -> List[str]:
return _notes


async def get_playlist(
chat_id: int, name: str, type: str
) -> Union[bool, dict]:
async def get_playlist(chat_id: int, name: str, type: str) -> Union[bool, dict]:
name = name
_notes = await _get_playlists(chat_id, type)
if name in _notes:
Expand Down Expand Up @@ -73,9 +71,7 @@ async def save_playlist(chat_id: int, name: str, note: dict, type: str):
xd = playlistdb_punjabi
elif type == "Others":
xd = playlistdb_others
await xd.update_one(
{"chat_id": chat_id}, {"$set": {"notes": _notes}}, upsert=True
)
await xd.update_one({"chat_id": chat_id}, {"$set": {"notes": _notes}}, upsert=True)


async def delete_playlist(chat_id: int, name: str, type: str) -> bool:
Expand Down
2 changes: 0 additions & 2 deletions Yukki/Database/pmpermit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

from Yukki import db

pmpermitdb = db.permit
Expand Down
2 changes: 0 additions & 2 deletions Yukki/Database/queue.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

from Yukki import db

pytgdb = db.pytg
Expand Down
2 changes: 0 additions & 2 deletions Yukki/Database/sudo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

from Yukki import db

sudoersdb = db.sudoers
Expand Down
2 changes: 1 addition & 1 deletion Yukki/Database/theme.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Union
from typing import Dict, Union

from Yukki import db

Expand Down
2 changes: 0 additions & 2 deletions Yukki/Database/videocalls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Union

from Yukki import db

videodb = db.yukkivideocalls
Expand Down
19 changes: 4 additions & 15 deletions Yukki/Decorators/admins.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from typing import Dict, List, Union

from Yukki import SUDOERS, app
from Yukki.Database import (_get_authusers, add_nonadmin_chat, delete_authuser,
get_authuser, get_authuser_count,
get_authuser_names, is_nonadmin_chat,
remove_nonadmin_chat, save_authuser)
from Yukki.Database import get_authuser_names, is_nonadmin_chat
from Yukki.Utilities.changers import int_to_alpha


Expand All @@ -16,9 +11,7 @@ async def wrapper(_, message):
)
is_non_admin = await is_nonadmin_chat(message.chat.id)
if not is_non_admin:
member = await app.get_chat_member(
message.chat.id, message.from_user.id
)
member = await app.get_chat_member(message.chat.id, message.from_user.id)
if not member.can_manage_voice_chats:
if message.from_user.id not in SUDOERS:
token = await int_to_alpha(message.from_user.id)
Expand All @@ -38,9 +31,7 @@ async def wrapper(_, message):
return await message.reply_text(
"You're an __Anonymous Admin__!\nRevert back to User Account."
)
member = await app.get_chat_member(
message.chat.id, message.from_user.id
)
member = await app.get_chat_member(message.chat.id, message.from_user.id)
if not member.can_manage_voice_chats:
return await message.reply(
"You don't have the required permission to perform this action.\n\n__REQUIRES ADMIN WITH MANAGE VC RIGHTS__"
Expand All @@ -60,9 +51,7 @@ async def wrapper(_, CallbackQuery):
if not a.can_manage_voice_chats:
if CallbackQuery.from_user.id not in SUDOERS:
token = await int_to_alpha(CallbackQuery.from_user.id)
_check = await get_authuser_names(
CallbackQuery.from_user.id
)
_check = await get_authuser_names(CallbackQuery.from_user.id)
if token not in _check:
return await CallbackQuery.answer(
"You don't have the required permission to perform this action.\nPermission: MANAGE VOICE CHATS",
Expand Down
Loading

0 comments on commit 03845a6

Please sign in to comment.