Skip to content

Commit 658f69f

Browse files
committed
IFTTT tweaks
Follows up on #4
1 parent 0e8c69e commit 658f69f

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

hackjohn.py

+25-12
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def get_trailhead_df():
119119
output_path.write_text(text)
120120
print(f'output has changed: {output_has_changed}')
121121

122+
# determine whether to notify
123+
notify = not space_df.empty and output_has_changed and min_report_date <= report_date
124+
122125
## Notifications using MiddlemanBot
123126
# Uses https://github.com/n1try/telegram-middleman-bot
124127

@@ -136,31 +139,41 @@ def get_trailhead_df():
136139
'text': text,
137140
'origin': 'hackjohn',
138141
}
139-
if enable_middleman and not space_df.empty and output_has_changed and min_report_date <= report_date:
142+
if notify and enable_middleman:
140143
mmb_response = requests.post(mmb_url, json=payload)
141144
print('middleman status code', mmb_response.status_code)
142145
print(mmb_response.text)
143146

144147
## Notifications using IFTTT
145148

146-
# Set enable_ifttt to True to receive IFTTT notification
149+
# Set enable_ifttt to True and personalize ifttt_key to receive IFTTT notifications
147150
enable_ifttt = False
148151
event_name = 'hackjohn'
149-
ifttt_key = 'cJLFuy0CHPBwK0wqndI2g9'
152+
ifttt_key = 'replace-with-ifttt-key'
150153

151-
# Create you own IFTTT (https://ifttt.com/create)
152-
# Select webhooks for this and select receive a web trigger
153-
# Set event name to match event_name variable above
154-
# Create a that to respond to the event (IFTTT rich notifications allow click to call options to the reservation line.) You can add 3 values (specified below).
155-
# Go to https://ifttt.com/maker_webhooks and click on documentation, copy & paste your key into the ifttt_key variable above
154+
"""
155+
## IFTTT Setup Instructions
156+
157+
Create you own IFTTT at https://ifttt.com/create.
158+
Select webhooks for this and select "Receive a web request".
159+
Set event name to match `event_name` variable above.
160+
Create a that to respond to the event.
161+
For example, select "Send a rich notification from the IFTTT app"
162+
(IFTTT rich notifications allow click to call options to the reservation line).
163+
You can add 3 values (specified below).
164+
For example, use `{{Value1}}` for the message template and `tel: {{Value2}}` as link action.
165+
Go to https://ifttt.com/maker_webhooks and click on documentation,
166+
copy & paste your key into the `ifttt_key` variable above.
167+
"""
156168

157169
ifttt_hostname = 'https://maker.ifttt.com'
158170
ifttt_url = ifttt_hostname + '/trigger/' + event_name + '/with/key/' + ifttt_key
159171

160-
if enable_ifttt and not space_df.empty and output_has_changed and min_report_date <= report_date:
161-
report = {}
162-
report["value1"] = text
163-
report["value2"] = '209-372-0740'
172+
if notify and enable_ifttt:
173+
report = {
174+
"value1": text,
175+
"value2": '209-372-0740',
176+
}
164177
response = requests.post(ifttt_url, data=report)
165178
print('ifttt status code', response.status_code)
166179
print(response.text)

0 commit comments

Comments
 (0)