def processAddRestaurant(tweet, twitter):

	contents = tweet['text']
	m = re.search('restaurant ([\w\s\',]+)$', contents)
	if m:
		print("adding restaurant: " + m.group(1))

		new_restaurant = restaurant.Restaurant.fromName(m.group(1))
		did_add_restaurant = restaurant_manager.addRestaurant(new_restaurant)

		if did_add_restaurant:
			restaurant_manager.saveRestaurants()
			replyToTweet(tweet, "Ooo, good choice, I'd be salvating if I was a human", twitter)
		else:
			replyToTweet(tweet, "So good you want to add it twice?", twitter)

	else:
		print("Error passsing match " + contents)
		replyToTweet(tweet, "Sorry, that isn't a valid restaurant command", twitter)	
	elif 'remove' in tweetContent:
		processRemoveTweet(mention, twitter)
	elif 'restaurant' in tweetContent:
		processAddRestaurant(mention, twitter)
	else:
		processUnknownTweet(mention, twitter)

	status_id = long(mention['id'])
	if status_id > latest_status_id:
		latest_status_id = status_id
		with open(latest_status_id_file, 'w') as f:
			f.write(str(latest_status_id))


chosen_restaurant = restaurant_manager.pickRestaurant()
print("Chosen restaurant: " + str(chosen_restaurant))

chosen_restaurant.visit()

restaurant_manager.saveRestaurants()

composeRestaurantTweet(chosen_restaurant, person_manager, twitter)


# TODO: Respond to requests to organise pub
# TODO: Allow people to opt-in/out of lunch/pub individually

#t = Twitter(auth = OAuth(token, token_key, con_secret, con_secret_key))


#t.statuses.update(status = "Test status")
def writeOutRestaurants(restaurant_manager):
	restaurant_manager.addRestaurant(restaurant.Restaurant.fromName("Cape of Good Hope"))
	restaurant_manager.addRestaurant(restaurant.Restaurant.fromName("Cocos"))	
	restaurant_manager.saveRestaurants()