Skip to content

Commit

Permalink
Update for Latest Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoodwin committed Aug 23, 2017
1 parent 599888f commit f4abe9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions IRC/IRC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class IRCChannel {
self.server = server
}


func receive(_ text: String) {
if let delegate = self.delegate {
delegate.didRecieveMessage(self, message: text)
Expand Down
8 changes: 4 additions & 4 deletions IRC/IRCServerInputParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ struct IRCServerInputParser {

if message.hasPrefix(":") {
let firstSpaceIndex = message.index(of: " ")!
let source = message.substring(to: firstSpaceIndex)
let rest = message.substring(from: firstSpaceIndex).trimmingCharacters(in: .whitespacesAndNewlines)
let source = message[..<firstSpaceIndex]
let rest = message[firstSpaceIndex...].trimmingCharacters(in: .whitespacesAndNewlines)
print(source)

if rest.hasPrefix("PRIVMSG") {
let remaining = rest.substring(from: rest.index(message.startIndex, offsetBy: 8))
let remaining = rest[rest.index(message.startIndex, offsetBy: 8)...]

if remaining.hasPrefix("#") {
let split = remaining.components(separatedBy: ":")
Expand All @@ -33,7 +33,7 @@ struct IRCServerInputParser {
}
} else if rest.hasPrefix("JOIN") {
let user = source.components(separatedBy: "!")[0].trimmingCharacters(in: CharacterSet(charactersIn: ":"))
let channel = rest.substring(from: rest.index(message.startIndex, offsetBy: 5)).trimmingCharacters(in: CharacterSet(charactersIn: "# "))
let channel = rest[rest.index(message.startIndex, offsetBy: 5)...].trimmingCharacters(in: CharacterSet(charactersIn: "# "))
return .joinMessage(user: user, channel: channel)
} else{
let server = source.trimmingCharacters(in: CharacterSet(charactersIn: ": "))
Expand Down

0 comments on commit f4abe9c

Please sign in to comment.