Skip to content

Commit

Permalink
fix: add admin right error check
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Apr 14, 2021
1 parent b1c3b61 commit 88e8219
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/utils/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { isNone } from '../types/option';
async function handlerSendError(e: any, userId: number): Promise<boolean> {
// 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);
}
Expand Down Expand Up @@ -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;

0 comments on commit 88e8219

Please sign in to comment.