-
Notifications
You must be signed in to change notification settings - Fork 103
Sourcery refactored main branch #2
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
base: main
Are you sure you want to change the base?
Conversation
kuki = kukidb["KukiDb"]["Kuki"] | ||
|
||
kuki = kukidb["KukiDb"]["Kuki"] |
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 addchat
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches (
swap-if-else-branches
)
kuki = kukidb["KukiDb"]["Kuki"] | ||
|
||
kuki = kukidb["KukiDb"]["Kuki"] |
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 rmchat
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches (
swap-if-else-branches
)
kukidb = MongoClient(MONGO_URL) | ||
|
||
kuki = kukidb["KukiDb"]["Kuki"] | ||
|
||
is_kuki = kuki.find_one({"chat_id": message.chat.id}) | ||
if is_kuki: | ||
if message.reply_to_message: | ||
botget = await bot.get_me() | ||
botid = botget.id | ||
if not message.reply_to_message.from_user.id == botid: | ||
return | ||
await bot.send_chat_action(message.chat.id, "typing") | ||
if not message.text: | ||
msg = "/" | ||
else: | ||
msg = message.text | ||
try: | ||
x = requests.get(f"https://kukiapi.xyz/api/apikey={KUKI_API}/message={msg}").json() | ||
x = x['reply'] | ||
await asyncio.sleep(1) | ||
except Exception as e: | ||
error = str(e) | ||
await message.reply_text(x) | ||
await bot.send_message( | ||
ERROR_LOG, f"""{error}""") | ||
await bot.send_chat_action(message.chat.id, "cencel") | ||
kukidb = MongoClient(MONGO_URL) | ||
|
||
kuki = kukidb["KukiDb"]["Kuki"] | ||
|
||
if is_kuki := kuki.find_one({"chat_id": message.chat.id}): | ||
if message.reply_to_message: | ||
botget = await bot.get_me() | ||
botid = botget.id | ||
if message.reply_to_message.from_user.id != botid: | ||
return | ||
await bot.send_chat_action(message.chat.id, "typing") | ||
msg = message.text or "/" | ||
try: | ||
x = requests.get(f"https://kukiapi.xyz/api/apikey={KUKI_API}/message={msg}").json() | ||
x = x['reply'] | ||
await asyncio.sleep(1) | ||
except Exception as e: | ||
error = str(e) | ||
await message.reply_text(x) | ||
await bot.send_message( | ||
ERROR_LOG, f"""{error}""") | ||
await bot.send_chat_action(message.chat.id, "cencel") |
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 kukiai
refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression
) - Simplify if expression by using or (
or-if-exp-identity
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Simplify logical expression using De Morgan identities (
de-morgan
) - Replace if statement with if expression (
assign-if-exp
)
if not message.text: | ||
msg = "/" | ||
else: | ||
msg = message.text | ||
msg = message.text or "/" |
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 kukiai
refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression
) - Simplify if expression by using or (
or-if-exp-identity
) - Replace if statement with if expression (
assign-if-exp
)
if not message.text: | ||
msg = "/" | ||
else: | ||
msg = message.text.replace(message.text.split(" ")[0], "") | ||
msg = ( | ||
message.text.replace(message.text.split(" ")[0], "") | ||
if message.text | ||
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 kukiai
refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression
) - Replace if statement with if expression (
assign-if-exp
)
[[InlineKeyboardButton(text="Click here", | ||
url=f"t.me/kukichatbot?start")]]) | ||
[ | ||
[ | ||
InlineKeyboardButton( | ||
text="Click here", url="t.me/kukichatbot?start" | ||
) | ||
] | ||
] | ||
) | ||
|
||
await message.reply("Contact me in PM", | ||
reply_markup=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 start
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
[[InlineKeyboardButton(text="Click here", | ||
url=f"t.me/kukichatbot?start=help_")]]) | ||
[ | ||
[ | ||
InlineKeyboardButton( | ||
text="Click here", url="t.me/kukichatbot?start=help_" | ||
) | ||
] | ||
] | ||
) | ||
|
||
await message.reply("Contact me in PM", | ||
reply_markup=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 help
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.20%.
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
main
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
main
branch, then run:Help us improve this pull request!