techlift-tech / TelegramBotForPokerAnalysis

0 stars 0 forks source link

Register commands with Telegram if its not already registered. #7 #10

Open palashjhabak opened 3 years ago

palashjhabak commented 3 years ago

when service starts and we find that some commands are not yet registered we should register it

7

have this and #9 in a separate feature branch and start a pull request when you are done @disha-2401

disha-2401 commented 3 years ago

I can't understand the SetMyCommandsAsync method can you show me one example, I'll try to register if not registered already.

palashjhabak commented 3 years ago

@disha-2401 I just did a public search on github and got following example usages,

https://github.com/djohsson/Lastgram/blob/5e998265b01382e924b559034d19ae65d0a1f0b6/Lastgram/Bot.cs

I think its is pretty straightforward, try if its working.

It basically takes List as input

disha-2401 commented 3 years ago

we can set command using this code

IEnumerable<BotCommand> commandsToBeSet = new BotCommand[]
            {
                new BotCommand{Command="week_profit",Description="get weekly profit"},
                new BotCommand{Command="todays_profit",Description="get today's profit"},
                new BotCommand{Command="remaining_limit",Description="get remaining limit"},
                new BotCommand{Command="set_limit",Description="set limit of a user"},
            };
            botClient.SetMyCommandsAsync(commandsToBeSet);

as I mentioned earlier we can not use the pascal case in command naming. so we can use underscore instead

disha-2401 commented 3 years ago

the SetMyCommandsAsync() method does not append commands in existing commands, it only updates the commands list. so whenever we call SetMyCommandsAsync() method we need to give a full list of BotCommands as a parameter.

palashjhabak commented 3 years ago

the SetMyCommandsAsync() method does not append commands in existing commands, it only updates the commands list. so whenever we call SetMyCommandsAsync() method we need to give a full list of BotCommands as a parameter.

ohh ok. Still works for us.