-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
276 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
class TwitchChatSettings { | ||
/// The ID of the broadcaster specified in the request. | ||
final String broadcasterId; | ||
|
||
/// A Boolean value that determines whether chat messages must contain only | ||
/// emotes. Is `true`, if only messages that are 100% emotes are allowed; | ||
/// otherwise, `false`. | ||
final bool emoteMode; | ||
|
||
/// A Boolean value that determines whether the broadcaster restricts the chat | ||
/// room to followers only, based on how long they’ve followed. | ||
/// | ||
/// Is `true`, if the broadcaster restricts the chat room to followers only; | ||
/// otherwise, `false`. | ||
/// | ||
/// See [followerModeDuration] for how long the followers must have followed | ||
/// the broadcaster to participate in the chat room. | ||
final bool followerMode; | ||
|
||
/// The length of time, in minutes, that the followers must have followed the | ||
/// broadcaster to participate in the chat room. See [followerMode]. | ||
/// | ||
/// Is `null` if [followerMode] is `false`. | ||
final int? followerModeDuration; | ||
|
||
/// The moderator’s ID. The response includes this field only if the request | ||
/// specifies a User access token that includes the | ||
/// `TwitchApiScope.moderatorReadChatSettings` scope. | ||
final String? moderatorId; | ||
|
||
/// A Boolean value that determines whether the broadcaster adds a short delay | ||
/// before chat messages appear in the chat room. This gives chat moderators | ||
/// and bots a chance to remove them before viewers can see the message. | ||
/// | ||
/// Is `true`, if the broadcaster applies a delay; otherwise, `false`. | ||
/// | ||
/// See [nonModeratorChatDelayDuration] for the length of the delay. | ||
/// | ||
/// The response includes this field only if the request specifies a User | ||
/// access token that includes the `TwitchApiScope.moderatorReadChatSettings` | ||
/// scope. | ||
final bool nonModeratorChatDelay; | ||
|
||
/// The amount of time, in seconds, that messages are delayed from appearing | ||
/// in chat. See [nonModeratorChatDelay]. | ||
/// | ||
/// Is `null` if [nonModeratorChatDelay] is `false`. | ||
/// | ||
/// The response includes this field only if the request specifies a User | ||
/// access token that includes the `TwitchApiScope.moderatorReadChatSettings` | ||
/// scope. | ||
final int? nonModeratorChatDelayDuration; | ||
|
||
/// A Boolean value that determines whether the broadcaster limits how often | ||
/// users in the chat room are allowed to send messages. | ||
/// | ||
/// Is `true`, if the broadcaster applies a delay; otherwise, `false`. | ||
/// | ||
/// See [slowModeWaitTime] for the delay. | ||
final bool slowMode; | ||
|
||
/// The amount of time, in seconds, that users need to wait between sending | ||
/// messages. See [slowMode]. | ||
/// | ||
/// Is `null` if [slowMode] is `false`. | ||
final int? slowModeWaitTime; | ||
|
||
/// A Boolean value that determines whether only users that subscribe to the | ||
/// broadcaster’s channel can talk in the chat room. | ||
/// | ||
/// Is `true`, if the broadcaster restricts the chat room to subscribers only; | ||
/// otherwise, `false`. | ||
final bool subscriberMode; | ||
|
||
/// A Boolean value that determines whether the broadcaster requires users to | ||
/// post only unique messages in the chat room. | ||
/// | ||
/// Is `true`, if the broadcaster requires unique messages only; otherwise, | ||
/// `false`. | ||
final bool uniqueChatMode; | ||
|
||
TwitchChatSettings({ | ||
required this.broadcasterId, | ||
required this.emoteMode, | ||
required this.followerMode, | ||
required this.followerModeDuration, | ||
required this.moderatorId, | ||
required this.nonModeratorChatDelay, | ||
required this.nonModeratorChatDelayDuration, | ||
required this.slowMode, | ||
required this.slowModeWaitTime, | ||
required this.subscriberMode, | ||
required this.uniqueChatMode, | ||
}); | ||
|
||
factory TwitchChatSettings.fromJson(Map<String, dynamic> json) { | ||
return TwitchChatSettings( | ||
broadcasterId: json['broadcaster_id'] as String, | ||
emoteMode: json['emote_mode'] as bool, | ||
followerMode: json['follower_mode'] as bool, | ||
followerModeDuration: json['follower_mode_duration'] as int?, | ||
moderatorId: json['moderator_id'] as String?, | ||
nonModeratorChatDelay: json['non_moderator_chat_delay'] as bool, | ||
nonModeratorChatDelayDuration: | ||
json['non_moderator_chat_delay_duration'] as int?, | ||
slowMode: json['slow_mode'] as bool, | ||
slowModeWaitTime: json['slow_mode_wait_time'] as int?, | ||
subscriberMode: json['subscriber_mode'] as bool, | ||
uniqueChatMode: json['unique_chat_mode'] as bool, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:test/test.dart'; | ||
|
||
import '../utils/twitch_mock_client.dart'; | ||
|
||
void main() { | ||
final client = TwitchMockClient(); | ||
|
||
group('getChatSettings', () { | ||
const tBroadcasterId = '1234'; | ||
|
||
test('1', () async { | ||
final settings = | ||
await client.getChatSettings(broadcasterId: tBroadcasterId); | ||
expect(settings.length, 1); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:test/test.dart'; | ||
|
||
import '../utils/twitch_mock_client.dart'; | ||
|
||
void main() { | ||
final client = TwitchMockClient(); | ||
|
||
group('getGlobalChatBadges', () { | ||
test('1', () async { | ||
final badges = await client.getGlobalChatBadges(); | ||
expect(badges.length, 1); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:twitch_api/src/models/twitch_chat_settings.dart'; | ||
|
||
import '../utils/test_utils.dart'; | ||
|
||
void main() { | ||
group('TwitchChatSettings', () { | ||
test('parse: get_chat_settings.json', () async { | ||
final json = | ||
jsonDecode(await readFileStringAsync('get_chat_settings.json')) | ||
as Map<String, dynamic>; | ||
final settingsJson = | ||
(json['data'] as Iterable).first as Map<String, dynamic>; | ||
final settings = TwitchChatSettings.fromJson(settingsJson); | ||
|
||
expect(settings.broadcasterId, '713936733'); | ||
expect(settings.slowMode, false); | ||
expect(settings.slowModeWaitTime, isNull); | ||
expect(settings.followerMode, true); | ||
expect(settings.followerModeDuration, 0); | ||
expect(settings.subscriberMode, false); | ||
expect(settings.emoteMode, false); | ||
expect(settings.uniqueChatMode, false); | ||
expect(settings.nonModeratorChatDelay, true); | ||
expect(settings.nonModeratorChatDelayDuration, 4); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"broadcaster_id": "713936733", | ||
"slow_mode": false, | ||
"slow_mode_wait_time": null, | ||
"follower_mode": true, | ||
"follower_mode_duration": 0, | ||
"subscriber_mode": false, | ||
"emote_mode": false, | ||
"unique_chat_mode": false, | ||
"non_moderator_chat_delay": true, | ||
"non_moderator_chat_delay_duration": 4 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"set_id": "vip", | ||
"versions": [ | ||
{ | ||
"id": "1", | ||
"image_url_1x": "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/1", | ||
"image_url_2x": "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/2", | ||
"image_url_4x": "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/3" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters