replyBearyChat :: (MonadIO m, MonadThrow m) => BearyChatRequest -> AppM m BearyChatResponse
replyBearyChat req = do
    bc <- getBearyChat
    let tokenStr = token (req :: BearyChatRequest)
    when (outgoingKey bc /= tokenStr) $
        throwM   $ ServiceException_ "BearyChat Token check failed"
    checkTimeOut $ ts req
    let msg      = text (req :: BearyChatRequest)
        echo     = T.strip $ fromMaybe msg $ T.stripPrefix (trigger_word req) msg
        saveReq  = do now <- getNow
                      insert $ EntityBearyChatMessage
                        tokenStr
                        (trigger_word     req)
                        echo
                        (millisToUTC $ ts req)
                        (subdomain        req)
                        (channel_name     req)
                        (user_name        req)
                        now
    runTrans saveReq
    return $ BearyChatResponse ("echo: " <> echo) Nothing
replyBearyChat :: (MonadIO m, MonadThrow m) => BearyChatRequest -> AppM m BearyChatResponse
replyBearyChat req = do
    bc <- getBearyChat
    let tokenStr = token (req :: BearyChatRequest)
    when (outgoingKey bc /= tokenStr) $
        throwM   $ ServiceException_ "BearyChat Token check failed"
    checkTimeOut $ ts req
    let msg      = text (req :: BearyChatRequest)
        echo     = T.strip $ fromMaybe msg $ T.stripPrefix (trigger_word req) msg
        saveReq  = do now <- getNow
                      insert $ EntityBearyChatMessage
                        tokenStr
                        (trigger_word     req)
                        echo
                        (millisToUTC $ ts req)
                        (subdomain        req)
                        (channel_name     req)
                        (user_name        req)
                        now
    runTrans saveReq
    return $ BearyChatResponse ("echo: " <> echo) Nothing
replyBearyChat req = do
    bc <- getBearyChat
    let tokenStr = token (req :: BearyChatRequest)
    when (outgoingKey bc /= tokenStr) $
        throwM   $ ServiceException_ "BearyChat Token check failed"
    checkTimeOut $ ts req
    let msg      = text (req :: BearyChatRequest)
        echo     = T.strip $ fromMaybe msg $ T.stripPrefix (trigger_word req) msg
        saveReq  = do now <- getNow
                      insert $ EntityBearyChatMessage
                        tokenStr
                        (trigger_word     req)
                        echo
                        (millisToUTC $ ts req)
                        (subdomain        req)
                        (channel_name     req)
                        (user_name        req)
                        now
    runTrans saveReq
    return $ BearyChatResponse ("echo: " <> echo) Nothing