@csrf_exempt
@require_POST
def telegram_bot(request):
    try:
        doc = json.loads(request.body.decode())
        jsonschema.validate(doc, telegram_callback)
    except ValueError:
        return HttpResponseBadRequest()
    except jsonschema.ValidationError:
        return HttpResponse()
    if ('/start' not in doc['message']['text']):
        return HttpResponse()
    chat = doc['message']['chat']
    name = max(chat.get('title', ''), chat.get('username', ''))
    invite = render_to_string('integrations/telegram_invite.html', {'qs': signing.dumps((chat['id'], chat['type'], name))})
    Telegram.send(chat['id'], invite)
    return HttpResponse()
@csrf_exempt
@require_POST
def telegram_bot(request):
    try:
        doc = json.loads(request.body.decode())
        jsonschema.validate(doc, telegram_callback)
    except ValueError:
        return HttpResponseBadRequest()
    except jsonschema.ValidationError:
        return HttpResponse()
    if ('/start' not in doc['message']['text']):
        return HttpResponse()
    chat = doc['message']['chat']
    name = max(chat.get('title', ), chat.get('username', ))
    invite = render_to_string('integrations/telegram_invite.html', {'qs': signing.dumps((chat['id'], chat['type'], name))})
    Telegram.send(chat['id'], invite)
    return HttpResponse()