You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Remove validateTelegramConfig call to allow service to start without token
87
+
88
+
constservice=newTelegramService(runtime);
89
+
90
+
// If bot is not initialized (no token), return the service without further initialization
91
+
if(!service.bot){
92
+
logger.warn('Telegram service started without bot functionality - no bot token provided');
93
+
returnservice;
94
+
}
72
95
73
96
constmaxRetries=5;
74
97
letretryCount=0;
75
98
letlastError: Error|null=null;
76
99
77
100
while(retryCount<maxRetries){
78
101
try{
79
-
constservice=newTelegramService(runtime);
80
-
81
102
logger.success(
82
103
`✅ Telegram client successfully started for character ${runtime.character.name}`
83
104
);
@@ -92,7 +113,7 @@ export class TelegramService extends Service {
92
113
service.setupMessageHandlers();
93
114
94
115
// Wait for bot to be ready by testing getMe()
95
-
awaitservice.bot.telegram.getMe();
116
+
awaitservice.bot!.telegram.getMe();
96
117
97
118
returnservice;
98
119
}catch(error){
@@ -110,9 +131,12 @@ export class TelegramService extends Service {
110
131
}
111
132
}
112
133
113
-
thrownewError(
114
-
`Telegram initialization failed after ${maxRetries} attempts. Last error: ${lastError?.message}`
134
+
logger.error(
135
+
`Telegram initialization failed after ${maxRetries} attempts. Last error: ${lastError?.message}. Service will continue without Telegram functionality.`
115
136
);
137
+
138
+
// Return the service even if initialization failed, to prevent server crash
139
+
returnservice;
116
140
}
117
141
118
142
/**
@@ -133,32 +157,32 @@ export class TelegramService extends Service {
133
157
* @returns A Promise that resolves once the bot has stopped.
134
158
*/
135
159
asyncstop(): Promise<void>{
136
-
this.bot.stop();
160
+
this.bot?.stop();
137
161
}
138
162
139
163
/**
140
164
* Initializes the Telegram bot by launching it, getting bot info, and setting up message manager.
141
165
* @returns {Promise<void>} A Promise that resolves when the initialization is complete.
0 commit comments