Skip to content

Commit

Permalink
fix: clean up channel names before sending them over IRC
Browse files Browse the repository at this point in the history
  • Loading branch information
LosFarmosCTL committed Jan 22, 2024
1 parent 909cd59 commit e52e0a1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Sources/Twitch/Chat/ChatClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ public class ChatClient {
nonce: String? = nil
) async throws {
try await client.send(
message, in: channel, replyingTo: messageId, nonce: nonce)
message, in: cleanChannelName(channel), replyingTo: messageId,
nonce: nonce)
}

public func join(to channel: String) async throws {
try await client.join(to: channel)
try await client.join(to: cleanChannelName(channel))
}

public func joinAll(channels: String...) async throws {
for channel in channels { try await join(to: channel) }
for channel in channels { try await join(to: cleanChannelName(channel)) }
}

public func part(from channel: String) async throws {
try await client.part(from: channel)
try await client.part(from: cleanChannelName(channel))
}

private func cleanChannelName(_ channel: String) -> String {
return channel.lowercased().trimmingCharacters(in: ["#", " "])
}
}

0 comments on commit e52e0a1

Please sign in to comment.