Skip to content

Commit

Permalink
Merge pull request #11 from LezdCS/parser-improvment
Browse files Browse the repository at this point in the history
Parser improvment
  • Loading branch information
LezdCS authored Apr 24, 2024
2 parents 1aa2c71 + cb1880d commit 5eb4fb1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 76 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,17 @@ Code format and pub score

## 0.0.4

Fix 7TV emotes
Fix 7TV emotes

## 1.0.0

Release stable

## 1.1.0

Breaking changes
Fixed few stuff

## 1.2.0

Breaking changes (Twitch API)
64 changes: 0 additions & 64 deletions lib/src/data/seventv_api.dart

This file was deleted.

4 changes: 2 additions & 2 deletions lib/src/data/twitch_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class TwitchApi {
static Future<void> banUser(
String token,
String broadcasterId,
String userId,
String authorId,
int? duration,
String clientId,
) async {
Expand All @@ -145,7 +145,7 @@ class TwitchApi {
dio.options.headers["authorization"] = "Bearer $token";
Map body = {
"data": {
"user_id": userId,
"user_id": authorId,
},
};
if (duration != null) {
Expand Down
19 changes: 15 additions & 4 deletions lib/src/twitch_chat.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:async';

import 'package:api_7tv/api_7tv.dart';
import 'package:collection/collection.dart';
import 'package:flutter/cupertino.dart';
import 'package:twitch_chat/src/twitch_badge.dart';
import 'package:twitch_chat/src/chat_message.dart';
import 'package:twitch_chat/src/data/ffz_api.dart';
import 'package:twitch_chat/src/data/seventv_api.dart';
import 'package:twitch_chat/src/data/twitch_api.dart';
import 'package:twitch_chat/src/twitch_chat_parameters.dart';
import 'package:twitch_chat/src/utils/split_function.dart';
Expand Down Expand Up @@ -414,10 +414,21 @@ class TwitchChat {

await FfzApi.getEmotes(_channelId!).then((value) => emotes.addAll(value));

await SeventvApi.getChannelEmotes(_channelId!)
.then((value) => emotes.addAll(value));
await SeventvApi.getChannelEmotes(_channelId!).then((value) => {
value?.forEach(
(emote) => emotes.add(
Emote.fromJson7Tv(emote),
),
)
});

await SeventvApi.getGlobalEmotes().then((value) => emotes.addAll(value));
await SeventvApi.getGlobalEmotes().then((value) => {
value?.forEach(
(emote) => emotes.add(
Emote.fromJson7Tv(emote),
),
)
});

return emotes;
}
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: twitch_chat
description: twitch_tchat allows dart and flutter apps to exploit the Twitch IRC with Emotes and Badges.
version: 1.0.0
version: 1.2.0
homepage: https://github.com/LezdCS/twitch_chat
repository: https://github.com/LezdCS/twitch_chat

Expand All @@ -16,6 +16,7 @@ dependencies:
quiver: ^3.2.1
faker: ^2.1.0
uuid: ^3.0.7
api_7tv: ^0.0.1

dev_dependencies:
flutter_test:
Expand Down
11 changes: 7 additions & 4 deletions test/twitch_chat_test.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
@Timeout(Duration(seconds: 90000))

import 'package:api_7tv/api_7tv.dart';
import 'package:collection/collection.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:twitch_chat/src/data/seventv_api.dart';
import 'package:twitch_chat/twitch_chat.dart';

Future<void> main() async {

String token = 'USER_TOKEN';
String clientId = 'TWITCH_CLIENT_ID';

Expand All @@ -18,8 +17,12 @@ Future<void> main() async {
clientId,
);

List<Emote> emotes = await SeventvApi.getChannelEmotes(
channelId!,
List emotesCall = await SeventvApi.getChannelEmotes(channelId!) ?? [];
List<Emote> emotes = [];
emotesCall.forEach(
(emote) => emotes.add(
Emote.fromJson7Tv(emote),
),
);

expect(emotes, isNotEmpty);
Expand Down

0 comments on commit 5eb4fb1

Please sign in to comment.