Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callbackButton doesn't emit "calback_query" in keyboard #73

Closed
empas opened this issue Feb 21, 2017 · 2 comments
Closed

callbackButton doesn't emit "calback_query" in keyboard #73

empas opened this issue Feb 21, 2017 · 2 comments
Labels

Comments

@empas
Copy link

empas commented Feb 21, 2017

I'm trying to make simple interactive keyboard and want to make button which will remove keyboard.

import config from './config';
import Telegraf from 'telegraf';
import { Extra, Markup } from 'telegraf';

const app = new Telegraf(config.token);
const registerMarkup = Extra
    .markup((m) => m
        .resize()
        .keyboard([
            m.contactRequestButton('Зарегистрировать номер'),
            m.callbackButton('Отмена', 'removeKb')
        ])
    );
const cancelMarkup = Extra.markup((m) => m.removeKeyboard());

app.command('register', (ctx) => {
    ctx.reply('Необходимо зарегистрировать номер телефона', registerMarkup);
});
app.on('callback_query', (ctx) => {
    console.log('callbackQuery');
    console.log(ctx.callbackQuery);
});

app.startPolling();

In this case "callbackButton" doesn't emit anything except simple message like "button". But if I try inlineKeyboard it works.

@dotcypress
Copy link
Member

dotcypress commented Feb 21, 2017

Hey @empas

Actually callbackButton works only with inlineKeyboard, use plain button instead.

import config from './config';
import Telegraf from 'telegraf';
import { Extra, Markup } from 'telegraf';

const app = new Telegraf(config.token);
const registerMarkup = Extra
    .markup((m) => m
        .resize()
        .keyboard([
            m.contactRequestButton('Зарегистрировать номер'),
            m.button('Отмена')
        ])
    );

const cancelMarkup = Extra.markup((m) => m.removeKeyboard());

app.command('register', (ctx) => {
    ctx.reply('Необходимо зарегистрировать номер телефона', registerMarkup);
});

app.hears('Отмена', (ctx) => {
    ctx.reply('Ну нет так нет', cancelMarkup);
});

app.on('callback_query', (ctx) => {
    console.log('callbackQuery');
    console.log(ctx.callbackQuery);
});

app.startPolling();

@empas
Copy link
Author

empas commented Feb 22, 2017

@dotcypress thank you for answer) This is exactly how I use it now.

@empas empas closed this as completed Feb 22, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants