File tree 1 file changed +7
-1
lines changed
Sources/D2Handlers/Message/Handler
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ public struct FactorialHandler: MessageHandler {
24
24
let `operator` = match. output. operator
25
25
let alpha = `operator`. count
26
26
let result = multifactorial ( operand, alpha)
27
+ let link : String ? = switch alpha {
28
+ case 1 : nil
29
+ case 2 : " https://en.wikipedia.org/wiki/Double_factorial "
30
+ default : " https://en.wikipedia.org/wiki/Double_factorial#Definitions "
31
+ }
32
+ let formattedOperator = link. map { " [ \( `operator`) ](< \( $0) >) " } ?? " \( `operator`) "
27
33
do {
28
- try await sink. sendMessage ( " \( operand) \( `operator` ) = \( result. isLessThanOrEqualTo ( Double ( Int . max) ) ? String ( Int ( result) ) : String ( result) ) " , to: channelId)
34
+ try await sink. sendMessage ( " \( operand) \( formattedOperator ) = \( result. isLessThanOrEqualTo ( Double ( Int . max) ) ? String ( Int ( result) ) : String ( result) ) " , to: channelId)
29
35
} catch {
30
36
log. warning ( " Could not send factorial message: \( error) " )
31
37
}
You can’t perform that action at this time.
0 commit comments