I'm hoping to recycle and improve upon this for some other future projects, where mobile event notifications would be nice. As with any project there were a few hiccups, but I was able to overcome them at the level needed for this one-off project. I'm pretty happy with how easily this came together. A quick trip down to the shelter and my relative now has their new dog! I suspect the shelter was not expecting that someone was creating a bot to let them "snipe" the dog before someone else adopted it. Success □Īfter a few days I suddenly heard a ping on my phone and saw a message from my bot that the dog's adoption status was now "Available". In the future I plan to do what I'm told is the "correct" way to do this and run the script via systemd, but that's for another post. I ended up with a hacky workaround by setting the XDG_RUNTIME_DIR environmental variable explicitly. Sending messages as my normal user initially didn't work running this script via cron. Status= `python $HOME/dog/status_check.py ` if then echo $timestamp: $status | keybase chat send mybotĮlse echo $status | keybase -home=/path/to/mybotshomedir chat send roycoding #! /bin/bash export XDG_RUNTIME_DIR=/run/user/1000 To solve this I put logic into my script to send the current "unavailable" status messages from my normal user and any other status messages as my bot user, thus triggering a notification.įinally I set the script to run every 15 minutes via cron. I now had notifications working, which is great, but on the other hand, I didn't want a notification for non-interesting events (while still wanting to know that the checks were occurring). KEYBASE BOTS UPDATEI'll update this post if I find and fix the root issue. KEYBASE BOTS FULLThe simplest workaround I found was to create the bot's directory with the full path and always use that □ Initially I had specified the bot's directory via a relative path like ~/mybotshomedir, but this resulted in buggy behavior. help on global options can be found via keybase help advanced. my bot) is messaging me, I will get a notification on my desktop and phone, depending on my client notification preferences □!! Keybase -home=/path/to/mybotshomedir chat send roycoding "Hello! " To send a chat message to another Keybase user, you simply do something like this: Keybase has a pretty decent desktop GUI chat client and corresponding mobile apps, but you can also use the command line API to do pretty much everything you can do in the apps (plus a lot more). I wanted to see if it would be possible to easily create a script that would send me an alert via keybase chat to let me know when the status of the dog had changed. Keybase is particularly interesting if you like command line interfaces, as it is designed to be very unix-y. KEYBASE BOTS FREE(Keybase is not without controversy, in particular its publicity scheme around giving away free cryptocurrency and later being purchased by Zoom.) For those of you not familiar with Keybase, it's a company that provides services centered on end-to-end encryption, specifically Slack-style chat, Dropbox-style file storage, and encrypted git repos, while also serving as an identity / encryption key directory. But the question I didn't quite know the answer to, was how I could easily create alerts (in particular on my phone) when the dog's adoption status changed. I could then run this periodically via cron. text if status = 'Not Available - Pending': Import requests from bs4 import BeautifulSoup as bs url = r = requests. Scraping the webpage was straight-forward, I used just a few throwaway lines of Python with requests to fetch the page and Beautiful Soup to extract the specific piece of text I wanted. So naturally I decided to write a script to scrape the webpage with the dog's status and alert me when the status changed to "available for adoption". Of course checking the web and all is doable, but why do that when we have perfectly good computers designed to do exactly that kind of thing. That basically meant we could call the shelter to check the status or keep checking the shelter's website. The problem was that the dog was not yet available for adoption, as the shelter was still waiting some amount of time in the event that the dog's owner would claim it. Not just any dog, but a specific puppy at an animal shelter in town. Recently one of my relatives really wanted a dog. Notifications with Keybase: You get a puppy!Ģ2 July 2020 - This is a post on my blog.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |