#!/usr/bin/env python

from string import Template, join

from chalicelib.resetter import launch

from chalice import Chalice

app = Chalice(app_name='resetter')


@app.route('/',methods=['GET'])
def index():
	print "starting"
	try:
		team = app.current_request.query_params['text']
		if team == '':
			team = 'WSH'
	except:
		team = 'WSH'
	print "getting for team " + team
	retList = launch(team,True)
	print "we got a return: " + str(retList)
	if len(retList) == 1:
		return { "response_type": "in_channel", "text": retList[0] }
	else:
		return { "response_type": "in_channel", "text": join(retList," ") }


@@ -468,76 +468,213 @@
 %0A%09%09r
-eturn %7B %22response_type%22: %22in_channel%22, %22text%22: retList%5B0%5D %7D%0A%09else:%0A%09
+text = retList%5B0%5D%0A%09else:%0A%09%09rtext = join(retList,%22 %22)%0A%09%0A%09if rtext.startswith(%22I'm sorry, I didn't recognize team%22):%0A%09%09rtext = rtext.replace(%22I'm sorry, I didn't recognize team%22,%22I'm sorry, I can't reset%22)%0A%0A
 %09ret
@@ -722,25 +722,12 @@
 t%22: 
-join(retList,%22 %22)
+rtext
  %7D%0A
-%0A

rephrase for funsies