Skip to content

Commit 3639569

Browse files
committed
feat: Removed instance variable for WebHookService, created instance locally in setupWebhook method
1 parent a5e4e01 commit 3639569

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/bot/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import { WebHookService } from '../service/WebHook';
1414
export class CopBot {
1515
private static instance: CopBot;
1616
private _bot: Bot<Context>;
17-
private _webhookService: WebHookService;
1817
private constructor() {
1918
this._bot = new Bot<Context>(Config.token, { client: { timeoutSeconds: 20 } });
20-
this._webhookService = new WebHookService(this._bot);
2119
}
2220
// Public method to get the singleton instance of CopBot
2321
public static getInstance(): CopBot {
@@ -42,9 +40,9 @@ export class CopBot {
4240
console.log('Setting webhook...');
4341
try {
4442
console.log('Setting up webhook...');
45-
await this._webhookService.setupWebHook();
46-
await this._webhookService.initial();
47-
this._webhookService.startServer();
43+
const _webhookService = new WebHookService(this._bot);
44+
await _webhookService.setupWebHook();
45+
_webhookService.startServer();
4846
console.log(`Bot started in webhook mode`);
4947
} catch (err) {
5048
console.error('Error setting up webhook:', err);

0 commit comments

Comments
 (0)