add internal gomuks command support
This commit is contained in:
parent
3fc33a5ac9
commit
8650c44266
1 changed files with 168 additions and 79 deletions
44
lib/controllers/gomuks_commands.dart
Normal file
44
lib/controllers/gomuks_commands.dart
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/client.dart";
|
||||
import "package:nexus/models/bot_command.dart";
|
||||
|
||||
class GomuksCommandsController extends AsyncNotifier<IList<BotCommand>> {
|
||||
static const unsupported = ISetConst({
|
||||
// Needs gomuks web
|
||||
"devtools",
|
||||
"upgraderoom",
|
||||
|
||||
// Needs attachment stuff
|
||||
"myroomavatar",
|
||||
"globalavatar",
|
||||
"roomavatar",
|
||||
|
||||
// Already in Nexus' UI with a better UX
|
||||
"poll",
|
||||
});
|
||||
|
||||
@override
|
||||
Future<IList<BotCommand>> build() async =>
|
||||
(await ref
|
||||
.read(ClientController.provider.notifier)
|
||||
.getCommandDefinitions())
|
||||
.where(
|
||||
(description) =>
|
||||
description.isValid &&
|
||||
!unsupported.contains(description.command),
|
||||
)
|
||||
.map(
|
||||
(description) => BotCommand(
|
||||
sender: BotCommand.gomuksSender,
|
||||
botName: "gomuks",
|
||||
description: description,
|
||||
),
|
||||
)
|
||||
.toIList();
|
||||
|
||||
static final provider =
|
||||
AsyncNotifierProvider<GomuksCommandsController, IList<BotCommand>>(
|
||||
GomuksCommandsController.new,
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue