-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored DOGE-TR branch #6
base: DOGE-TR
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sourcery timed out performing refactorings.
Due to GitHub API limits, only the first 60 comments can be shown.
sample_config.py
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 59-59
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
if not self.jsobj: | ||
return None | ||
return self.jsobj | ||
return None if not self.jsobj else self.jsobj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Main.parse_storage.TheHTMLParser.result
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
)
opt_file = self.options.file | ||
if opt_file: | ||
if opt_file := self.options.file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Main.create_file_name
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
__copyright__ = "©️ Copyright 2021, " + __author__ | ||
__copyright__ = f"©️ Copyright 2021, {__author__}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 24-72
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace if statement with if expression (
assign-if-exp
)
userbot/__main__.py
Outdated
LOGS.info(userbot.__license__ + " ile korunmaktadır.") | ||
LOGS.info(f'{userbot.__license__} ile korunmaktadır.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function startup_process
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
doginput = "Inline buttons " + markdown_note | ||
doginput = f"Inline buttons {markdown_note}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function button
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
event, f"**📺 Geçerli bir YouTube URL'sine girin veya cevap verin!**" | ||
event, "**📺 Geçerli bir YouTube URL'sine girin veya cevap verin!**" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function yt_inline
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
await c_q.answer(f"➡️ Görünüm olarak şu değiştirildi: 📜 Liste", alert=False) | ||
await c_q.answer("➡️ Görünüm olarak şu değiştirildi: 📜 Liste", alert=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function ytdl_callback
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
if reply_message.media: | ||
media = await reply_message.download_media() | ||
if reply_message.text: | ||
await doge.bot.send_file(chat, media, caption=reply_message.text) | ||
else: | ||
await doge.bot.send_file(chat, media) | ||
return await event.delete() | ||
|
||
else: | ||
if not reply_message.media: | ||
return await edl( | ||
event, | ||
"__Bot üzerinden ne göndermeliyim? Bana bir metin verin ya da mesajı yanıtlayın.__", | ||
) | ||
|
||
media = await reply_message.download_media() | ||
if reply_message.text: | ||
await doge.bot.send_file(chat, media, caption=reply_message.text) | ||
else: | ||
await doge.bot.send_file(chat, media) | ||
return await event.delete() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function botmsg
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
f"Bu ayarları yapabilmek için bana özelden yazmalısın!", alert=True | ||
"Bu ayarları yapabilmek için bana özelden yazmalısın!", alert=True | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function settings
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
f"🐶 Doɢᴇ UsᴇʀBoᴛ\n\n TAG loggerözelliğiniz başarıyla kapatıldı", | ||
"🐶 Doɢᴇ UsᴇʀBoᴛ\\n\\n TAG loggerözelliğiniz başarıyla kapatıldı", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TAG_LOGGER_OFF
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
f"🐶 Doɢᴇ UsᴇʀBoᴛ\n\n TAG Logger özelliğiniz zaten açık!", alert=True | ||
"🐶 Doɢᴇ UsᴇʀBoᴛ\\n\\n TAG Logger özelliğiniz zaten açık!", | ||
alert=True, | ||
) | ||
|
||
elif gvar("PM_LOGGER_GROUP_ID") is None and gvar("TAG_LOGGER_GROUP_ID") is None: | ||
await event.answer( | ||
f"🐶 Doɢᴇ UsᴇʀBoᴛ\n\n TAG Logger özelliğini açmak için öncelikle bir grup ayarlamanız gerekir. Sizi grup ayarlama ekranına yönlendiriyorum..." | ||
"🐶 Doɢᴇ UsᴇʀBoᴛ\\n\\n TAG Logger özelliğini açmak için öncelikle bir grup ayarlamanız gerekir. Sizi grup ayarlama ekranına yönlendiriyorum..." | ||
) | ||
|
||
await event.edit( | ||
f"""🔔 **Etiketleri kaydetme grubunuzun Doge UserBot tarafından oluşturulmasını istiyorsanız** "`🕹 Otomatik`", **kendiniz ayarlamak istiyorsanız** "`🥏 Manüel`" **yazan butona tıklayın.**""", | ||
"""🔔 **Etiketleri kaydetme grubunuzun Doge UserBot tarafından oluşturulmasını istiyorsanız** "`🕹 Otomatik`", **kendiniz ayarlamak istiyorsanız** "`🥏 Manüel`" **yazan butona tıklayın.**""", | ||
buttons=buttons, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TAG_LOGGER_ON
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
int(gvar("TAG_LOGGER_GROUP_ID")), f"Tag Logger Grubu Test Mesajı!" | ||
int(gvar("TAG_LOGGER_GROUP_ID")), | ||
"Tag Logger Grubu Test Mesajı!", | ||
) | ||
|
||
await a.delete() | ||
return await event.edit( | ||
f"Tag Logger için zaten kayıtlı bir grubunuz var! Grup oluşturma işlemini iptal ediyorum", | ||
"Tag Logger için zaten kayıtlı bir grubunuz var! Grup oluşturma işlemini iptal ediyorum", | ||
buttons=get_back_button("TAG_LOGGER_GROUP"), | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TAG_LOGGER_GROUP_AUTO
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
f"🐶 Doɢᴇ UsᴇʀBoᴛ\n\ PM Permit özelliğiniz başarıyla kapatıldı", | ||
"🐶 Doɢᴇ UsᴇʀBoᴛ\\n\\ PM Permit özelliğiniz başarıyla kapatıldı", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PM_LOGGER_OFF
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
f"🐶 Doɢᴇ UsᴇʀBoᴛ\n\n PM Logger özelliğiniz zaten açık!", alert=True | ||
"🐶 Doɢᴇ UsᴇʀBoᴛ\\n\\n PM Logger özelliğiniz zaten açık!", | ||
alert=True, | ||
) | ||
|
||
elif gvar("PM_LOGGER_GROUP_ID") is not None and gvar("pmpermit") != "True": | ||
sgvar("pmpermit", True) | ||
return await event.answer("🐶 PM LOGGER değeriniz açıldı!", alert=True) | ||
elif gvar("PM_LOGGER_GROUP_ID") is None: | ||
await event.answer( | ||
f"🐶 Doɢᴇ UsᴇʀBoᴛ\n\n PM Logger özelliğini açmak için öncelikle bir grup ayarlamanız gerekir. Sizi grup ayarlama ekranına yönlendiriyorum..." | ||
"🐶 Doɢᴇ UsᴇʀBoᴛ\\n\\n PM Logger özelliğini açmak için öncelikle bir grup ayarlamanız gerekir. Sizi grup ayarlama ekranına yönlendiriyorum..." | ||
) | ||
|
||
await event.edit( | ||
f"""💬 **PM için log grubunuzun Doge UserBot tarafından oluşturulmasını istiyorsanız** "`🕹 Otomatik`", **kendiniz ayarlamak istiyorsanız** "`🥏 Manüel`" **yazan butona tıklayın.**""", | ||
"""💬 **PM için log grubunuzun Doge UserBot tarafından oluşturulmasını istiyorsanız** "`🕹 Otomatik`", **kendiniz ayarlamak istiyorsanız** "`🥏 Manüel`" **yazan butona tıklayın.**""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PM_LOGGER_ON
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
descript = f"🚧 BU KANALI SİLMEYİN!\n\ | ||
\n🗑 Eğer bu kanalı silerseniz,\ | ||
\n🐾 Kaydederek iletme özelliği çalışmayacaktır.\n\ | ||
\n🧡 @DogeUserBot" | ||
descript = "🚧 BU KANALI SİLMEYİN!\\n\\\x1f \\n🗑 Eğer bu kanalı silerseniz,\\\x1f \\n🐾 Kaydederek iletme özelliği çalışmayacaktır.\\n\\\x1f \\n🧡 @DogeUserBot" | ||
|
||
gphoto = await doge.upload_file(file="userbot/helpers/resources/DogeBotLog.jpg") | ||
await sleep(0.75) | ||
_, channelid = await create_channel("🐾 Doɢᴇ Gɪzʟɪ Kᴀɴᴀʟ", doge, descript, gphoto) | ||
await sleep(0.75) | ||
descmsg = f"**🚧 BU KANALI SİLMEYİN!\ | ||
\n🚧 BU KANALDAN AYRILMAYIN!\ | ||
\n🚧 BU KANALI DEĞİŞTİRMEYİN!**\n\ | ||
\n🗑 Eğer bu kanalı silerseniz,\ | ||
\n🐾 Kaydederek iletme özelliği çalışmayacaktır!\n\ | ||
\n**🧡 @DogeUserBot**" | ||
descmsg = "**🚧 BU KANALI SİLMEYİN!\\\x1f \\n🚧 BU KANALDAN AYRILMAYIN!\\\x1f \\n🚧 BU KANALI DEĞİŞTİRMEYİN!**\\n\\\x1f \\n🗑 Eğer bu kanalı silerseniz,\\\x1f \\n🐾 Kaydederek iletme özelliği çalışmayacaktır!\\n\\\x1f \\n**🧡 @DogeUserBot**" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function privatechannel
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
if (type(rpic.media) == MessageMediaDocument) or ( | ||
type(rpic.media) == MessageMediaPhoto | ||
): | ||
if type(rpic.media) in [ | ||
MessageMediaDocument, | ||
MessageMediaPhoto, | ||
]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function ss
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
text = "**🐶 Doɢᴇ UsᴇʀBoᴛ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" | ||
text += "\n\n" | ||
text = "**🐶 Doɢᴇ UsᴇʀBoᴛ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" + "\n\n" | ||
text += f"**🚨 Hata Raporu:** [{new['error']}]({pastelink})" | ||
text += "\n\n" | ||
link = f"[BURAYA](https://t.me/DogeSup)" | ||
link = "[BURAYA](https://t.me/DogeSup)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function DogeUserBotClient.bot_cmd.decorator.wrapper
refactored with the following changes:
- Replace assignment and augmented assignment with single assignment (
merge-assign-and-aug-assign
) - Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
text = "**🐶 Doɢᴇ Asɪsᴛᴀɴ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" | ||
text += "\n\n" | ||
text = "**🐶 Doɢᴇ Asɪsᴛᴀɴ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" + "\n\n" | ||
text += f"**🚨 Hata Raporu:** [{new['error']}]({pastelink})" | ||
text += "\n\n" | ||
link = f"[BURAYA](https://t.me/DogeSup)" | ||
link = "[BURAYA](https://t.me/DogeSup)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function DogeUserBotClient.shiba_cmd.decorator.wrapper
refactored with the following changes:
- Replace assignment and augmented assignment with single assignment (
merge-assign-and-aug-assign
) - Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
tmp_chelp += f"\n\n**🐾 Aʏᴀʀ:**" | ||
tmp_chelp += "\\n\\n**🐾 Aʏᴀʀ:**" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function _format_about
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
if event.sender_id and ( | ||
event.sender_id == int(gvar("OWNER_ID")) | ||
or event.sender_id in Config.SUDO_USERS | ||
if ( | ||
not event.sender_id | ||
or event.sender_id != int(gvar("OWNER_ID")) | ||
and event.sender_id not in Config.SUDO_USERS | ||
): | ||
try: | ||
await func(event) | ||
except FloodWaitError as e: | ||
await sleep(e.seconds + 5) | ||
except MessageNotModifiedError: | ||
pass | ||
else: | ||
return | ||
try: | ||
await func(event) | ||
except FloodWaitError as e: | ||
await sleep(e.seconds + 5) | ||
except MessageNotModifiedError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function sudo_owner.wrapper
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
text = f"**🚨 Bu komutu kullanabilmek için yönetici olmalıyım!**" | ||
text = "**🚨 Bu komutu kullanabilmek için yönetici olmalıyım!**" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function NewMessage.filter
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
chat_id = int("-100" + str(chatid.channel_id)) | ||
chat_id = int(f"-100{str(chatid.channel_id)}") | ||
elif isinstance(chatid, InputPeerChat): | ||
chat_id = int("-" + str(chatid.chat_id)) | ||
chat_id = int(f"-{str(chatid.chat_id)}") | ||
elif isinstance(chatid, InputPeerUser): | ||
chat_id = int(chatid.user_id) | ||
else: | ||
chat_id = chatid | ||
if str(chat_id) == str(Config.BOTLOG_CHATID): | ||
return await client.editmessage( | ||
entity=entity, | ||
entity=chatid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function edit_message
refactored with the following changes:
- Use previously assigned local variable (
use-assigned-variable
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
userbot/core/inlinebot.py
Outdated
buttons = [ | ||
( | ||
Button.inline( | ||
f"ℹ️️ Bɪʟɢɪ", | ||
data="check", | ||
), | ||
), | ||
( | ||
buttons = [(Button.inline("ℹ️️ Bɪʟɢɪ", data="check"), ), ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function back_menu
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/core/inlinebot.py
Outdated
buttons = [ | ||
( | ||
Button.inline( | ||
f"ℹ️️ Bɪʟɢɪ", | ||
data="check", | ||
), | ||
), | ||
( | ||
buttons = [(Button.inline("ℹ️️ Bɪʟɢɪ", data="check"), ), ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main_menu
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
username = replied_user.user.username | ||
if username: | ||
if username := replied_user.user.username: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function slap
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
horny = f"**Kategori:** " | ||
horny = "**Kategori:** " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function nsfw
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/helpers/progress.py
Outdated
return str(round(size, 2)) + " " + dict_power_n[raised_to_pow] + "B" | ||
return f'{str(round(size, 2))} {dict_power_n[raised_to_pow]}B' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function humanbytes
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
((str(days) + f" gün, ") if days else "") | ||
+ ((str(hours) + f" saat, ") if hours else "") | ||
+ ((str(minutes) + f" dakika, ") if minutes else "") | ||
+ ((str(seconds) + f" saniye, ") if seconds else "") | ||
(f"{str(days)} gün, " if days else "") | ||
+ (f"{str(hours)} saat, " if hours else "") | ||
+ (f"{str(minutes)} dakika, " if minutes else "") | ||
+ (f"{str(seconds)} saniye, " if seconds else "") | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function time_formatter
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
userbot/helpers/progress.py
Outdated
return tmp[:-2] + " önce" | ||
return f'{tmp[:-2]} önce' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function afk_time
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
fcfe7c3
to
72c7d3b
Compare
Signed-off-by: TeleDoge <DogeUserBot@gmail.com>
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.15%.
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! |
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.18%.
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! |
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.18%.
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
DOGE-TR
refactored 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
DOGE-TR
branch, then run:Help us improve this pull request!