custom record stuff
This commit is contained in:
parent
fd0d598f4c
commit
f15283cb7f
4 changed files with 43 additions and 76 deletions
|
|
@ -1,17 +0,0 @@
|
||||||
import 'package:tmi/tmi.dart';
|
|
||||||
import "package:riverpod/riverpod.dart";
|
|
||||||
|
|
||||||
class ClientController extends Notifier<Client> {
|
|
||||||
@override
|
|
||||||
Client build() {
|
|
||||||
final client = Client(channels: "cozyp62", secure: true)
|
|
||||||
..connect()
|
|
||||||
..on("disconnected", (reason) => ref.invalidateSelf());
|
|
||||||
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
|
|
||||||
static final provider = NotifierProvider<ClientController, Client>(
|
|
||||||
ClientController.new,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +1,51 @@
|
||||||
import "package:cozybot/controllers/client_controller.dart";
|
import "dart:convert";
|
||||||
|
import "dart:io";
|
||||||
import "package:riverpod/riverpod.dart";
|
import "package:riverpod/riverpod.dart";
|
||||||
|
|
||||||
class RecordController extends Notifier<String> {
|
class RecordController extends Notifier<String> {
|
||||||
@override
|
@override
|
||||||
String build() {
|
String build() {
|
||||||
ref.watch(ClientController.provider).on("chat", (_, userstate, message, _) {
|
print("aa");
|
||||||
if (userstate["username"] == "streamlabs") {
|
WebSocket.connect("wss://irc-ws.chat.twitch.tv:443").then((ws) {
|
||||||
final match = RegExp(
|
void send(String data) => ws.add("$data\n\r");
|
||||||
r"\d+[Ww]?-\d+[Ll]?",
|
|
||||||
).allMatches(message).lastOrNull;
|
send("NICK justinfan12345");
|
||||||
final group = match?.group(0);
|
send("JOIN #cozyp62");
|
||||||
if (group == null) return;
|
print("Logged in...");
|
||||||
state = "Record:\n$group";
|
|
||||||
}
|
ws.listen(
|
||||||
|
(text) {
|
||||||
|
for (final line in const LineSplitter().convert(text)) {
|
||||||
|
if (line.startsWith("PING")) {
|
||||||
|
return send("PONG :tmi.twitch.tv");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!line.contains(" PRIVMSG #")) return;
|
||||||
|
|
||||||
|
// Parse user from ":user!user@user.tmi.twitch.tv ..."
|
||||||
|
if (!line.startsWith(":")) continue;
|
||||||
|
final bang = line.indexOf("!");
|
||||||
|
if (bang == -1) return;
|
||||||
|
final user = line.substring(1, bang);
|
||||||
|
|
||||||
|
// Parse message after " :"
|
||||||
|
final msgStart = line.indexOf(" :");
|
||||||
|
if (msgStart == -1) return;
|
||||||
|
final message = line.substring(msgStart + 2);
|
||||||
|
|
||||||
|
if (user != "streamlabs") return;
|
||||||
|
|
||||||
|
final match = RegExp(
|
||||||
|
r"\d+[Ww]?-\d+[Ll]?",
|
||||||
|
).allMatches(message).lastOrNull;
|
||||||
|
final group = match?.group(0);
|
||||||
|
if (group == null) return;
|
||||||
|
state = "Record:\n$group";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDone: ref.invalidateSelf,
|
||||||
|
onError: (_) => ref.invalidateSelf(),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return "Record:\n0-0";
|
return "Record:\n0-0";
|
||||||
|
|
|
||||||
48
pubspec.lock
48
pubspec.lock
|
|
@ -65,14 +65,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.6.1"
|
version: "4.6.1"
|
||||||
eventify:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: eventify
|
|
||||||
sha256: b829429f08586cc2001c628e7499e3e3c2493a1d895fd73b00ecb23351aa5a66
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.1"
|
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -113,14 +105,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
logger:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: logger
|
|
||||||
sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.6.2"
|
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -257,14 +241,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.2"
|
version: "1.2.2"
|
||||||
tmi:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: tmi
|
|
||||||
sha256: "25d21ac46d06aaf858fa6727b6650baffa16a2ac450661926885583a99f2b636"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.0.5"
|
|
||||||
type_plus:
|
type_plus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -289,30 +265,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
web_socket:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: web_socket
|
|
||||||
sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.1"
|
|
||||||
web_socket_channel:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: web_socket_channel
|
|
||||||
sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.3"
|
|
||||||
web_socket_client:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: web_socket_client
|
|
||||||
sha256: "0ec5230852349191188c013112e4d2be03e3fc83dbe80139ead9bf3a136e53b5"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.5"
|
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dependencies:
|
||||||
shelf_router: ^1.1.4
|
shelf_router: ^1.1.4
|
||||||
cli_tools: ^0.6.0
|
cli_tools: ^0.6.0
|
||||||
collection: ^1.19.1
|
collection: ^1.19.1
|
||||||
tmi: ^0.0.5
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
lints: ^6.0.0
|
lints: ^6.0.0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue