php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.9k stars 955 forks source link

Main menu icon always on top #451

Closed dzarezenko closed 7 years ago

dzarezenko commented 7 years ago

Hi,

I have implemented few bots already with this lib. But I have a common problem. My bots main menu runs on /start command execution. So users can see main menu on start of using my bots. But menu icon disappeared after some time or when you try to use bot on PC for example. And users should execute /start command again to run the menu. But users don't know about that and as a result don't use menu at all.

How can I keep menu icon always on top?

noplanman commented 7 years ago

What exactly is your main menu? A keyboard message sent via the /start command?

dzarezenko commented 7 years ago

I call on \start something like this:


[
   'chat_id' => $chat_id,
   'text'    => $text,
   'reply_markup' => new Longman\TelegramBot\Entities\Keyboard([
            'keyboard' => [
                [self::BTN_MARKET, self::BTN_BALANCES],
                [self::BTN_RATES, self::BTN_ORDEDS]
            ],
            'resize_keyboard' => true,
            'one_time_keyboard' => false,
            'selective' => false
        ])
];
jacklul commented 7 years ago

There is no way to do this without sending another message that will re-display this menu.

You can use @BotFather /setcommands and add an entry with your command and label it as main menu item.

If you want a menu that doesn't vanish take a look at inline keyboards, they are essentialy better and nicer, not to mention whole menu and submenus can be contained within one message.

dzarezenko commented 7 years ago

Ok, maybe you know, what is the best way to keep menu on top for users that don't know about menu. So, they don't know about /start command for example and I want they use menu?

jacklul commented 7 years ago

Most people will try writing /help or anything in chat, you might force the menu while replying to messages like this. Not really any other ideas, sorry.

MBoretto commented 7 years ago

In my opinion permanent keyboard are an anti pattern in bot developing. Use commands and inline keyboards