Skip to content

Commit 88e8219

Browse files
committed
fix: add admin right error check
1 parent b1c3b61 commit 88e8219

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/utils/send.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import { isNone } from '../types/option';
1919
async function handlerSendError(e: any, userId: number): Promise<boolean> {
2020
// bot was blocked or chat is deleted
2121
logger.error(e);
22-
const re = /chat not found|bot was blocked by the user|bot was kicked|user is deactivated/;
23-
if (config.delete_on_err_send && re.test(e.description)) {
22+
if (config.delete_on_err_send && isChatUnAvailable(e.description)) {
2423
logger.error(`delete all subscribes for user ${userId}`);
2524
deleteSubscribersByUserId(userId);
2625
}
@@ -90,4 +89,9 @@ const send = async (
9089
}
9190
};
9291

92+
function isChatUnAvailable(description: string): boolean {
93+
const re = /chat not found|bot was blocked by the user|bot was kicked|user is deactivated|have no rights|need administrator rights/;
94+
return re.test(description);
95+
}
96+
9397
export default send;

0 commit comments

Comments
 (0)