27 lines
636 B
TypeScript
27 lines
636 B
TypeScript
import { APIError, MessageContext } from "vk-io";
|
|
import { Composer } from "../composer";
|
|
import { logger } from "../logger";
|
|
|
|
export const composer = new Composer<MessageContext>();
|
|
|
|
composer.use(async (ctx, next) => {
|
|
try {
|
|
await next();
|
|
} catch (err) {
|
|
logger.error(err);
|
|
}
|
|
});
|
|
|
|
composer.use(async (ctx, next) => {
|
|
try {
|
|
await next();
|
|
} catch (err) {
|
|
if (err instanceof APIError && err.code === 917) {
|
|
logger.error('no access to the chat');
|
|
await ctx.send('хачю доступ к чату :=(');
|
|
return;
|
|
}
|
|
|
|
throw err;
|
|
}
|
|
}); |