From 88e8219425719ac0608409479dd7a2b3fc73c1ce Mon Sep 17 00:00:00 2001 From: fengkx Date: Wed, 14 Apr 2021 16:19:56 +0800 Subject: [PATCH] fix: add admin right error check --- source/utils/send.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/utils/send.ts b/source/utils/send.ts index 5031c421657..495e8240b7f 100644 --- a/source/utils/send.ts +++ b/source/utils/send.ts @@ -19,8 +19,7 @@ import { isNone } from '../types/option'; async function handlerSendError(e: any, userId: number): Promise { // bot was blocked or chat is deleted logger.error(e); - const re = /chat not found|bot was blocked by the user|bot was kicked|user is deactivated/; - if (config.delete_on_err_send && re.test(e.description)) { + if (config.delete_on_err_send && isChatUnAvailable(e.description)) { logger.error(`delete all subscribes for user ${userId}`); deleteSubscribersByUserId(userId); } @@ -90,4 +89,9 @@ const send = async ( } }; +function isChatUnAvailable(description: string): boolean { + const re = /chat not found|bot was blocked by the user|bot was kicked|user is deactivated|have no rights|need administrator rights/; + return re.test(description); +} + export default send;