gringobot icon indicating copy to clipboard operation
gringobot copied to clipboard

error handling when /eita is invoked from a private chat

Open armand1m opened this issue 3 years ago • 0 comments

Describe the bug

When someone invoked the /eita command in a private conversation, the bot instance errors with a 400 and the instance gets terminated.

Unhandled error while processing {
  update_id: 3627372363,
  message: {
    message_id: 8383,
    from: {
      id: 12312312312,
      is_bot: false,
      first_name: 'xxx',
      last_name: '.',
      username: 'yyy',
      language_code: 'en'
    },
    chat: {
      id: 11111222222,
      first_name: 'xxx',
      last_name: '.',
      username: 'yyy',
      type: 'private'
    },
    date: 1661782466,
    text: '/eita',
    entities: [ [Object] ]
  }
}
/app/node_modules/telegraf/lib/core/network/client.js:258
            throw new error_1.default(data, { method, payload });
                  ^

TelegramError: 400: Bad Request: there are no administrators in the private chat
    at Telegram.callApi (/app/node_modules/telegraf/lib/core/network/client.js:258:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  response: {
    ok: false,
    error_code: 400,
    description: 'Bad Request: there are no administrators in the private chat'
  },
  on: { method: 'getChatAdministrators', payload: { chat_id: 1284516730 } }
}

To Reproduce Steps to reproduce the behavior:

  1. Open a private chat with a gringobot instance
  2. Invoke /eita
  3. Check instance logs

Expected behavior The server should know how to handle specific commands based on the chat type. If it's private, some commands should be disabled.

armand1m avatar Aug 29 '22 16:08 armand1m