File tree 2 files changed +13
-11
lines changed
2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -81,14 +81,7 @@ public class D2Receiver: Receiver {
81
81
MentionD2Handler ( conversator: FollowUpConversator ( messageDB: messageDB) ) ,
82
82
MentionSomeoneHandler ( ) ,
83
83
MessagePreviewHandler ( configuration: _messagePreviewsConfiguration) ,
84
- TriggerReactionHandler {
85
- guard let city = cityConfiguration. city else { throw ReactionTriggerError . other ( " No city specified " ) }
86
- return OpenWeatherMapQuery ( city: city) . perform ( )
87
- . mapCatching {
88
- guard let emoji = $0. emoji else { throw ReactionTriggerError . other ( " No weather emoji " ) }
89
- return emoji
90
- }
91
- } ,
84
+ TriggerReactionHandler ( cityConfiguration: _cityConfiguration) ,
92
85
CountToNHandler ( ) ,
93
86
UniversalSummoningHandler ( hostInfo: hostInfo) ,
94
87
HaikuHandler ( configuration: _haikuConfiguration, inventoryManager: inventoryManager) ,
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ public struct TriggerReactionHandler: MessageHandler {
15
15
16
16
public init (
17
17
dateSpecificReactions: Bool = true ,
18
- weatherEmojiProvider: @escaping ( ) throws -> Promise < String , any Error >
18
+ weatherReactions: Bool = true ,
19
+ cityConfiguration: AutoSerializing < CityConfiguration >
19
20
) {
20
21
self . init ( triggers: [
21
22
. init( keywords: [ " hello " ] , emoji: " 👋 " ) ,
@@ -60,8 +61,16 @@ public struct TriggerReactionHandler: MessageHandler {
60
61
}
61
62
}
62
63
63
- // React with the weather
64
- return try weatherEmojiProvider ( )
64
+ if weatherReactions {
65
+ guard let city = cityConfiguration. wrappedValue. city else { throw ReactionTriggerError . other ( " No city specified " ) }
66
+ return OpenWeatherMapQuery ( city: city) . perform ( )
67
+ . mapCatching {
68
+ guard let emoji = $0. emoji else { throw ReactionTriggerError . other ( " No weather emoji " ) }
69
+ return emoji
70
+ }
71
+ }
72
+
73
+ throw ReactionTriggerError . other ( " No good morning/evening reaction configured " )
65
74
}
66
75
}
67
76
] )
You can’t perform that action at this time.
0 commit comments