mast / telegram-bot-api

First Telegram Bot API node.js library
http://mast.github.io/telegram-bot-api/
MIT License
246 stars 64 forks source link

TypeError on reply_markup #12

Closed aisqwe closed 8 years ago

aisqwe commented 8 years ago

when trying to send a keyboard in sendMessage this error comes up:

source.on('error', function() {});

TypeError: undefined is not a function at Function.DelayedStream.create

mast commented 8 years ago

this is meaningless without piece of code. Please share your code and console output.

roger2000hk commented 8 years ago

I am trying to use "reply_markup" as below, but failed. I don't quite understand what should I pass to reply_markup

    api.sendMessage({
        chat_id: chat_id,
        reply_markup: {
            ForceReply: {
                force_reply: true
            },
            ReplyKeyboardMarkup: {
                keyboard: [ ["1","2"],["3","4"] ]
            }
        },
        text: message.text ? 'reply to you: '+message.text : 'Your message doesn\'t contain text :('
    }, function(err, data)
    {
        if (err != null) { console.log(err); }
        console.log(data);
    });
TypeError: Object #<Object> has no method 'on'
    at Function.DelayedStream.create (/home/algouser/algo_fix/nodefix/node_modules/telegram-bot-api/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js:33:10)

then I try this as well, but still no use

reply_markup: '{ "ForceReply":{ force_reply: "True" } }',
cincauhangus commented 8 years ago

you will need to serialize values for reply_markup with JSON.stringify()

reply_markup: JSON.stringify({keyboard: [['1','2'],['3','4']]})
roger2000hk commented 8 years ago

great, it worked. Thanks.

mast commented 8 years ago

Closing as no response from originator is provided.