Skip to content

Commit

Permalink
Merge pull request #12 from SOBotics/filter_refactor --autoupdate
Browse files Browse the repository at this point in the history
finished the filter refactor (not thoroughly tested)
  • Loading branch information
double-fault committed Apr 25, 2017
2 parents 54d75dc + c070536 commit e97cf34
Show file tree
Hide file tree
Showing 9 changed files with 471 additions and 397 deletions.
8 changes: 4 additions & 4 deletions Sources/BackgroundTasks.swift
Expand Up @@ -16,12 +16,12 @@ func save(rooms: [ChatRoom]) {
handleError(error, "while saving the user database")
}
do {
try filter.saveUsernameBlacklist()
try filter.filterBlacklistedUsernames.saveUsernameBlacklist()
} catch {
handleError(error, "while saving the username blacklist")
}
do {
try filter.saveReports()
try filter.reports.saveReports()
} catch {
handleError(error, "while saving reports")
}
Expand Down Expand Up @@ -80,15 +80,15 @@ func handleInput(input: String, rooms: [ChatRoom], listener: ChatListener) {
func shutDown(reason: ChatListener.StopReason, rooms: [ChatRoom]) {
var shouldReboot = reason == .reboot

filter.stop()
filter.postFetcher.stop()

//Wait for pending messages to be posted.
for room in rooms {
while !room.messageQueue.isEmpty {
sleep(1)
}
}
while filter != nil && !(filter.ws.state == .disconnected || filter.ws.state == .error) {
while filter != nil && !(filter.postFetcher.ws.state == .disconnected || filter.postFetcher.ws.state == .error) {
sleep(1)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/CommandCheckPost.swift
Expand Up @@ -38,7 +38,7 @@ class CommandCheckPost: Command {
reply("Could not fetch the question!")
return
}
let result = try filter.checkAndReportPost(question)
let result = try filter.postFetcher.postClassifier.checkAndReportPost(question)
switch result {
case .alreadyClosed:
reply ("That post was caught by the filter but is already closed.")
Expand Down

0 comments on commit e97cf34

Please sign in to comment.