Skip to content

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 30, 2022

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:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from itspranavajay July 30, 2022 16:00
Comment on lines -38 to +39
kuki = kukidb["KukiDb"]["Kuki"]

kuki = kukidb["KukiDb"]["Kuki"]
Copy link
Author

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:

kuki = kukidb["KukiDb"]["Kuki"]

kuki = kukidb["KukiDb"]["Kuki"]
Copy link
Author

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:

Comment on lines -94 to +113
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")
Copy link
Author

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:

Comment on lines -133 to +127
if not message.text:
msg = "/"
else:
msg = message.text
msg = message.text or "/"
Copy link
Author

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:

Comment on lines -154 to +150
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 "/"
)

Copy link
Author

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:

Comment on lines -179 to +183
[[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)

Copy link
Author

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:

Comment on lines -200 to +211
[[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)

Copy link
Author

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:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jul 30, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.20%.

Quality metrics Before After Change
Complexity 5.28 ⭐ 4.27 ⭐ -1.01 👍
Method Length 102.20 🙂 99.90 🙂 -2.30 👍
Working memory 7.88 🙂 8.53 🙂 0.65 👎
Quality 65.05% 🙂 65.25% 🙂 0.20% 👍
Other metrics Before After Change
Lines 182 189 7
Changed files Quality Before Quality After Quality Change
main.py 65.05% 🙂 65.25% 🙂 0.20% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
main.py kukiai 10 🙂 176 😞 11 😞 48.78% 😞 Try splitting into smaller methods. Extract out complex expressions
main.py addchat 5 ⭐ 143 😞 11 😞 56.82% 🙂 Try splitting into smaller methods. Extract out complex expressions
main.py start 2 ⭐ 123 😞 10 😞 64.01% 🙂 Try splitting into smaller methods. Extract out complex expressions
main.py kukiai 2 ⭐ 122 😞 9 🙂 66.20% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants