dumbdumb

package module
v0.0.0-...-c756553 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2016 License: GPL-2.0 Imports: 5 Imported by: 0

README

dumbdumb

Makes dumbphones smart(er). Service that accepts text message queries via emails to built-in SMTP server, delegates to the appropriate APIs to gather information and responds succinctly via text messages (email) to the sender.

End-user Interface

"Weather" handler

Provides weather forcast for today, tonight, and tomorrow via three text messages.

[Ww]eather <town descriptor>

Example query:

weather boston, ma
"Find" handler

Finds the closest matching place given an open-ended query and returns information about it.

[Ff]ind <query>

Example query:

Find thrift store west roxbury, ma

Example response:

Savers
Phone: 1 617-323-8231
Addr: 1230 Veterans of Foreign Wars Pkwy, West Roxbury, MA
Open now: yes
"Translate" handler

Translates a message from a source to target language.

[Tt]ranslate <src-lang> -> <target-lang> <message>

Example query:

Translate es -> en hola

Example response:

[es] -> [en]: Hello

Prerequisites

  • Server with port 25 exposed to public, with DNS A-record or MX-record pointing to it
  • Mandrill (MailChimp) account and API key handy, and hostname for above server verified as a sender in the Mandrill interface (Hint: start up the dumbdumb service and watch the output after you've requested your Mandrill verification email.)
  • Weather Underground account and API key
  • Google Cloud Platform API key with Places and Translate services enabled

Installation (Ubuntu server)

These are steps to install, tested on an ubuntu 14.04 server.

  1. Install required packages and Golang:
sudo apt-get update
sudo apt-get install -y git mercurial curl
sudo curl https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz \
  | tar -C /usr/local -xz
  1. Set GOPATH and ensure it is on PATH:
echo "export GOPATH=\$HOME/go" >> $HOME/.bash_profile
echo "export PATH=\$PATH:/usr/local/go/bin:\$HOME/go/bin" >> $HOME/.bash_profile
  1. Clone this repo into $GOPATH/src/github.com/davemt/dumbdumb

  2. Fetch dependencies and install the service entry point script:

cd $GOPATH/src/github.com/davemt/dumbdumb
go get ./...
cd dumbdumb && go install

Running the service

Ensure all required environment variables are set (see settings.sh.example).

Start up service with dumbdumb (requires $GOPATH/bin to be on $PATH).

It is not a daemon so you'll need to do any detaching or output redireciton on your own.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	HandleRequest(request Request) (err error)
}

Handlers take a request string, handle the request, and generate some output to be sent back to the requestor.

type Request

type Request interface {
	GetPayload() (payload string)
	SendOutput(output string) (err error)
}

Stores the payload of a request, and provides the mechanism for sending the response output back to the requestor. Each request implementation is coupled with a particular Listener implementation.

type RequestListener

type RequestListener interface {
	Listen(incoming chan Request)
}

Listeners provide an interface for incoming requests to be submitted. The listener sends requests to the incoming channel.

type Server

type Server struct {
	// contains filtered or unexported fields
}

The Server is responsible for initializing a set of configured listeners which listen for incoming requests. Requests are routed to configured handlers based on the payload of the request.

func NewServer

func NewServer() *Server

func (*Server) AddHandler

func (s *Server) AddHandler(pattern string, handler Handler)

func (*Server) AddListener

func (s *Server) AddListener(l RequestListener)

func (*Server) HandleRequest

func (s *Server) HandleRequest(request Request)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

Begin listening for and handling incoming requests.

func (*Server) RouteRequest

func (s *Server) RouteRequest(request string) (*Handler, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL