Skip to content

Commit

Permalink
Handle even more good morning and evening patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Nov 8, 2024
1 parent ccc20de commit 3985a4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import D2NetAPIs
import Utils
import Logging

nonisolated(unsafe) private let goodMorningOrEveningPattern = #/\b[gjm](?:j*[uü]+[ste]+n?|oo+d+)\s+(?:[gm](?:[oö]+(?:r+n+i+ng*|(?:r+[gj]+(?:e+|ä+h*)|i+)n)|ü+de+)|e+ve+ni+ng|a+be+nd|da+y|ta+g|n(?:a+ch|i+gh)t)\b/#.ignoresCase()
nonisolated(unsafe) private let goodMorningOrEveningPattern = #/\b[gjm](?:j*[uü]+[stde]+n?|o+d+n?)\s+(?:[gm](?:[oö]+(?:r+n+i+ng*|(?:r+[gj]+(?:e+|ä+h*)|i+)n)|ü+de+)|e+ve+ni+ng|a+be+nd|da+y|ta+g|n(?:a+ch|i+gh)t)\b/#.ignoresCase()
private let log = Logger(label: "D2Handler.TriggerReactionHandler")

public struct TriggerReactionHandler: MessageHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct TriggerReactionHandlerTests {
#expect(await messageTriggersWeather("Juten moin"))
#expect(await messageTriggersWeather("juuten morgen"))
#expect(await messageTriggersWeather("guten abend"))
#expect(await messageTriggersWeather("goodn abend"))
#expect(await messageTriggersWeather("juuten aaaabeend"))
// TODO: This one currently does not work, likely due to a compiler bug:
// https://github.com/swiftlang/swift/issues/77481
Expand All @@ -40,6 +41,8 @@ struct TriggerReactionHandlerTests {
#expect(await !messageTriggersWeather("Morning"))
#expect(await !messageTriggersWeather("Morgen"))
#expect(await !messageTriggersWeather("evening"))
#expect(await !messageTriggersWeather("gut"))
#expect(await !messageTriggersWeather("guten"))
}

private func messageTriggersWeather(_ content: String) async -> Bool {
Expand Down

0 comments on commit 3985a4d

Please sign in to comment.