मैं एक टेलीग्राम बॉट स्थापित करने की कोशिश कर रहा हूँ। मैंने सभी डेटा दर्ज किया लेकिन फिर यह त्रुटि सामने आती है।

मैंने पुनः लोड करने का प्रयास किया।

मुझे नहीं पता कि कौन सा टुकड़ा डालना है।शायद यहाँ।

कोड डालने से क्या हुआ

errro in getChatMember { Error: ETELEGRAM: 400 Bad Request: chat not found
    at request.then.resp (/app/node_modules/node-telegram-bot-api/src/telegram.js:280:15)
    at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:699:18)
    at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/app/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
  code: 'ETELEGRAM',
  response:
   IncomingMessage {
     _readableState:
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: BufferList { head: null, tail: null, length: 0 },
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: true,
        endEmitted: true,
        reading: false,
        sync: true,
        needReadable: false,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        paused: false,
        emitClose: true,
        autoDestroy: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0m,
        readingMore: 3mtrue,
        decoder: null2m,
        encoding: null },
     readable: false,
     _events:
      [Object: null prototype] {
        end: [Array],
        close: [Array],
        data: [Function],
        error: [Function] },
     _eventsCount: 4,
     _maxListeners: undefined,
     socket:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'api.telegram.org',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 7,
        connecting: false,
        _hadError: false,
        _handle: [TLSWrap],
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [ReadableState],
        readable: true,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [TLSWrap],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: null,
        [Symbol(res)]: [TLSWrap],
        [Symbol(asyncId)]: -1,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: null,
        [Symbol(kBytesRead)]: 0,
        [Symbol(kBytesWritten)]: 0,
        [Symbol(connect-options)]: [Object] },
     connection:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'api.telegram.org',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 7,
        connecting: false,
        _hadError: false,
        _handle: [TLSWrap],
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [ReadableState],
        readable: true,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [TLSWrap],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: null,
        [Symbol(res)]: [TLSWrap],
        [Symbol(asyncId)]: -1,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: null,
        [Symbol(kBytesRead)]: 0,
        [Symbol(kBytesWritten)]: 0,
        [Symbol(connect-options)]: [Object] },
     httpVersionMajor: 1,
     httpVersionMinor: 1,
     httpVersion: '1.1',
     complete: true,
     headers:
      { server: 'nginx/1.16.1',
        date: 'Sat, 31 Aug 2019 19:43:05 GMT',
        'content-type': 'application/json',
        'content-length': '73',
        connection: 'keep-alive',
        'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
        'access-control-allow-origin': '*',
        'access-control-expose-headers': 'Content-Length,Content-Type,Date,Server,Connection' },
     rawHeaders:
      [ 'Server',
        'nginx/1.16.1',
        'Date',
        'Sat, 31 Aug 2019 19:43:05 GMT',
        'Content-Type',
        'application/json',
        'Content-Length',
        '73',
        'Connection',
        'keep-alive',
        'Strict-Transport-Security',
        'max-age=31536000; includeSubDomains; preload',
        'Access-Control-Allow-Origin',
        '*',
        'Access-Control-Expose-Headers',
        'Content-Length,Content-Type,Date,Server,Connection' ],
     trailers: {},
     rawTrailers: [],
     aborted: false,
     upgrade: false,
     url: '',
     method: null,
     statusCode: 400,
     statusMessage: 'Bad Request',
     client:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'api.telegram.org',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 7,
        connecting: false,
        _hadError: false,
        _handle: [TLSWrap],
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [ReadableState],
        readable: true,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [TLSWrap],
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: null,
        [Symbol(res)]: [TLSWrap],
        [Symbol(asyncId)]: -1,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: null,
        [Symbol(kBytesRead)]: 0,
        [Symbol(kBytesWritten)]: 0,
        [Symbol(connect-options)]: [Object] },
     _consuming: false,
     _dumped: false,
     req:
      ClientRequest {
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: false,
        chunkedEncoding: false,
        shouldKeepAlive: true,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [TLSSocket],
        connection: [TLSSocket],
        _header:
         'POST /bot935567004:AAHzn_nFK3ROZZ16TTtoENflnjuD-luYtPc/getChatMember HTTP/1.1\r\nhost: api.telegram.org\r\ncontent-type: application/x-www-form-urlencoded\r\ncontent-length: 40\r\nConnection: keep-alive\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path:
         '/bot935567004:AAHzn_nFK3ROZZ16TTtoENflnjuD-luYtPc/getChatMember',
        _ended: true,
        res: [Circular],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(isCorked)]: false,
        [Symbol(outHeadersKey)]: [Object] },
     request:
      Request {
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        method: 'POST',
        simple: false,
        resolveWithFullResponse: true,
        forever: true,
        readable: true,
        writable: true,
        explicitMethod: true,
        _qs: [Querystring],
        _auth: [Auth],
        _oauth: [OAuth],
        _multipart: [Multipart],
        _redirect: [Redirect],
        _tunnel: [Tunnel],
        _rp_resolve: [Function],
        _rp_reject: [Function],
        _rp_promise: [Promise],
        _rp_callbackOrig: undefined,
        callback: [Function],
        _rp_options: [Object],
        headers: [Object],
        setHeader: [Function],
        hasHeader: [Function],
        getHeader: [Function],
        removeHeader: [Function],
        localAddress: undefined,
        pool: [Object],
        dests: [],
        __isRequestRequest: true,
        _callback: [Function: RP$callback],
        uri: [Url],
        proxy: null,
        tunnel: true,
        setHost: true,
        originalCookieHeader: undefined,
        _disableCookies: true,
        _jar: undefined,
        port: 443,
        host: 'api.telegram.org',
        body: 'chat_id=-1001457333935&user_id=749901319',
        path:
         '/bot935567004:AAHzn_nFK3ROZZ16TTtoENflnjuD-luYtPc/getChatMember',
        httpModule: [Object],
        agentClass: [Function],
        agentOptions: [Object],
        agent: [Agent],
        _started: true,
        href:
         'https://api.telegram.org/bot935567004:AAHzn_nFK3ROZZ16TTtoENflnjuD-luYtPc/getChatMember',
        req: [ClientRequest],
        ntick: true,
        response: [Circular],
        originalHost: 'api.telegram.org',
        originalHostHeaderName: 'host',
        responseContent: [Circular],
        _destdata: true,
        _ended: true,
        _callbackCalled: true },
     toJSON: [Function: responseToJSON],
     caseless: Caseless { dict: [Object] },
     body:
      { ok: false,
        error_code: 400,
        description: 'Bad Request: chat not found' } } }
(node:4) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `status` of 'undefined' or 'null'.
    at TelegramBot.bot.on (/app/app.js:201:22)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:4) 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:4) [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.
^C

(नोड:4)

त्रुटि: ETELEGRAM: 400 खराब अनुरोध: request.then.resp (/app/node_modules/node-telegram-bot-api/src/telegram.js:280:15) पर tryCatcher (/app/node_modules/bluebird) पर चैट नहीं मिली /js/release/util.js:16:23) Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:517:31) पर Promise._settlePromise (/app/node_modules/bluebird/js) पर /release/promise.js:574:18) Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:619:10) पर Promise._settlePromises (/app/node_modules/bluebird/js/release) पर /promise.js:699:18) _drainQueueStep पर (/app/node_modules/bluebird/js/release/async.js:138:12) _drainQueue पर (/app/node_modules/bluebird/js/release/async.js:131 :9) तत्काल पर Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:147:5) पर। .js:17:14) रनकॉलबैक पर (timers.js:705:18) tryOnImmedia पर ते (timers.js:676:5) प्रक्रिया पर तत्काल (timers.js:658:5) (नोड:4) UnhandledPromiseRejectionWarning: अनहेल्ड प्रॉमिस रिजेक्शन। यह त्रुटि या तो कैच ब्लॉक के बिना एसिंक्स फ़ंक्शन के अंदर फेंकने से या किसी ऐसे वादे को अस्वीकार करने से उत्पन्न हुई जिसे .catch() के साथ संभाला नहीं गया था। (अस्वीकृति आईडी: १) (नोड: ४) [डीईपी ००१८] बहिष्करण चेतावनी: बिना क्रिया के वादा अस्वीकृति बहिष्कृत हैं। भविष्य में, वादा अस्वीकरण जो संभाला नहीं जाता है, गैर-शून्य निकास कोड के साथ Node.js प्रक्रिया को समाप्त कर देगा।

0
ExeneS 30 अगस्त 2019, 20:10

1 उत्तर

सबसे बढ़िया उत्तर

आपको संदेश भेजने के लिए कैच जोड़कर वादा त्रुटियों को पकड़ना होगा, इसलिए कृपया सभी संदेश भेजें फ़ंक्शन में कैच ब्लॉक जोड़ें और जांचें कि कौन सा मामला त्रुटि है

bot.sendMessage(message.chat.id, text, params).catch(e => console.log("in 1", e) );

वादा श्रृंखला में कैच जोड़ने से चेतावनी संदेश लॉगिंग नहीं होगा लेकिन यह एक त्रुटि संदेश प्रिंट करेगा 400 Bad Request: chat not found ;

मुझे उम्मीद है कि त्रुटि यहां हो सकती है कृपया schema.ref लॉग इन करें और सुनिश्चित करें कि यह एक वैध चैट आईडी है।

schema.ref      =       Number(message.text.split("/start ")[1]);
bot.sendMessage(Number(message.text.split("/start ")[1]), `💣 Вы пригласили <a href="tg://user?id=${message.from.id}">пользователя</a>, вам начислено <b>${settings.ppr}₽</b>`, {
            parse_mode: "HTML"
        });

समस्या को ट्रैक करने के लिए पूर्ण उदाहरण:

bot.on("message", async (message) => {
    let ban = await Ban.findOne({ id: message.from.id });
    if(ban) return;

    message.send = (text, params , method ) => bot.sendMessage(message.chat.id, text, params).catch(e=> console.log("errro in " + method , e) ) ;

    await bot.getMe().catch(e=> console.log("errro in getMe" , e) );

    $menu = [];
    keyboards.main.map((x) => $menu.push(x));

    if(admins.find((x) => x === message.from.id)) $menu.push(["⚡️ Админка"])

    User.findOne({ id: message.from.id }).then(async ($user) => {
        if($user) return;

        let schema = {
            id: message.from.id,
            balance: 0,
            ref: 0,
            epr: 0,
            eps: 0,
            epv: 0,
            menu: "",
            adminmenu: "",
            prfUser: "",
            prp: {},
            regDate: `${new Date().getDate()}.${new Date().getMonth() + 1}.${new Date().getFullYear()}`,
            verify: false
        }

        if(Number(message.text.split("/start ")[1])) {
            schema.ref      =       Number(message.text.split("/start ")[1]);
            bot.sendMessage(Number(message.text.split("/start ")[1]), `💣 Вы пригласили <a href="tg://user?id=${message.from.id}">пользователя</a>, вам начислено <b>${settings.ppr}₽</b>`, {
                parse_mode: "HTML"
            }).catch(e => console.log("error in 💣 Вы пригласили ", e ));

            let ref = await User.findOne({ id: Number(message.text.split("/start ")[1]) });
            if(ref) {
                await ref.inc("balance", settings.ppr);
                message.send(`Благодарю, что вы воспользовались приглашением <a href="tg://user?id=${ref.id}">пользователя!</a>` , {} , "Благодарю");
            }
        }

        if(typeof(message.text.split("/start ")[1]) === "string") {
            let link = await Ref.findOne({ name: message.text.split("/start ")[1] });

            if(link) {
                if(!link.refs.find((x) => x === message.from.id)) {
                    link.refs.push(message.from.id);
                    await link.save();
                }
            }
        }

        let user = new User(schema);
        await user.save();

        return message.send(`Выберите действие. ⤵️`, {
            reply_markup: {
                keyboard: $menu,
                resize_keyboard: true
            }
        },"Выберите");
    });

    message.user = await User.findOne({ id: message.from.id });

    let { status } = await bot.getChatMember(-1001457333935, message.from.id).catch(e=> console.log("errro in getChatMember" , e) );;
    if(status === 'left') return message.send(`➕ *Для того, чтобы* начать/продолжить работу с ботом, *вы должны быть подписанным* на канал https://t.me/joinchat/AAAAAFbdJq9JTae6gCB9ag`, 
    {
        parse_mode: 'Markdown',
        reply_markup: {
            inline_keyboard: [
                [{ text: '➕ Подписаться', url: 'https://t.me/joinchat/AAAAAFbdJq9JTae6gCB9ag' }]
            ]
        }
    }, "➕ *Для того, ");
})
0
Yasser Mas 31 अगस्त 2019, 18:59