almost working
This commit is contained in:
parent
828b93c43c
commit
4c1d9baa41
14 changed files with 1690 additions and 0 deletions
11
lib/controllers/client_controller.dart
Normal file
11
lib/controllers/client_controller.dart
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import 'package:tmi/tmi.dart';
|
||||
import "package:riverpod/riverpod.dart";
|
||||
|
||||
class ClientController extends Notifier<Client> {
|
||||
@override
|
||||
Client build() => Client(channels: "cozyp62", secure: true)..connect();
|
||||
|
||||
static final provider = NotifierProvider<ClientController, Client>(
|
||||
ClientController.new,
|
||||
);
|
||||
}
|
||||
29
lib/controllers/record_controller.dart
Normal file
29
lib/controllers/record_controller.dart
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import "package:cozybot/controllers/client_controller.dart";
|
||||
import "package:riverpod/riverpod.dart";
|
||||
|
||||
class RecordController extends Notifier<String> {
|
||||
@override
|
||||
String build() {
|
||||
ref.watch(ClientController.provider).on("message", (
|
||||
_,
|
||||
userstate,
|
||||
message,
|
||||
_,
|
||||
) {
|
||||
if (userstate.username == "Streamlabs") {
|
||||
final match = RegExp(
|
||||
r"\d+[Ww]?-\d+[Ll]?",
|
||||
).allMatches(message).lastOrNull;
|
||||
final group = match?.group(0);
|
||||
if (group == null) return;
|
||||
state = "Record:\n$group";
|
||||
}
|
||||
});
|
||||
|
||||
return "Record:\n0-0";
|
||||
}
|
||||
|
||||
static final provider = NotifierProvider<RecordController, String>(
|
||||
RecordController.new,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue