Not an issue! Just a question...
Please answer these questions before submitting your issue. Thanks!
-
What version of pyTelegramBotAPI are you using?
4.17.0
-
What OS are you using?
Ubuntu 22.04
-
What version of python are you using?
3.10.12
How would i implement a '/repeat' last command?
Kinda simplified pseudocode example:
previous_message = None
@bot.middleware_handler(update_types=["message"])
def modify_message(bot_instance, message):
global previous_message
d = get_command_elements(message)
if d["command"] != "repeat":
previous_message = message
@bot.message_handler(commands=["repeat"])
def repeat(message):
global previous_message
bot.forward_message(
previous_message.chat.id, message.chat.id, previous_message.message_id
)
# run '/status' command
@bot.message_handler(commands=["status"])
def status_info(message):
global previous_message
previous_message = message
status = get_status()
bot.send_message(message.chat.id, status)

/repeat works, I can just click the forwarded message and it repeats the command
I also have a command that can be run either as '/info' (as a reply to a message) or as '/info item' to query info for 'item'.
send "/info item" as message

#OR: send "/info" as a reply to a message

@bot.message_handler(commands=["info"])
def info(message):
global previous_message
previous_message = message
if 'item' in message.text:
item = extract_item(message.text)
result = run_query(item)
elif message.json["reply_to_message"]["text"]:
item = extract_item(message.json["reply_to_message"]["text"])
result = run_query(item)
bot.send_message(message.chat.id, result)

Does not work, as the forwarded 'command' only hotlinks "/info" not "/info item"
Same goes with the reply-type command...
Not an issue! Just a question...
Please answer these questions before submitting your issue. Thanks!
What version of pyTelegramBotAPI are you using?
4.17.0
What OS are you using?
Ubuntu 22.04
What version of python are you using?
3.10.12
How would i implement a '/repeat' last command?
Kinda simplified pseudocode example:
/repeat works, I can just click the forwarded message and it repeats the command
I also have a command that can be run either as '/info' (as a reply to a message) or as '/info item' to query info for 'item'.
send "/info item" as message
#OR: send "/info" as a reply to a message

Does not work, as the forwarded 'command' only hotlinks "/info" not "/info item"
Same goes with the reply-type command...