Skip to content

Commit

Permalink
Merge pull request #23 from TORISOUP/add_name
Browse files Browse the repository at this point in the history
ChatにName要素を追加
  • Loading branch information
TORISOUP authored Sep 6, 2023
2 parents 5b76aeb + 063dc55 commit de9d7fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
42 changes: 22 additions & 20 deletions Assets/TORISOUP/NicoliveClient/Plugins/Comment/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public struct Chat : IEquatable<Chat>
/// <value></value>
public int Score { get; private set; }

/// <summary>
/// コメント投稿者の名前
/// </summary>
public string Name { get; private set; }

public Chat(string thread,
long vpos,
long date,
Expand All @@ -73,7 +78,8 @@ public Chat(string thread,
string content,
int no,
int roomId,
int score) : this()
int score,
string name)
{
Thread = thread;
Vpos = vpos;
Expand All @@ -86,29 +92,15 @@ public Chat(string thread,
No = no;
RoomId = roomId;
Score = score;
}

/// <summary>
/// プレミアム会員であるか
/// </summary>
public bool IsPremium
{
get { return (Premium & 1) != 0; }
}

/// <summary>
/// 運営コメント または /から始まる特殊なメッセージであるか
/// </summary>
public bool IsStaff
{
get { return (Premium & 2) != 0; }
Name = name;
}

public bool Equals(Chat other)
{
return Thread == other.Thread && Vpos == other.Vpos && Date == other.Date && Mail == other.Mail &&
UserId == other.UserId && Premium == other.Premium && Anonymity == other.Anonymity &&
Content == other.Content && No == other.No && RoomId == other.RoomId && Score == other.Score;
Content == other.Content && No == other.No && RoomId == other.RoomId && Score == other.Score &&
Name == other.Name;
}

public override bool Equals(object obj)
Expand All @@ -130,8 +122,15 @@ public override int GetHashCode()
hashCode.Add(No);
hashCode.Add(RoomId);
hashCode.Add(Score);
hashCode.Add(Name);
return hashCode.ToHashCode();
}

public override string ToString()
{
return
$"{nameof(Thread)}: {Thread}, {nameof(Vpos)}: {Vpos}, {nameof(Date)}: {Date}, {nameof(Mail)}: {Mail}, {nameof(UserId)}: {UserId}, {nameof(Premium)}: {Premium}, {nameof(Anonymity)}: {Anonymity}, {nameof(Content)}: {Content}, {nameof(No)}: {No}, {nameof(RoomId)}: {RoomId}, {nameof(Score)}: {Score}, {nameof(Name)}: {Name}";
}
}

[Serializable]
Expand All @@ -147,6 +146,7 @@ internal struct ChatDto : IEquatable<ChatDto>
public string content;
public int no;
public int score;
public string name;

public bool IsSuccess()
{
Expand All @@ -166,15 +166,16 @@ public Chat ToChat(int roomId)
content,
no,
roomId,
score
score,
name
);
}

public bool Equals(ChatDto other)
{
return thread == other.thread && vpos == other.vpos && date == other.date && mail == other.mail &&
user_id == other.user_id && premium == other.premium && anonymity == other.anonymity &&
content == other.content && no == other.no && score == other.score;
content == other.content && no == other.no && score == other.score && name == other.name;
}

public override bool Equals(object obj)
Expand All @@ -195,6 +196,7 @@ public override int GetHashCode()
hashCode.Add(content);
hashCode.Add(no);
hashCode.Add(score);
hashCode.Add(name);
return hashCode.ToHashCode();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/TORISOUP/NicoliveClient/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023.8.29
2023.9.6

0 comments on commit de9d7fa

Please sign in to comment.