From f7187b04786b1c7a6ec09ae02c4027935f3805a1 Mon Sep 17 00:00:00 2001 From: Jonathan Keller Date: Thu, 2 Nov 2017 08:26:36 -0700 Subject: [PATCH] Fix deprecation warnings --- Sources/SwiftChatSE/ChatListener.swift | 16 ++++++++-------- Sources/SwiftChatSE/ChatRoom.swift | 2 +- Sources/SwiftChatSE/CommandPrivilege.swift | 2 +- Sources/SwiftChatSE/Utilites.swift | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Sources/SwiftChatSE/ChatListener.swift b/Sources/SwiftChatSE/ChatListener.swift index 837d3eb..d069336 100644 --- a/Sources/SwiftChatSE/ChatListener.swift +++ b/Sources/SwiftChatSE/ChatListener.swift @@ -154,7 +154,7 @@ open class ChatListener { for usageComponent in availableUsageComponents { for component in availableComponents { let distance = Levenshtein.distanceBetween(usageComponent, and: component) - let componentScore = min(distance, usageComponent.characters.count) + let componentScore = min(distance, usageComponent.count) if componentScore < bestMatch?.score ?? Int.max { bestMatch = (score: componentScore, component: component, usageComponent: usageComponent) @@ -176,13 +176,13 @@ open class ChatListener { } for _ in args { if !availableComponents.isEmpty { - score += availableComponents.first!.characters.count / 3 + score += availableComponents.first!.count / 3 availableComponents.removeFirst() } } for component in (availableComponents + availableUsageComponents) { - score += component.characters.count + score += component.count } commandScores[usage] = score @@ -200,7 +200,7 @@ open class ChatListener { $0 != "*" && $0 != "..." }.joined(separator: " ") - if score <= Int(ceil(Float(commandCharacters.characters.count)/2.0)) && score < (lowest?.score ?? Int.max) { + if score <= Int(ceil(Float(commandCharacters.count)/2.0)) && score < (lowest?.score ?? Int.max) { lowest = (command, score) } } @@ -216,10 +216,10 @@ open class ChatListener { open func processMessage(_ room: ChatRoom, message: ChatMessage, isEdit: Bool) { let lowercase = message.content.lowercased() - let shortName = String(name.characters[ - name.characters.startIndex.. Void)? = nil) { - if message.characters.count == 0 { + if message.count == 0 { return } messageQueue.append((message, completion)) diff --git a/Sources/SwiftChatSE/CommandPrivilege.swift b/Sources/SwiftChatSE/CommandPrivilege.swift index 758157b..3bcae93 100644 --- a/Sources/SwiftChatSE/CommandPrivilege.swift +++ b/Sources/SwiftChatSE/CommandPrivilege.swift @@ -56,7 +56,7 @@ open class CommandPrivilege: Command { let cleanedName = chatUser.name.replacingOccurrences(of: " ", with: "").lowercased() if chatUser.id == Int(user) || cleanedName == user.lowercased() || - (user.hasPrefix("@") && cleanedName == String(user.lowercased().characters.dropFirst())) || + (user.hasPrefix("@") && cleanedName == String(user.lowercased().dropFirst())) || chatUser.id == idFromURL { targetUser = chatUser diff --git a/Sources/SwiftChatSE/Utilites.swift b/Sources/SwiftChatSE/Utilites.swift index a06e6b5..05ce039 100644 --- a/Sources/SwiftChatSE/Utilites.swift +++ b/Sources/SwiftChatSE/Utilites.swift @@ -83,9 +83,9 @@ public func makeTable(_ heading: [String], contents: [String]...) -> String { var tableWidth = 0 for col in 0..