Skip to content

Commit

Permalink
Merge pull request #28 from pureooze/ushamim/notice-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pureooze authored Oct 14, 2023
2 parents 64b92eb + 7a1fe27 commit b924231
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ In order to connect you need to create an `appsettings.json` file in the root of
WIP

### Notice
WIP
[NOTICE Twitch API](https://dev.twitch.tv/docs/irc/tags/#notice-tags)

[NoticeMsg Type](https://github.com/pureooze/TwitchEverywhere/blob/main/TwitchEverywhere/Types/NoticeMsg.cs)

| Field | Support |
|--------------|---------|
| MsgId ||
| TargetUserId ||

### RoomState
WIP
Expand Down
18 changes: 9 additions & 9 deletions TwitchEverywhere.UnitTests/TwitchConnectorTests/NoticeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Message message

switch( message.MessageType ) {
case MessageType.Notice: {
Notice msg = (Notice)message;
Notice? expectedPrivMessage = (Notice)expectedMessage;
NoticeMsg msg = (NoticeMsg)message;
NoticeMsg? expectedPrivMessage = (NoticeMsg)expectedMessage;
NoticeMessageCallback( msg, expectedPrivMessage );
break;
}
Expand Down Expand Up @@ -67,20 +67,20 @@ Message message
}

private void NoticeMessageCallback(
Notice notice,
Notice? expectedNoticeMessage
NoticeMsg noticeMsg,
NoticeMsg? expectedNoticeMessage
) {
Assert.That( notice.MsgId, Is.EqualTo( expectedNoticeMessage?.MsgId ), "MsgId was not equal to expected value");
Assert.That( notice.TargetUserId, Is.EqualTo( expectedNoticeMessage?.TargetUserId ), "TargetUserId was not equal to expected value");
Assert.That( notice.MessageType, Is.EqualTo( expectedNoticeMessage?.MessageType ), "MessageType was not equal to expected value");
Assert.That( noticeMsg.MsgId, Is.EqualTo( expectedNoticeMessage?.MsgId ), "MsgId was not equal to expected value");
Assert.That( noticeMsg.TargetUserId, Is.EqualTo( expectedNoticeMessage?.TargetUserId ), "TargetUserId was not equal to expected value");
Assert.That( noticeMsg.MessageType, Is.EqualTo( expectedNoticeMessage?.MessageType ), "MessageType was not equal to expected value");
}

private static IEnumerable<TestCaseData> NoticeMessages() {
yield return new TestCaseData(
new List<string> {
$"@msg-id=delete_message_success :tmi.twitch.tv NOTICE #channel :The message from foo is now deleted."
}.ToImmutableList(),
new Notice(
new NoticeMsg(
MsgId: "delete_message_success",
TargetUserId: ""
)
Expand All @@ -90,7 +90,7 @@ private static IEnumerable<TestCaseData> NoticeMessages() {
new List<string> {
$"@msg-id=whisper_restricted;target-user-id=12345678 :tmi.twitch.tv NOTICE #channel :Your settings prevent you from sending this whisper."
}.ToImmutableList(),
new Notice(
new NoticeMsg(
MsgId: "whisper_restricted",
TargetUserId: "12345678"
)
Expand Down
2 changes: 1 addition & 1 deletion TwitchEverywhere/Implementation/TwitchConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ string response
string targetMessageId = GetValueFromResponse( response, MsgIdPattern );
string targetUserId = GetValueFromResponse( response, TargetUserIdPattern );

return new Notice(
return new NoticeMsg(
MsgId: targetMessageId,
TargetUserId: targetUserId
);
Expand Down
3 changes: 2 additions & 1 deletion TwitchEverywhere/TwitchEverywhere.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
<Version>0.1.1</Version>
<Version>0.1.2</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<PackRelease>true</PackRelease>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TwitchEverywhere.Types;

public record Notice(
public record NoticeMsg(
string MsgId,
string TargetUserId
) : Message ( MessageType.Notice );

0 comments on commit b924231

Please sign in to comment.