Skip to content

Added a function to make bot send a message when mentioned - #15

Open
pistonpro0001 wants to merge 10 commits into
masterfrom
bot-reply
Open

Added a function to make bot send a message when mentioned#15
pistonpro0001 wants to merge 10 commits into
masterfrom
bot-reply

Conversation

@pistonpro0001

Copy link
Copy Markdown
Owner

Used the bot.event decorator to allow bot to respond to replies and mentions, only when it isn't the bot itself. Also removed unneeded function get_or_create... because the game I made to test isn't implemented anymore.

Closes: #14

Used the `bot.event` decorator to allow bot to respond to replies and
mentions, only when it isn't the bot itself. Also removed unneeded
function `get_or_create...` because the game I made to test isn't
implemented anymore.

Closes: #14
@pistonpro0001
pistonpro0001 requested a review from roli2py August 14, 2026 23:36
@pistonpro0001 pistonpro0001 added the enhancement New feature or request label Aug 14, 2026

@roli2py roli2py left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I can't understand a purpose of this functionality, because, for now, it replies with a static text. For now, it seems as an overwhelm.

Comment thread main.py Outdated
Comment thread main.py Outdated
@bot.event
async def on_message(message):
if message.author == bot.user:
return

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By PEP 8, it's a bad practice to do the implicit return of None, but, for now, we don't have an established style guidelines, so I'll keep the decision to the author.

Our main goal is to establish the style guidelines and then we can continue to make new changes and review PRs.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know!

@roli2py roli2py Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still implicit return of None

Repository owner deleted a comment from pistonpro0001 Aug 15, 2026
pistonpro0001 and others added 6 commits August 15, 2026 15:31
Co-authored-by: Roman <romanmashevskyi@proton.me>
roli2py suggested that I comment how the parts of the bot reply function
work, so I added comments in the `on_message` function to clarify what
each part of the function does.
Place the run to mitigate the problems when the tools are invoking the
main module to inspect dependencies or get a `version` variable.
Add the guidelines to mitigate typical mistakes when making changes to
the code and resolve the problems on this basis more easily.
@roli2py
roli2py self-requested a review August 17, 2026 06:31

@roli2py roli2py left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can skip the hast table, if you want. Fix the other problem and feel free to merge it.

Comment thread devbot.py
Comment on lines +37 to +43
if message.reference: # Is the message a refrence to anyone (reply or mention)?
if message.reference.cached_message: # Does the bot already has the original message saved in its memory?
is_reply_to_bot = message.reference.cached_message.author == bot.user # Check if the message it replied to was from the bot
else:
try:
original_msg = await message.channel.fetch_message(message.reference.message_id) # Get the original message replied to
is_reply_to_bot = original_msg.author == bot.user # Check if the message it replied to was from the bot

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are so concrete and describing each line. In this case, the variables and methods are self-describable. It's better to comment what and why solves this logic and not how.

Comment thread main.py Outdated
pass

if was_mentioned or is_reply_to_bot:
await message.reply("beep boop this is my impression of a non-commital robot") # Reply to the message with a funny comment ig

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary comment. Also, as I suggested in #14, we can create a hash table with the answers and pick a random one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Bot respond to replies and mentions from user

3 participants