EdJoPaTo / grammy-inline-menu

Inline Menus for Telegram made simple. Successor of telegraf-inline-menu.
MIT License
357 stars 44 forks source link

How to use query data in menu text? #86

Closed bitcoinxtwo closed 4 years ago

bitcoinxtwo commented 4 years ago

i have try use manual method in js/nodejs example code is const menu = new TelegrafInlineMenu(text) i want to be the (text also my sql query data) const menu = new TelegrafInlineMenu(ctx => con.query('select * from table where id='+ctx.from.id,function(err,result){ //i want my text also mydata query result in here//or other method please }) )

EdJoPaTo commented 4 years ago

You can use a constant string or a function returning a string.

something like this is what i usually go for:

function menuBody(ctx) {
  const text = 'Create some text for ' + ctx.from.first_name
  return text
}

const menu = new TelegrafInlineMenu(menuBody)
bitcoinxtwo commented 4 years ago

How can i place my query data.

You can use a constant string or a function returning a string.

something like this is what i usually go for:

function menuBody(ctx) {
  const text = 'Create some text for ' + ctx.from.first_name
  return text
}

const menu = new TelegrafInlineMenu(menuBody)
EdJoPaTo commented 4 years ago

You can call whatever function you want to call from the menuBody function of my example. It is completely independent from the menu there.

EdJoPaTo commented 4 years ago

I'll just close this due to inactivity. If you have any questions feel free to ask ahead!