File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export class CopBot {
2626 }
2727 async start ( ) {
2828 const port = Config . port || 3000 ;
29+ const web_hook = Config . web_hook ;
2930 const isProduction = Config . environment === 'production' ;
3031 if ( isProduction ) {
3132 const server = http . createServer ( async ( req , res ) => {
@@ -72,13 +73,16 @@ export class CopBot {
7273 server . listen ( port , '0.0.0.0' , ( ) => {
7374 console . log ( `Bot started on port ${ port } ` ) ;
7475 } ) ;
76+ await this . _bot . api . setWebhook ( `${ web_hook } ` ) ;
77+ console . log ( `Webhook set successfully to: ${ web_hook } ` ) ;
7578 await this . _bot . start ( {
7679 onStart : ( botInfo ) => {
7780 console . log ( `Bot started in web-hook mode! Username: ${ botInfo . username } ` ) ;
7881 } ,
7982 } ) ;
8083 } else {
8184 try {
85+ await this . _bot . api . getUpdates ( { offset : - 1 } ) ;
8286 await this . _bot . start ( {
8387 onStart : ( botInfo ) => {
8488 console . log ( `Bot started in long-polling mode! Username: ${ botInfo . username } ` ) ;
@@ -130,7 +134,10 @@ export class CopBot {
130134 if ( ! chat ) {
131135 return ;
132136 }
133-
137+ const msg = ctx . message ?. text ! ;
138+ if ( msg === '/start' ) {
139+ console . log ( 'Start command received' ) ;
140+ }
134141 const reply = new BotReply ( ctx ) ;
135142 const from = ctx . from ;
136143 console . log ( `Bot added to group ${ chat . title } by ${ from ?. username } ` ) ;
You can’t perform that action at this time.
0 commit comments