from django.shortcuts import render from django.http import HttpResponse, JsonResponse from django.views.decorators.csrf import csrf_exempt import os, sys from slack.modules import * from TokenManager import TokenManager tm = TokenManager() SLACK_TOKEN = tm.get('SLACK_TOKEN') def index(request): return HttpResponse('Front page of ECEUSC Slack Bot should go here!') @csrf_exempt def command(request): if request.method == 'GET': return HttpResponse('Lol lets do this') elif request.method == 'POST': req_token = request.POST.get('token') if req_token != SLACK_TOKEN: return HttpResponse('WRONG TOKEN', status=401) user_id = request.POST.get('user_id') channel_id = request.POST.get('channel_id') channel_name = request.POST.get('channel_name') text = request.POST.get('text') words = text.split(' ')
from django.views.decorators.csrf import csrf_exempt from django.shortcuts import render from django.http import HttpResponse import os from messengerbot import receive from TokenManager import TokenManager tm = TokenManager() VERIFY_TOKEN = tm.get('MESSENGER_VERIFY_TOKEN') def index(request): return HttpResponse('Front page of ECEUSC Messenger Bot should go here! Heroku 2....') @csrf_exempt def webhook(request): if request.method == 'GET': verify_token = request.GET.get('hub.verify_token') if verify_token == VERIFY_TOKEN: hub_challenge = request.GET.get('hub.challenge') print(hub_challenge) return HttpResponse(hub_challenge) else: return HttpResponse('ERROR') elif request.method == 'POST': obj = request.POST.get('object') if obj == 'page': for entry in request.POST.get('entry'): for msg_event in entry.get('messaging'):
https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # https://docs.djangoproject.com/en/2.0/ref/settings/#secret-key from TokenManager import TokenManager tm = TokenManager() SECRET_KEY = tm.get('DJANGO_TOKEN') or 'CHANGE_ME_TO_LARGE_RANDOM_VALUE' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [ 'peaceful-river-18332.herokuapp.com', 'eceusc.herokuapp.com', 'ngrok.io', '*', ] # Application definition INSTALLED_APPS = [ 'django.contrib.admin',
import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # https://docs.djangoproject.com/en/2.0/ref/settings/#secret-key from TokenManager import TokenManager tm = TokenManager() SECRET_KEY = tm.get('DJANGO_TOKEN') or 'CHANGE_ME_TO_LARGE_RANDOM_VALUE' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [ 'peaceful-river-18332.herokuapp.com', 'eceusc.herokuapp.com', 'ngrok.io', '*', ] import socket HOSTNAME = None try: HOSTNAME = socket.gethostname()