Skip to content

Gracefully handle errors when unbanning users #178

@SitiSchu

Description

@SitiSchu

Currently the bot will simply refuse to unban a person if it fails to unban them in any of the groups.
Some cases where this can happen:

  1. Bot was in a group that is now deleted, but the group is still in the DB
    • Need to manually edit the DB to remove the group
  2. Group doesn't have the rights to unban the user in a group
    • For example the private moderation group where theres no point in banning users

Preferably the bot would just skip over these issues and still unban the user instead of making it impossible to unban them (and it also being impossible to know why its not working since theres no message from the bot, just a log on the server).
It should probably also remove inaccessible groups from its DB.

Example for 2.

TelegramError: 400: Bad Request: not enough rights to restrict/unrestrict chat member
    at Telegram.callApi (/app/node_modules/telegraf/lib/core/network/client.js:315:19)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Promise.all (index 0)
    at async unbanHandler (/app/handlers/commands/unban.js:39:2)
    at async execute (/app/node_modules/telegraf/lib/composer.js:518:17)
    at async /app/node_modules/telegraf/lib/composer.js:519:21
    at async execute (/app/node_modules/telegraf/lib/composer.js:518:17)
    at async /app/node_modules/telegraf/lib/composer.js:519:21
    at async execute (/app/node_modules/telegraf/lib/composer.js:518:17)
    at async /app/node_modules/telegraf/lib/composer.js:519:21 {
  response: {
    ok: false,
    error_code: 400,
    description: 'Bad Request: not enough rights to restrict/unrestrict chat member'
  },
  on: {
    method: 'unbanChatMember',
    payload: { chat_id: -100xxxxxxxxxx, user_id: 81xxxxxx }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions