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,11 +1,40 @@
|
|||
import "package:cozybot/controllers/client_controller.dart";
|
||||
import "dart:convert";
|
||||
import "dart:io";
|
||||
import "package:riverpod/riverpod.dart";
|
||||
|
||||
class RecordController extends Notifier<String> {
|
||||
@override
|
||||
String build() {
|
||||
ref.watch(ClientController.provider).on("chat", (_, userstate, message, _) {
|
||||
if (userstate["username"] == "streamlabs") {
|
||||
print("aa");
|
||||
WebSocket.connect("wss://irc-ws.chat.twitch.tv:443").then((ws) {
|
||||
void send(String data) => ws.add("$data\n\r");
|
||||
|
||||
send("NICK justinfan12345");
|
||||
send("JOIN #cozyp62");
|
||||
print("Logged in...");
|
||||
|
||||
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;
|
||||
|
|
@ -13,6 +42,10 @@ class RecordController extends Notifier<String> {
|
|||
if (group == null) return;
|
||||
state = "Record:\n$group";
|
||||
}
|
||||
},
|
||||
onDone: ref.invalidateSelf,
|
||||
onError: (_) => ref.invalidateSelf(),
|
||||
);
|
||||
});
|
||||
|
||||
return "Record:\n0-0";
|
||||
|
|
|
|||
48
pubspec.lock
48
pubspec.lock
|
|
@ -65,14 +65,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.6.1"
|
||||
eventify:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: eventify
|
||||
sha256: b829429f08586cc2001c628e7499e3e3c2493a1d895fd73b00ecb23351aa5a66
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -113,14 +105,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.0"
|
||||
logger:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logger
|
||||
sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.2"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -257,14 +241,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -289,30 +265,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ dependencies:
|
|||
shelf_router: ^1.1.4
|
||||
cli_tools: ^0.6.0
|
||||
collection: ^1.19.1
|
||||
tmi: ^0.0.5
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^6.0.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue