This commit is contained in:
parent
f056961d8e
commit
090abb06f2
1 changed files with 13 additions and 14 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:developer';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:mnemo_cards_telegram_bot/bot_config.dart';
|
import 'package:mnemo_cards_telegram_bot/bot_config.dart';
|
||||||
|
|
@ -93,7 +92,7 @@ Future<void> _handleCodeClaim({
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _run() async {
|
Future<void> _run() async {
|
||||||
log('Starting bot version $version');
|
print('[BOT] Starting bot version $version');
|
||||||
BackendClient? backendClient;
|
BackendClient? backendClient;
|
||||||
TeleDart? teledart;
|
TeleDart? teledart;
|
||||||
|
|
||||||
|
|
@ -104,7 +103,7 @@ Future<void> _run() async {
|
||||||
|
|
||||||
final adminIds = lines.map((e) => e.trim()).toList();
|
final adminIds = lines.map((e) => e.trim()).toList();
|
||||||
if (adminIds.isEmpty) {
|
if (adminIds.isEmpty) {
|
||||||
log('No admins found in admins file');
|
print('[BOT] ERROR: No admins found in admins file');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,12 +115,12 @@ Future<void> _run() async {
|
||||||
try {
|
try {
|
||||||
await teledart!.sendMessage(admin, message);
|
await teledart!.sendMessage(admin, message);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Failed to notify admin $admin', error: e);
|
print('[BOT] ERROR: Failed to notify admin $admin: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log('Using backend API at ${config.backendUrl}');
|
print('[BOT] Using backend API at ${config.backendUrl}');
|
||||||
|
|
||||||
backendClient = BackendClient(
|
backendClient = BackendClient(
|
||||||
backendUrl: config.backendUrl,
|
backendUrl: config.backendUrl,
|
||||||
|
|
@ -259,7 +258,7 @@ Future<void> _run() async {
|
||||||
} else {
|
} else {
|
||||||
message.reply('Что-то пошло не так');
|
message.reply('Что-то пошло не так');
|
||||||
}
|
}
|
||||||
log('app error', error: e, stackTrace: s);
|
print('[BOT] ERROR: app error: $e\n$s');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -294,7 +293,7 @@ Future<void> _run() async {
|
||||||
teledartInstance.sendMessage(message.chat.id, 'Загрузка apk...');
|
teledartInstance.sendMessage(message.chat.id, 'Загрузка apk...');
|
||||||
message.replyDocument(file, caption: t.simpleString);
|
message.replyDocument(file, caption: t.simpleString);
|
||||||
} on Object catch (e, s) {
|
} on Object catch (e, s) {
|
||||||
log('app error', error: e, stackTrace: s);
|
print('[BOT] ERROR: app error: $e\n$s');
|
||||||
message.reply(e.toString());
|
message.reply(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -314,7 +313,7 @@ Future<void> _run() async {
|
||||||
answer.write('$type/$size - ok\n');
|
answer.write('$type/$size - ok\n');
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
answer.write('$type/$size - error\n');
|
answer.write('$type/$size - error\n');
|
||||||
log('clear cache error $dir', error: e, stackTrace: s);
|
print('[BOT] ERROR: clear cache error $dir: $e\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
answer.write('$type/$size - not exists\n');
|
answer.write('$type/$size - not exists\n');
|
||||||
|
|
@ -359,7 +358,7 @@ Future<void> _run() async {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} on Object catch (e, s) {
|
} on Object catch (e, s) {
|
||||||
log('app error', error: e, stackTrace: s);
|
print('[BOT] ERROR: app error: $e\n$s');
|
||||||
message.reply(e.toString());
|
message.reply(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -392,7 +391,7 @@ Future<void> _run() async {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} on Object catch (e, s) {
|
} on Object catch (e, s) {
|
||||||
log('app error', error: e, stackTrace: s);
|
print('[BOT] ERROR: app error: $e\n$s');
|
||||||
message.reply(e.toString());
|
message.reply(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -437,7 +436,7 @@ Future<void> _run() async {
|
||||||
message.reply('No backups');
|
message.reply('No backups');
|
||||||
}
|
}
|
||||||
} on Object catch (e, s) {
|
} on Object catch (e, s) {
|
||||||
log('backup error', error: e, stackTrace: s);
|
print('[BOT] ERROR: backup error: $e\n$s');
|
||||||
message.reply(e.toString());
|
message.reply(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -587,10 +586,10 @@ Future<void> _run() async {
|
||||||
});
|
});
|
||||||
|
|
||||||
teledartInstance.start();
|
teledartInstance.start();
|
||||||
log('Bot started');
|
print('[BOT] Bot started successfully');
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
log('Error: $e', error: e, stackTrace: s);
|
print('[BOT] ERROR: Error: $e\n$s');
|
||||||
print('Error while starting bot: $e');
|
print('[BOT] Error while starting bot: $e');
|
||||||
print('Stack trace: $s');
|
print('Stack trace: $s');
|
||||||
print('');
|
print('');
|
||||||
print('Required environment variables:');
|
print('Required environment variables:');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue