#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
 for amimoto_alexa
"""


import lamvery
import twitter
from helpers import *
from wpapi import *
from debugger import *


def collect_impression(intent, session):
    """Collect impression and finalize session
    """
    session_attributes = build_session_attributes(session)
    card_title = "Impression"

    debug_logger(session)
    speech_output = "Thank you! You can see impressions on twitter and ,A MI MO TO Blog." \
                    "Have a nice day! "

    impression = intent['slots']['UserImpression']['value']

    tw_ck, tw_cs, tw_ak, tw_as = lamvery.secret.get('tw_keys').split(',')
    tw_api = twitter.Api(consumer_key=tw_ck,
                         consumer_secret=tw_cs,
                         access_token_key=tw_ak,
                         access_token_secret=tw_as)

# todo: store session summary to firehose
    debug_logger(session['user']['userId'])

    # check right user?
    # if lamvery.secret.get('dc_id') == session['user']['userId']:
    comment_to_wordpress(session_attributes['VisitorName'], impression)
    if session_attributes['twitter_id']:
        tw_post = impression + " by " + session_attributes['twitter_id']
    else:
        tw_post = impression

    tw_api.PostUpdate(tw_post)



    should_end_session = True
    return build_response(session_attributes, build_speechlet_response(
        card_title, speech_output, None, should_end_session))

@@ -98,16 +98,26 @@
 twitter%0A
+import re%0A
 from hel
@@ -969,13 +969,34 @@
     
-# if 
+amimoto_user = re.compile(
 lamv
@@ -1022,12 +1022,36 @@
 id')
- == 
+)%0A    if amimoto_user.match(
 sess
@@ -1071,18 +1071,46 @@
 userId'%5D
+)
 :%0A
+        # post actions%0A    
     comm
@@ -1169,24 +1169,28 @@
 impression)%0A
+    
     if sessi
@@ -1218,16 +1218,20 @@
 r_id'%5D:%0A
+    
         
@@ -1295,16 +1295,20 @@
 er_id'%5D%0A
+    
     else
@@ -1309,16 +1309,20 @@
   else:%0A
+    
         
@@ -1343,16 +1343,20 @@
 ession%0A%0A
+    
     tw_a

check userid