question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why bot suddenly crashed?

See original GitHub issue

This code was working properly one month ago but since last night it was crashing.

(node:3848) UnhandledPromiseRejectionWarning: Error: 400: Bad Request: message is not modified at buildConfig.then.then.then.then (D:\apps\bot\node_modules\telegraf\core\network\client.js:235:17) at at process._tickCallback (internal/process/next_tick.js:118:7) (node:3848) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:3848) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. code :


app.action('start', (ctx) => {
    http.get('http://localhost:3000/api/questions', (res) => {
        //res.setEncoding('utf8');
        let rawData = '';
        res.on('data', (chunk) => {
            rawData += chunk;
        });
        res.on('end', () => {
            try {
                data = JSON.parse(rawData);
                i = Object.keys(data).length;
                ctx.editMessageText('Choose one of the options:', 
                Extra.HTML().markup(m => m.inlineKeyboard([
                    m.callbackButton(data[x].Q1, 'plus1'),
                    m.callbackButton(data[x].Q2, 'plus2')
                ], {
                    columns: 1
                })));
            } catch (e) {
                console.error(e.message);
            }
        });
    }).on('error', (e) => {
        console.error(`Got error: ${e.message}`);
    });
});

app.action('plus1', (ctx) => {
    if (x < i) {
        answer[x] = 1;
        ctx.editMessageText('Choose one of the options:', Extra.HTML().markup(m => m.inlineKeyboard([
            m.callbackButton(data[x].Q1, 'plus1'),
            m.callbackButton(data[x].Q2, 'plus2')
        ], {
            columns: 1
        })));
        x++;
    } else {
        ctx.editMessageText('Finished :', Extra.HTML().markup(m => m.inlineKeyboard([
            m.callbackButton('Result', 'result')
        ])));
    }
});

app.action('plus2', (ctx) => {
    if (x < i) {
        answer[x] = 2;
        ctx.editMessageText('Choose one of the options', Extra.HTML().markup(m => m.inlineKeyboard([
            m.callbackButton(data[x].Q1, 'plus1'),
            m.callbackButton(data[x].Q2, 'plus2')
        ], {
            columns: 1
        })));
        x++;
    } else {
        ctx.editMessageText('Finished :', Extra.HTML().markup(m => m.inlineKeyboard([
            m.callbackButton('Result', 'result')
        ])));
    }});

app.action('result', (ctx) => {
    ctx.reply(answer);
});
app.startPolling();

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13

github_iconTop GitHub Comments

6reactions
tva10commented, Mar 30, 2018

Hello @parsarian Then you use editMessageText and send to user same content which is not diffs to previous edition of that message - Telegram Bot Api returns this error - Error: 400: Bad Request: message is not modified

So and in your app you don’t handle any error In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code You can try to handle this error

ctx.editMessageText( .... ).catch( function(error){ console.error(error); } );

or any other errors in your bot

app.catch(function(err){ console.log(err); });
4reactions
tva10commented, Apr 3, 2018

@parsarian , Nope, sendNextQuestion, receive context as param. data object with questions will be stored as global variable and line sendNextQuestion(ctx); seems incorrect because of ctx is not defined message, and I changed to sendNextQuestion(data); but steel Cannot read property 'x' of undefined message appear.

ctx is not defined message appears because forgot to rename ctx to context at return ctx.editMessageText('Choose one of the options:',... and return ctx.editMessageText('Finished :', lines

Read more comments on GitHub >

github_iconTop Results From Across the Web

Team Fortress 2 Cathook Bots Are Suddenly Crashing ...
Several bots are experiencing issues in Team Fortress 2 following a seemingly small update with lots of hidden changes.
Read more >
why Telegram bot suddenly crashed - Stack Overflow
Telegram has several methods for updating a message. If you call editMessageText but the text itself is not change, this is the response...
Read more >
How to Fix Discord's Crash Issues - Online Tech Tips
Discord's crash issues aren't uncommon, which means you may find the app crashing for no apparent reason from time to time.
Read more >
How to Fix Server Overload & Crashes Due to Bad Bot Traffic
Malicious bots are an overlooked cause of server overload that leads to server instability, poor user experience due to slower loading times, ...
Read more >
Crashed unexpectedly on every startupp : r/discordapp - Reddit
"Looks like Discord has crashed unexpectedly. ... r/discordapp - If i was to build a discord bot , what premium features.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found