88 lines
2.6 KiB
Dart
88 lines
2.6 KiB
Dart
import 'anim_command.dart';
|
|
import 'crush_command.dart';
|
|
import 'epsh_files_command.dart';
|
|
import 'fake_video_message_command.dart';
|
|
import 'info_command.dart';
|
|
import 'send_control_command.dart';
|
|
import 'slash_command.dart';
|
|
import 'watching_command.dart';
|
|
import '../../core/plugins/plugin_store.dart';
|
|
import '../../core/plugins/plugin_models.dart';
|
|
import '../../core/config/app_commands.dart';
|
|
|
|
const List<SlashCommand> kSlashCommands = [
|
|
SlashCommand('/test', '12345 test отображение'),
|
|
SlashCommand('/info', 'сводка данных о человеке', run: runInfo),
|
|
SlashCommand('/anim1', 'анимация текста', run: runAnim1),
|
|
SlashCommand('/IAlwaysWatchingYou', '👁️', run: runWatching),
|
|
SlashCommand(
|
|
'/epshFiles',
|
|
'цензура слов чёрными квадратами {шанс 1-100}',
|
|
run: runEpshFiles,
|
|
),
|
|
SlashCommand(
|
|
'/crush',
|
|
'Тест устойчивости веб клиента макса',
|
|
run: runCrush,
|
|
hidden: true,
|
|
),
|
|
SlashCommand(
|
|
'/FakeVideoMessage',
|
|
'кружок с подменённой длиной: [13:37 | 10000 (сек)]',
|
|
run: runFakeVideoMessage,
|
|
),
|
|
SlashCommand(
|
|
'/sendControlPayload',
|
|
'CONTROL в текущий чат: [event | json]',
|
|
run: runSendControl,
|
|
),
|
|
];
|
|
|
|
SlashCommand? findSlashCommand(String text) {
|
|
final name = text.trimLeft().split(RegExp(r'\s')).first.toLowerCase();
|
|
for (final c in allSlashCommands) {
|
|
if (c.name.toLowerCase() == name) return c;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
List<SlashCommand> get allSlashCommands {
|
|
final plugins = <SlashCommand>[];
|
|
final names = <String>{};
|
|
for (final plugin in PluginStore.instance.plugins.value) {
|
|
if (!plugin.enabled) continue;
|
|
for (final command in plugin.manifest.commands) {
|
|
if (!names.add(command.name.toLowerCase())) continue;
|
|
final descriptor = PluginCommandDescriptor(
|
|
plugin: plugin,
|
|
command: command,
|
|
);
|
|
plugins.add(
|
|
SlashCommand(
|
|
command.name,
|
|
command.description,
|
|
hidden: command.hidden,
|
|
arguments: command.arguments,
|
|
run: (context) async {
|
|
final run = context.runPlugin;
|
|
if (run == null) throw StateError('Plugin host is unavailable');
|
|
await run(descriptor);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
return [
|
|
...plugins,
|
|
if (AppCommands.current.value)
|
|
...kSlashCommands.where((c) => !names.contains(c.name.toLowerCase())),
|
|
];
|
|
}
|
|
|
|
String commandArgs(String text) {
|
|
final trimmed = text.trimLeft();
|
|
final idx = trimmed.indexOf(RegExp(r'\s'));
|
|
if (idx == -1) return '';
|
|
return trimmed.substring(idx + 1).trim();
|
|
}
|