-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix reply command #148
Fix reply command #148
Conversation
src/spotted/handlers/reply.py
Outdated
@@ -16,7 +16,7 @@ async def reply_cmd(update: Update, context: CallbackContext): | |||
""" | |||
info = EventInfo.from_message(update, context) | |||
|
|||
if len(info.text) <= 7: # the reply is empty | |||
if len(info.text) <= 7 or Config.post_get("channel_tag")[1:] in info.text.lower(): # the reply is empty |
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.
but if I have
/reply@Spotted_DMI_Bot blablabla
this condition will be true but I am using the reply correctly
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.
I think when you use the full-command /reply@Spotted_DMI_Bot answer
it is only because you accidentally click the suggested command of the bot menu. Usually you just use /reply answer
without including @Spotted_DMI_bot
in the command
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.
but it's wrong conceptually that you can't use the full-command
you could change the condition into something like
if len(...) <= SOMETHING:
where SOMETHING is
7
whennot bot_tag in info.text.lower()
7 + len(config bot_tag)
whenbot_tag in info.text.lower()
This small change in the src/spotted/handlers/reply.py file should fix the issue: async def reply_cmd(update: Update, context: CallbackContext):
info = EventInfo.from_message(update, context)
### use the new args property of the info object
if len(info.args) == 0: # the reply is empty
await info.bot.send_message(
chat_id=info.chat_id,
text="La reply è vuota\n"
"Per mandare un messaggio ad un utente, rispondere al suo post o report con /reply "
"seguito da ciò che gli si vuole dire",
)
return
### build the reply text from the args
reply_text = " ".join(info.args)
g_message_id = update.message.reply_to_message.message_id
if (pending_post := PendingPost.from_group(admin_group_id=info.chat_id, g_message_id=g_message_id)) is not None:
await info.bot.send_message(
chat_id=pending_post.user_id,
text=f"COMUNICAZIONE DEGLI ADMIN SUL TUO ULTIMO POST:\n{reply_text}",
)
elif (report := Report.from_group(admin_group_id=info.chat_id, g_message_id=g_message_id)) is not None:
await info.bot.send_message(
chat_id=report.user_id, text=f"COMUNICAZIONE DEGLI ADMIN SUL TUO ULTIMO REPORT:\n{reply_text}"
) It appears that both the command's short and long versions (with the bot tag) behave correctly this way. |
And a smaller thing: don't add this fix in the changelog under version 3.0.0 since that version has already been released and cannot be changed. |
I updated the reply command and removed the previous addition of the entry in the Unfortunately I don't have time to add the tests, sorry. Thanks so much @TendTo for the suggestion 😄 |
Just fix the linting issues (there is an unused import and you accidentally removed the function docstring) and we will be golden. |
Prerequisites
CHANGELOG.rst
file with an overview of the changes made.Description
Fix reply command when it is triggered by bot's menu command
Issue closed by this PR
Does this PR introduce a breaking change?
Python version you are using
Python 3.10.12