Skip to content

Commit

Permalink
added returning-chatter in PRIVMSG
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Jun 17, 2022
1 parent 1211fb0 commit 8e8e4eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/TwitchIRC/IncomingMessage/PrivateMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public struct PrivateMessage: MessageWithBadges {
public var flags = [String]()
/// Whether it's the first time the user is sending a message.
public var firstMessage = Bool()
/// Not sure but probably whether or not the chatter
/// hasn't been chatting for a while in this channel, before this message.
public var returningChatter = Bool()
/// Not sure exactly what is this? usually empty.
public var messageId = String()
/// Message's id.
Expand Down Expand Up @@ -116,6 +119,7 @@ public struct PrivateMessage: MessageWithBadges {
self.emoteOnly = parser.bool(for: "emote-only")
self.flags = parser.array(for: "flags")
self.firstMessage = parser.bool(for: "first-msg")
self.returningChatter = parser.bool(for: "returning-chatter")
self.messageId = parser.string(for: "msg-id")
self.id = parser.string(for: "id")
self.crowdChantParentMessageId = parser.string(for: "crowd-chant-parent-msg-id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,37 @@ final class PrivateMessageTests: XCTestCase {
XCTAssertTrue(msg.replyParent == .init())
XCTAssertTrue(msg.parsingLeftOvers.isEmpty, "Non-empty parsing left-overs: \(msg.parsingLeftOvers)")
}

/// Tests where `returningChatter`.
func testParsedValues7() throws {
let string = "@badge-info=;badges=vip/1;color=#0000FF;display-name=flexvegapro3;emotes=;first-msg=0;flags=;id=9c3e3024-a4b4-493b-8668-96597be002ac;mod=0;returning-chatter=0;room-id=550217406;subscriber=0;tmi-sent-ts=1655439139118;turbo=0;user-id=705215697;user-type= :[email protected] PRIVMSG #novastark_7 :jajaja xD"

let msg: PrivateMessage = try TestUtils.parseAndUnwrap(string: string)

XCTAssertEqual(msg.channel, "novastark_7")
XCTAssertEqual(msg.message, "jajaja xD")
XCTAssertEqual(msg.badgeInfo, [])
XCTAssertEqual(msg.badges, ["vip/1"])
XCTAssertEqual(msg.bits, "")
XCTAssertEqual(msg.color, "#0000FF")
XCTAssertEqual(msg.displayName, "flexvegapro3")
XCTAssertEqual(msg.userLogin, "flexvegapro3")
XCTAssertEqual(msg.emotes, [])
XCTAssertEqual(msg.emoteOnly, false)
XCTAssertEqual(msg.flags, [])
XCTAssertEqual(msg.firstMessage, false)
XCTAssertEqual(msg.returningChatter, false)
XCTAssertEqual(msg.messageId, "")
XCTAssertEqual(msg.id, "9c3e3024-a4b4-493b-8668-96597be002ac")
XCTAssertEqual(msg.crowdChantParentMessageId, "")
XCTAssertEqual(msg.customRewardId, "")
XCTAssertEqual(msg.roomId, "550217406")
XCTAssertEqual(msg.tmiSentTs, 1655439139118)
XCTAssertEqual(msg.clientNonce, "")
XCTAssertEqual(msg.userId, "705215697")
XCTAssertTrue(msg.replyParent == .init())
XCTAssertTrue(msg.parsingLeftOvers.isEmpty, "Non-empty parsing left-overs: \(msg.parsingLeftOvers)")
}
}

// MARK: - PrivateMessage.ReplyParent Equatable (basically)
Expand Down

0 comments on commit 8e8e4eb

Please sign in to comment.