Core: Append parameters to command, like "/edit_22456"

Created on 30 Apr 2017  路  4Comments  路  Source: php-telegram-bot/core

I want to list some records for the user and add a quick link to do some action on any of them. Something like:

Subject: Hello
ID: 85
Remove link: /remove_85

which when the /remove_85 is tapped, bot would remove that record having ID=85.
How to do it?

Most helpful comment

Thats for group IDs, they are negative numbers so they are in format '-314234', and because the command line cant look like this: '/whois-314234' (it wouldn't be clickable) we replaced - with g and in the command we check if it exists on that string position and restore the - when needed!

All 4 comments

Have a look at the WhoisCommand and the example GenericCommand.

You should be able to see how they work, otherwise just ask again.

Thanks @noplanman that was exactly what I'm looking for.
GenericCommand.php was pretty clear.
But in the WhoisCommand on line 77, 78 and 79 there is a part of code that I couldn't find out what it is doing.

if (strpos($text, 'g') === 0) {
    $text = str_replace('g', '-', $text);
}

Could you please explain it to me?

Thats for group IDs, they are negative numbers so they are in format '-314234', and because the command line cant look like this: '/whois-314234' (it wouldn't be clickable) we replaced - with g and in the command we check if it exists on that string position and restore the - when needed!

Thank you @jacklul that was very helpful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abbe-cipher picture abbe-cipher  路  4Comments

NabiKAZ picture NabiKAZ  路  4Comments

TheSleepySlee picture TheSleepySlee  路  3Comments

tchibomann picture tchibomann  路  3Comments

sineverba picture sineverba  路  3Comments