Skip to content

expnch/sms-snail-racing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMS-Powered Snail Racing

License: CC0-1.0 made-with-python

Watch and cheer (by text) as 3 brave snails fight for dominance of the racetrack. Cheering for a snail encourages it to move faster, but eventually they get distracted and slow down (so keep cheering!).

Entry for Zipwhip Hackathon 2020.

Countdown to the race

Snail race in progress

Zippy and Wanda tie for victory

Run

Requirements

  • Docker Compose
  • Zipwhip API phone number and session key (used for inbound SMS)
  • Ngrok.io authentication token (used for proxying webhook to local machine)

Setup and operation

Create env.sh:

export ZW_PHONE_NUMBER="<your ZW phone number>"
export ZW_SESSION_KEY="<your key>"
export NGROK_AUTH_TOKEN="<your token>"

or set the values in your shell manually. Run tools/start.sh.

Open src/frontend/index.html in a browser to view.

Control the game state by connecting to Redis and publishing to the commands channel, e.g.:

from redis import Redis

r = Redis()
r.publish('commands', 'next')

Design

Docker Compose is used to run 4 components:

  1. Redis: used for pub/sub channels and storing game state.
  2. Controller: manages game state and listens for events on Redis pub/sub.
  3. Sockets: asynchronous Websockets server that publishes game state changes to connected clients.
  4. Hooks: registers Ngrok endpoint as a webhook in the Zipwhip API, then processes incoming webhook data.

The user interface is a Javascript app that connects to the (local) Websockets server and redraws an HTML canvas with updates to the game state. Cheers and announcments are 'rendered' with CSS animations.

To-do

  • Send phone number to front-end dynamically
  • Delete webhook on registration on shutdown
  • Customizable snail names
  • Better admin interface than publishing to Redis stream

About

Zipwhip Hackathon 2020 entry

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •