<commit_before>from twilio.twiml import Response

from django.contrib.sites.models import Site
from django.http import (
    HttpResponse,
    HttpResponseRedirect,
)
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View

from haystack.inputs import AutoQuery
from haystack.query import SearchQuerySet

from contacts.models import (
    Book,
    Contact,
    LogEntry,
)
from profiles.models import Profile

MET_PREFIXES = ('met', 'saw')


@csrf_exempt
def sms(request):
    if request.method == 'GET':
        return HttpResponseRedirect('/')
    if request.method == 'POST':
        import pdb; pdb.set_trace()
        user, book = get_user_objects_from_message(request.POST)
        if not user or not book:
            r = Response()
            r.message("Hmm... It looks like your ContactOtter account isn't set up yet. Go to https://www.contactotter.com to get things ready!")
            return HttpResponse(r.toxml(), content_type='text/xml')

        message = request.POST.get('Body').strip()

        tokens = message.split(' ')
        if len(tokens) < 2:
            return help_message()

        if tokens[0].lower() in MET_PREFIXES:
            if tokens[1].lower() == 'with':
                del tokens[1]
            name = ' '.join(tokens[1:])
            contacts = SearchQuerySet().filter(<commit_msg>Let's not commit breakpoints<commit_after>from twilio.twiml import Response

from django.contrib.sites.models import Site
from django.http import (
    HttpResponse,
    HttpResponseRedirect,
)
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View

from haystack.inputs import AutoQuery
from haystack.query import SearchQuerySet

from contacts.models import (
    Book,
    Contact,
    LogEntry,
)
from profiles.models import Profile

MET_PREFIXES = ('met', 'saw')


@csrf_exempt
def sms(request):
    if request.method == 'GET':
        return HttpResponseRedirect('/')
    if request.method == 'POST':
        user, book = get_user_objects_from_message(request.POST)
        if not user or not book:
            r = Response()
            r.message("Hmm... It looks like your ContactOtter account isn't set up yet. Go to https://www.contactotter.com to get things ready!")
            return HttpResponse(r.toxml(), content_type='text/xml')

        message = request.POST.get('Body').strip()

        tokens = message.split(' ')
        if len(tokens) < 2:
            return help_message()

        if tokens[0].lower() in MET_PREFIXES:
            if tokens[1].lower() == 'with':
                del tokens[1]
            name = ' '.join(tokens[1:])
            contacts = SearchQuerySet().filter(
{'fraction_non_alphanumeric': 0.104, 'fraction_numerical': 0.0034782608695652175, 'mean_word_length': 2.8655913978494625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7269144', 'n_tokens_mistral': 832, 'n_tokens_neox': 807, 'n_words': 235}