Conversation
| if str(getenv("SUPPORT_CHANNEL")).strip() == "": | ||
| SUPPORT_CHANNEL = None | ||
| else: | ||
| SUPPORT_CHANNEL = str(getenv("SUPPORT_CHANNEL")) | ||
| if str(getenv("SUPPORT_GROUP")).strip() == "": | ||
| SUPPORT_GROUP = None | ||
| else: | ||
| SUPPORT_GROUP = str(getenv("SUPPORT_GROUP")) | ||
|
|
||
|
|
||
| if str(getenv("STRING_SESSION1")).strip() == "": | ||
| STRING1 = str(None) | ||
| else: | ||
| STRING1 = str(getenv("STRING_SESSION1")) | ||
|
|
||
| if str(getenv("STRING_SESSION2")).strip() == "": | ||
| STRING2 = str(None) | ||
| else: | ||
| STRING2 = str(getenv("STRING_SESSION2")) | ||
|
|
||
| if str(getenv("STRING_SESSION3")).strip() == "": | ||
| STRING3 = str(None) | ||
| else: | ||
| STRING3 = str(getenv("STRING_SESSION3")) | ||
|
|
||
| if str(getenv("STRING_SESSION4")).strip() == "": | ||
| STRING4 = str(None) | ||
| else: | ||
| STRING4 = str(getenv("STRING_SESSION4")) | ||
|
|
||
| if str(getenv("STRING_SESSION5")).strip() == "": | ||
| STRING5 = str(None) | ||
| else: | ||
| STRING5 = str(getenv("STRING_SESSION5")) | ||
|
|
||
| if str(getenv("LOG_SESSION")).strip() == "": | ||
| LOG_SESSION = str(None) | ||
| else: | ||
| LOG_SESSION = str(getenv("LOG_SESSION")) | ||
| SUPPORT_CHANNEL = ( | ||
| str(getenv("SUPPORT_CHANNEL")) | ||
| if str(getenv("SUPPORT_CHANNEL")).strip() | ||
| else None | ||
| ) | ||
| SUPPORT_GROUP = ( | ||
| str(getenv("SUPPORT_GROUP")) | ||
| if str(getenv("SUPPORT_GROUP")).strip() | ||
| else None | ||
| ) | ||
| STRING1 = ( | ||
| str(getenv("STRING_SESSION1")) | ||
| if str(getenv("STRING_SESSION1")).strip() | ||
| else str(None) | ||
| ) | ||
| STRING2 = ( | ||
| str(getenv("STRING_SESSION2")) | ||
| if str(getenv("STRING_SESSION2")).strip() | ||
| else str(None) | ||
| ) | ||
| STRING3 = ( | ||
| str(getenv("STRING_SESSION3")) | ||
| if str(getenv("STRING_SESSION3")).strip() | ||
| else str(None) | ||
| ) | ||
| STRING4 = ( | ||
| str(getenv("STRING_SESSION4")) | ||
| if str(getenv("STRING_SESSION4")).strip() | ||
| else str(None) | ||
| ) | ||
| STRING5 = ( | ||
| str(getenv("STRING_SESSION5")) | ||
| if str(getenv("STRING_SESSION5")).strip() | ||
| else str(None) | ||
| ) | ||
| LOG_SESSION = ( | ||
| str(getenv("LOG_SESSION")) | ||
| if str(getenv("LOG_SESSION")).strip() | ||
| else str(None) | ||
| ) |
There was a problem hiding this comment.
Lines 28-66 refactored with the following changes:
- Replaces an empty collection equality with a boolean operation [×8] (
simplify-empty-collection-comparison) - Replace if statement with if expression [×8] (
assign-if-exp) - Swap if/else branches of if expression to remove negation [×8] (
swap-if-expression)
| "[magenta] MissCutie Music Bot Booting...", | ||
| ) as status: | ||
| "[magenta] MissCutie Music Bot Booting...", | ||
| ) as status: |
There was a problem hiding this comment.
Function initiate_bot refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| "[magenta] Finalizing Booting...", | ||
| ) as status: | ||
| "[magenta] Finalizing Booting...", | ||
| ) as status: |
There was a problem hiding this comment.
Function initiate_bot refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting) - Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Replace f-string with no interpolated values with string (
remove-redundant-fstring)
| user = ( | ||
| user.first_name if not user.mention else user.mention | ||
| ) | ||
| user = user.mention or user.first_name |
There was a problem hiding this comment.
Function start_command refactored with the following changes:
- Swap if/else branches of if expression to remove negation [×2] (
swap-if-expression) - Simplify if expression by using or [×2] (
or-if-exp-identity)
| module = mod_match.group(1) | ||
| text = ( | ||
| "{} **{}**:\n".format( | ||
| "Here is the help for", HELPABLE[module].__MODULE__ | ||
| ) | ||
| + HELPABLE[module].__HELP__ | ||
| ) | ||
| module = mod_match[1] | ||
| text = f"Here is the help for **{HELPABLE[module].__MODULE__}**:\n{HELPABLE[module].__HELP__}" |
There was a problem hiding this comment.
Function help_button refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects [×3] (
use-getitem-for-re-match-groups) - Replace call to format with f-string (
use-fstring-for-formatting) - Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting)
| if not _notes: | ||
| return {} | ||
| return _notes["notes"] | ||
| return _notes["notes"] if _notes else {} |
There was a problem hiding this comment.
Function _get_assistant refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| if name in _notes: | ||
| return _notes[name] | ||
| else: | ||
| return False | ||
| return _notes[name] if name in _notes else False |
There was a problem hiding this comment.
Function get_assistant refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| if not user: | ||
| return False | ||
| return True | ||
| return bool(user) |
There was a problem hiding this comment.
Function is_nonadmin_chat refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Simplify boolean if expression (
boolean-if-exp-identity)
| if not _notes: | ||
| return {} | ||
| return _notes["notes"] | ||
| return _notes["notes"] if _notes else {} |
There was a problem hiding this comment.
Function _get_authusers refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| _notes = [] | ||
| for note in await _get_authusers(chat_id): | ||
| _notes.append(note) | ||
| return _notes | ||
| return list(await _get_authusers(chat_id)) |
There was a problem hiding this comment.
Function get_authuser_names refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Replace identity comprehension with call to collection constructor (
identity-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if name in _notes: | ||
| return _notes[name] | ||
| else: | ||
| return False | ||
| return _notes[name] if name in _notes else False |
There was a problem hiding this comment.
Function get_authuser refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| for chat in await chats.to_list(length=1000000000): | ||
| chats_list.append(chat) | ||
| return chats_list | ||
| return list(await chats.to_list(length=1000000000)) if chats else [] |
There was a problem hiding this comment.
Function get_served_chats refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression) - Replace identity comprehension with call to collection constructor (
identity-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if not chat: | ||
| return False | ||
| return True | ||
| return bool(chat) |
There was a problem hiding this comment.
Function is_served_chat refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Simplify boolean if expression (
boolean-if-exp-identity)
| if not user: | ||
| return False | ||
| return True | ||
| return bool(user) |
There was a problem hiding this comment.
Function is_gbanned_user refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Simplify boolean if expression (
boolean-if-exp-identity)
| if not onoff: | ||
| return False | ||
| return True | ||
| return bool(onoff) |
There was a problem hiding this comment.
Function is_on_off refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Simplify boolean if expression (
boolean-if-exp-identity)
| if not sudoers: | ||
| return [] | ||
| return sudoers["sudoers"] | ||
| return sudoers["sudoers"] if sudoers else [] |
There was a problem hiding this comment.
Function get_sudoers refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| if not _notes: | ||
| return {} | ||
| return _notes["notes"] | ||
| return _notes["notes"] if _notes else {} |
There was a problem hiding this comment.
Function _get_theme refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| if name in _notes: | ||
| return _notes[name] | ||
| else: | ||
| return False | ||
| return _notes[name] if name in _notes else False |
There was a problem hiding this comment.
Function get_theme refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| if not limit: | ||
| return "" | ||
| return limit["limit"] | ||
| return limit["limit"] if limit else "" |
There was a problem hiding this comment.
Function get_video_limit refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| if not chats: | ||
| return [] | ||
| chats_list = [] | ||
| for chat in await chats.to_list(length=1000000000): | ||
| chats_list.append(chat) | ||
| return chats_list | ||
| return list(await chats.to_list(length=1000000000)) if chats else [] |
There was a problem hiding this comment.
Function get_active_video_chats refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression) - Replace identity comprehension with call to collection constructor (
identity-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if not chat: | ||
| return False | ||
| return True | ||
| return bool(chat) |
There was a problem hiding this comment.
Function is_active_video_chat refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Simplify boolean if expression (
boolean-if-exp-identity)
| if not member.can_manage_voice_chats: | ||
| if message.from_user.id not in SUDOERS: | ||
| token = await int_to_alpha(message.from_user.id) | ||
| _check = await get_authuser_names(message.chat.id) | ||
| if token not in _check: | ||
| return await message.reply( | ||
| "You don't have the required permission to perform this action.\n\n__REQUIRES ADMIN WITH MANAGE VC RIGHTS__" | ||
| ) | ||
| if ( | ||
| not member.can_manage_voice_chats | ||
| and message.from_user.id not in SUDOERS | ||
| ): | ||
| token = await int_to_alpha(message.from_user.id) | ||
| _check = await get_authuser_names(message.chat.id) | ||
| if token not in _check: | ||
| return await message.reply( | ||
| "You don't have the required permission to perform this action.\n\n__REQUIRES ADMIN WITH MANAGE VC RIGHTS__" | ||
| ) |
There was a problem hiding this comment.
Function AdminRightsCheck refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs)
| if not member.can_manage_voice_chats: | ||
| return await message.reply( | ||
| return ( | ||
| await mystic(_, message) | ||
| if member.can_manage_voice_chats | ||
| else await message.reply( | ||
| "You don't have the required permission to perform this action.\n\n__REQUIRES ADMIN WITH MANAGE VC RIGHTS__" | ||
| ) | ||
| return await mystic(_, message) | ||
| ) |
There was a problem hiding this comment.
Function AdminActual refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| 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 | ||
| if ( | ||
| not a.can_manage_voice_chats | ||
| and 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 | ||
| ) | ||
| if token not in _check: | ||
| return await CallbackQuery.answer( | ||
| "You don't have the required permission to perform this action.\nPermission: MANAGE VOICE CHATS", | ||
| show_alert=True, | ||
| ) | ||
| if token not in _check: | ||
| return await CallbackQuery.answer( | ||
| "You don't have the required permission to perform this action.\nPermission: MANAGE VOICE CHATS", | ||
| show_alert=True, | ||
| ) |
There was a problem hiding this comment.
Function AdminRightsCheckCB refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs)
| if not a.can_manage_voice_chats: | ||
| return await CallbackQuery.answer( | ||
| return ( | ||
| await mystic(_, CallbackQuery) | ||
| if a.can_manage_voice_chats | ||
| else await CallbackQuery.answer( | ||
| "You don't have the required permission to perform this action.\nPermission: MANAGE VOICE CHATS", | ||
| show_alert=True, | ||
| ) | ||
| return await mystic(_, CallbackQuery) | ||
| ) |
There was a problem hiding this comment.
Function ActualAdminCB refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| buttons = [ | ||
| return [ | ||
| [ | ||
| InlineKeyboardButton(text="▶️", callback_data=f"resumecb"), | ||
| InlineKeyboardButton(text="⏸️", callback_data=f"pausecb"), | ||
| InlineKeyboardButton(text="⏭️", callback_data=f"skipcb"), | ||
| InlineKeyboardButton(text="⏹️", callback_data=f"stopcb"), | ||
| InlineKeyboardButton(text="▶️", callback_data="resumecb"), | ||
| InlineKeyboardButton(text="⏸️", callback_data="pausecb"), | ||
| InlineKeyboardButton(text="⏭️", callback_data="skipcb"), | ||
| InlineKeyboardButton(text="⏹️", callback_data="stopcb"), | ||
| ], | ||
| [ | ||
| InlineKeyboardButton( | ||
| text="🔗 More Menu", callback_data=f"other {videoid}|{user_id}" | ||
| ), | ||
| InlineKeyboardButton(text="🗑 Close Menu", callback_data=f"close"), | ||
| InlineKeyboardButton(text="🗑 Close Menu", callback_data="close"), | ||
| ], | ||
| ] | ||
| return buttons |
There was a problem hiding this comment.
Function secondary_markup refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Replace f-string with no interpolated values with string [×5] (
remove-redundant-fstring)
| buttons = [ | ||
| return [ | ||
| [ | ||
| InlineKeyboardButton(text="▶️", callback_data=f"resumecb"), | ||
| InlineKeyboardButton(text="⏸️", callback_data=f"pausecb"), | ||
| InlineKeyboardButton(text="⏭️", callback_data=f"skipcb"), | ||
| InlineKeyboardButton(text="⏹️", callback_data=f"stopcb"), | ||
| ], | ||
| [ | ||
| InlineKeyboardButton(text="🗑 Close Menu", callback_data=f"close"), | ||
| InlineKeyboardButton(text="▶️", callback_data="resumecb"), | ||
| InlineKeyboardButton(text="⏸️", callback_data="pausecb"), | ||
| InlineKeyboardButton(text="⏭️", callback_data="skipcb"), | ||
| InlineKeyboardButton(text="⏹️", callback_data="stopcb"), | ||
| ], | ||
| [InlineKeyboardButton(text="🗑 Close Menu", callback_data="close")], | ||
| ] | ||
| return buttons |
There was a problem hiding this comment.
Function secondary_markup2 refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Replace f-string with no interpolated values with string [×5] (
remove-redundant-fstring)
| buttons = [ | ||
| return [ |
There was a problem hiding this comment.
Function primary_markup refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Replace f-string with no interpolated values with string [×5] (
remove-redundant-fstring)
| buttons = [ | ||
| return [ |
There was a problem hiding this comment.
Function timer_markup refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Replace f-string with no interpolated values with string [×5] (
remove-redundant-fstring)
| buttons = [ | ||
| return [ |
There was a problem hiding this comment.
Function audio_markup refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Replace f-string with no interpolated values with string [×5] (
remove-redundant-fstring)
Sourcery Code Quality ReportMerging this PR leaves code quality unchanged.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!