@@ -17,7 +17,6 @@ export class CopBot {
17
17
private webhookPath = `/bot/${ Config . token } ` ;
18
18
private webhookURL = `${ Config . web_hook } ${ this . webhookPath } ` ;
19
19
private mode = this . isProduction ? 'webhook' : 'long-polling' ;
20
- private static latestContext : Context | null = null ;
21
20
private constructor ( ) {
22
21
this . _bot = new Bot < Context > ( Config . token ) ;
23
22
}
@@ -28,19 +27,6 @@ export class CopBot {
28
27
}
29
28
return CopBot . instance ;
30
29
}
31
- public static setContext ( ctx : Context ) : void {
32
- logger . info ( `Setting new context: at ${ new Date ( ) . toISOString ( ) } ` ) ;
33
- this . latestContext = ctx ;
34
- }
35
-
36
- public static getContext ( ) : Context | null {
37
- if ( this . latestContext ) {
38
- logger . info ( `Retrieved latest context: at ${ new Date ( ) . toISOString ( ) } ` ) ;
39
- } else {
40
- logger . warn ( 'Attempted to retrieve context, but no context is set.' ) ;
41
- }
42
- return this . latestContext ;
43
- }
44
30
// Stop the bot
45
31
async stop ( ) : Promise < void > {
46
32
if ( this . healthCheckInterval ) {
@@ -131,10 +117,7 @@ export class CopBot {
131
117
} )
132
118
) ;
133
119
this . _bot . on ( 'my_chat_member' , ( ctx ) => this . handleJoinNewChat ( ctx ) ) ;
134
- this . _bot . on ( 'message' , ( ctx ) => {
135
- CopBot . setContext ( ctx ) ;
136
- this . handleMessage ( ctx ) ;
137
- } ) ;
120
+ this . _bot . on ( 'message' , ( ctx ) => this . handleMessage ( ctx ) ) ;
138
121
this . _bot . catch ( async ( error : BotError < Context > ) => {
139
122
if ( error . message . includes ( 'timeout' ) ) {
140
123
await error . ctx . reply ( 'The request took too long to process. Please try again later.' ) ;
0 commit comments