Example #1
0
def slackrandom(request):
    responseData = ""
    statusCode = 200

    try:
        requestData = {}

        requestData['token'] = str(request.POST['token'])
        requestData['team_id'] = str(request.POST['team_id'])
        requestData['team_domain'] = str(request.POST['team_domain'])
        requestData['channel_id'] = str(request.POST['channel_id'])
        requestData['channel_name'] = str(request.POST['channel_name'])
        requestData['user_id'] = str(request.POST['user_id'])
        requestData['user_name'] = str(request.POST['user_name'])
        requestData['command'] = str(request.POST['command'])
        requestData['text'] = str(request.POST['text'])

        slacklog.request(requestData)

        requestWords = requestData['text'].split()

        if len(requestWords) == 0:
            responseData = generate_randomint(0, 100)
        elif len(requestWords) == 1:
            responseData = process_single(requestWords)
        elif len(requestWords) == 2:
            responseData = process_double(requestWords)
        elif len(requestWords) == 3:
            responseData = process_triple(requestWords)
    except Exception, e:
        statusCode = 500
        slacklog.error("slackrandom", e)
Example #2
0
def stats(request):
    responseData = {}

    if settings.REDIS_ENABLED:
        try:
            responseData["bytesGenerated"] = r.get(settings.REDIS_BYTES_GENERATED)
            responseData["requestCount"] = r.get(settings.REDIS_REQUEST_COUNT)
        except Exception, e:
            slacklog.error("stats", e)