Pedestrian Down (@PedDownYYC)
A Twitter bot and website collecting and tweeting pedestrian incidents reported by the @yyctransport Twitter account and OpenData Portal.
Unforunately the tweets and data from the OpenData Portal do not coincide in time or share any uniquely identifiable information, but using the intersection one can roughly correlate the data between the two public sources.
The initial version of this was a Twitter only bot that would quote any tweet from @yyctransport with the words: "ALERT" and "pedestrian" or "ped" but not cleared. In the tweet it mentions the number and tags #yycwalk.
Thanks to @yyctransport for reporting the incidents, and @RrrichardZach for the push to create the bot.
Since the bot is dependant on the @yyctransport team at the Traffic Management Centre tweeting, not all incidents are counted and reported. For the most accurate stats, please check with @CalgaryPolice. Incidents if viewed via camera, reported via 911, and affect traffic are tweeted. [1][2]
Even with this limitation, the purpose to show just how frequent incidents occur.
- Clone this repository
- Grab the dependencies via
go mod download
go build .
docker build -t peddown .
docker run peddown
The credentials for Twitter are read from the environment. If using the included systemd service file, add them there. If using Docker or something else to run them, please see Docker's instructions on managing environment variables.
-
Create the app using
flyctl launch
(Do NOT choose to deploy) -
Load the four environment variables in creds.example using
flyctl secrets
sed 's/export //g' creds | flyctl secrets import
-
Create the volume if necessary with
flyctl volume create peddown_data --region sea --size 1
-
Optionally restore the database with:
flyctl ssh sftp shell cd /data put peddown.db peddown.sqlite
-
Deploy the applicaton with
flyctl deploy
-
Monitor with
flyctl logs
Run a cron elsewhere to grab the file :( Maybe I'll investigate LiteFS in the future but that's a lot more work. Instead we'll set up a cron locally on my laptop to:
flyctl ssh sftp get /peddown.db peddown.db
cd ~/src/peddown.git
flyctl ssh sftp get /peddown.db peddown.db
source creds
~/src/peddown.git % go run tweetCollector.go -manual https://twitter.com/yyctransport/status/<ID>
flyctl ssh console -C 'mv /data/peddown.sqlite /data/peddown.sqlite.bk'
echo 'put peddown.db /data/peddown.sqlite' | flyctl ssh sftp shell
Run: go get -u && go mod tidy
Licensed with an MIT License