@@ -30,27 +30,30 @@ export class CopBot {
3030
3131 // Start the bot
3232 async start ( ) : Promise < void > {
33- const startBot = async ( ) => {
33+ const startBot = async ( mode : string ) => {
3434 await this . _bot . start ( {
3535 onStart : ( botInfo ) => {
36- console . log ( `Bot started in long-polling mode! Username: ${ botInfo . username } ` ) ;
36+ console . log ( `Bot started in ${ mode } mode! Username: ${ botInfo . username } ` ) ;
3737 } ,
3838 } ) ;
3939 } ;
4040 const isProduction = Config . environment === 'production' ;
4141 const webhookURL = `${ Config . web_hook } /bot/${ Config . token } ` ;
42+ const mode = isProduction ? 'webhook' : 'long-polling' ;
4243 console . log ( `Environment: ${ Config . environment } ` ) ;
4344 console . log ( `Web hook Url: ${ webhookURL } ` ) ;
4445 console . log ( `Running in ${ isProduction ? 'webhook' : 'long-polling' } mode` ) ;
4546 if ( isProduction ) {
4647 console . log ( 'Setting webhook...' ) ;
4748 try {
48- await startBot ( ) ;
4949 console . log ( 'Setting up webhook...' ) ;
5050 const _webhookService = new WebHookService ( this . _bot ) ;
5151 await _webhookService . setupWebHook ( ) ;
5252 _webhookService . startServer ( ) ;
53+ await startBot ( mode ) ;
54+ const webhookInfo = await this . _bot . api . getWebhookInfo ( ) ;
5355 console . log ( `Bot started in webhook mode` ) ;
56+ console . log ( 'webhookInfo' , webhookInfo ) ;
5457 } catch ( err ) {
5558 console . error ( 'Error setting up webhook:' , err ) ;
5659 process . exit ( 1 ) ;
@@ -59,7 +62,7 @@ export class CopBot {
5962 console . log ( 'Running in long-polling mode...' ) ;
6063 try {
6164 await this . _bot . api . deleteWebhook ( ) ;
62- await startBot ( ) ;
65+ await startBot ( mode ) ;
6366 } catch ( err ) {
6467 console . error ( 'Error in long-polling mode:' , err ) ;
6568 process . exit ( 1 ) ;
0 commit comments