camply icon indicating copy to clipboard operation
camply copied to clipboard

Add slack notification support

Open matthazinski opened this issue 1 year ago • 2 comments

Verified camply configure and camply campsites work as expected:

root@b77775ee7240:~# camply configure
2022-07-24 22:34:28,067 [  CAMPLY]: camply, the campsite finder ⛺️
2022-07-24 22:34:28,068 [    INFO]: Running camply configuration.
2022-07-24 22:34:28,068 [    INFO]: This process generates a configuration file (https://github.com/juftin/camply/blob/main/example.camply)
2022-07-24 22:34:28,068 [    INFO]: Do not include quotes around values
2022-07-24 22:34:28,068 [    INFO]: To skip a configuration field or keep it as default, just press <Enter>.
PUSHOVER_PUSH_USER: Enables Pushover Notifications
Enter value for PUSHOVER_PUSH_USER: 
PUSHBULLET_API_TOKEN: Enables Pushbullet Notifications
Enter value for PUSHBULLET_API_TOKEN: 
SLACK_WEBHOOK: Enables Slack Notifications
Enter value for SLACK_WEBHOOK: https://hooks.slack.com/services/REDACTED/REDACTED/REDACTED
TELEGRAM_BOT_TOKEN: Enables Telegram Notifications
Enter value for TELEGRAM_BOT_TOKEN: 
TELEGRAM_CHAT_ID: Telegram Notification will be sent here
Enter value for TELEGRAM_CHAT_ID: 
EMAIL_TO_ADDRESS: Email Notifications will be sent here
Enter value for EMAIL_TO_ADDRESS: 
EMAIL_USERNAME: Email Authorization Login Username
Enter value for EMAIL_USERNAME: 
EMAIL_PASSWORD: Email Authorization Login Password
Enter value for EMAIL_PASSWORD: 
EMAIL_SMTP_SERVER: Email Authorization SMTP Server Address
Enter value for EMAIL_SMTP_SERVER (default: `smtp.gmail.com`): 
EMAIL_SMTP_PORT: Email Authorization SMTP Server Port
Enter value for EMAIL_SMTP_PORT (default: `465`): 
EMAIL_FROM_ADDRESS: Email Notifications Will Come From this Email
Enter value for EMAIL_FROM_ADDRESS (default: `[email protected]`): 
EMAIL_SUBJECT_LINE: Email Notifications Will Have This Subject Line
Enter value for EMAIL_SUBJECT_LINE (default: `Camply Notification`): 
PUSHOVER_PUSH_TOKEN: Pushover Notifications From Your Custom App (not required)
Enter value for PUSHOVER_PUSH_TOKEN: 
RIDB_API_KEY: Personal Recreation.gov API Key (not required)
Enter value for RIDB_API_KEY: 
Are you ready to publish this to a file at /home/camply/.camply [y/n]: y
Are you sure? [y/n]: y
2022-07-24 22:34:50,552 [    INFO]: `.camply` file written to machine: /home/camply/.camply
2022-07-24 22:34:50,552 [  CAMPLY]: Exiting camply 👋
matt@adipose:~/local/camply$ sudo docker run -e SLACK_WEBHOOK="https://hooks.slack.com/services/REDACTED/REDACTED/REDACTED" -it 6201c1a50b9b camply campsites --campground 272299 --start-date 2022-10-20 --end-date 2022-10-23 --nights 3 --notifications slack --continuous
2022-07-24 23:19:13,025 [  CAMPLY]: camply, the campsite finder ⛺️
2022-07-24 23:19:13,031 [    INFO]: 3 booking nights selected for search, ranging from 2022-10-20 to 2022-10-22
2022-07-24 23:19:13,032 [    INFO]: Searching for availabilities with 3 consecutive night stays.
2022-07-24 23:19:14,613 [    INFO]: 1 Matching Campgrounds Found
2022-07-24 23:19:14,614 [    INFO]: ⛰  Joshua Tree National Park, CA (#2782) - 🏕  Cottonwood Campground (Ca) (#272299)
2022-07-24 23:19:14,614 [    INFO]: Searching for campsites every 10 minutes. 
2022-07-24 23:19:14,614 [    INFO]: Notifications active via: <SilentNotifications>, <SlackNotifications>
2022-07-24 23:19:14,614 [    INFO]: Searching across 1 campgrounds
2022-07-24 23:19:15,123 [    INFO]: Metadata fetched for 59 campsites
2022-07-24 23:19:15,123 [    INFO]: Searching Cottonwood Campground (Ca), Joshua Tree National Park, CA (272299) for availability: October, 2022
2022-07-24 23:19:16,312 [    INFO]:     ⛺️      1396 total sites found in month of October
2022-07-24 23:19:17,480 [    INFO]: ⛺️ ⛺️ ⛺️ ⛺️ 2 Reservable Campsites Matching Search Preferences
2022-07-24 23:19:17,486 [    INFO]: 📅 Thu, October 20 🏕  2 sites
2022-07-24 23:19:17,487 [    INFO]:     ⛰️  Joshua Tree National Park, CA  🏕  Cottonwood Campground (Ca): ⛺ 2 sites
2022-07-24 23:19:17,488 [    INFO]:             🔗 https://www.recreation.gov/camping/campsites/103777 (3 nights)
2022-07-24 23:19:17,488 [    INFO]:             🔗 https://www.recreation.gov/camping/campsites/103817 (3 nights)
2022-07-24 23:19:17,488 [    INFO]: 2 New Campsites Found.
2022-07-24 23:19:17,978 [  CAMPLY]: Exiting camply 👋

Screenshot from 2022-07-24 16-16-14

matthazinski avatar Jul 24 '22 23:07 matthazinski

Exciting! I'll get a look at this soon. Thank you for the contribution

juftin avatar Jul 25 '22 00:07 juftin

Until I find a better solution, will you also bump the version @ camply/_version.py too?

juftin avatar Jul 25 '22 23:07 juftin

Hey @matthazinski last follow up here - I tidied up some of the linting errors and pushed this to main. Thank you very much for the contribution!

juftin avatar Aug 25 '22 03:08 juftin