How Can Get CallbackData in current when InlineKeyboardCallbackButton clicked in telegram Bot in C# -
how can inlinekeyboardcallbackbutton clicked in telegram bot?
here code : i edited code
public async system.threading.tasks.task<actionresult> getmsgasync() { var req = request.inputstream; var responsstring = new streamreader(req).readtoend(); var update = jsonconvert.deserializeobject<update>(responsstring); var message = update.message; var chat = message.chat; inlinekeyboardmarkup categoryinlinemarkup = new inlinekeyboardmarkup( new inlinekeyboardbutton[][] { new inlinekeyboardbutton[] { new inlinekeyboardcallbackbutton("button1","callbackdata") } } ); await api.sendtextmessageasync(update.message.chat.id, "please click button", replymarkup: categoryinlinemarkup); if (update.type == telegram.bot.types.enums.updatetype.messageupdate) { // codes run in block } if (update.type == telegram.bot.types.enums.updatetype.callbackqueryupdate) { // can't clicked button here if (update.callbackquery.data.contains("callbackdata")) { await api.answercallbackqueryasync(update.callbackquery.id, update.callbackquery.data); } } }
how can button clicked in webhook method, not in console program?
finally find out answer, problem line of code :
var message = update.message;
this line of code main problem because line not in try catch block , can't understand line problem .
after problem, have suggestion you
can debugging telegram bot in personal computer without uploading code on host, purpose can run 3 below steps ::
1- accessing iis express site remote computer
3- after download ngrok can forward telegram webhook requests personal computer .
Comments
Post a Comment