|
|
|
@ -9,7 +9,7 @@ from max_bot.models import Partner, Integration, Client, BonusTransaction, App
|
|
|
|
from restoran_max_bot.bot_started import bot_started
|
|
|
|
from restoran_max_bot.bot_started import bot_started
|
|
|
|
from restoran_max_bot.bot_stopped import bot_stopped
|
|
|
|
from restoran_max_bot.bot_stopped import bot_stopped
|
|
|
|
from restoran_max_bot.bot_message import bot_message, bot_promo
|
|
|
|
from restoran_max_bot.bot_message import bot_message, bot_promo
|
|
|
|
from restoran_max_bot.common import common_get_contact
|
|
|
|
from restoran_max_bot.common import common_get_contact, common_check_registration
|
|
|
|
from restoran_max_bot.settings import DEBUG
|
|
|
|
from restoran_max_bot.settings import DEBUG
|
|
|
|
from restoran_max_bot.utils import is_json, has_key
|
|
|
|
from restoran_max_bot.utils import is_json, has_key
|
|
|
|
|
|
|
|
|
|
|
|
@ -72,13 +72,6 @@ def api_start_max_v1(request, token, **kwargs):
|
|
|
|
rt = {'success': False, 'error': 'data update_type not found', 'data': ''}
|
|
|
|
rt = {'success': False, 'error': 'data update_type not found', 'data': ''}
|
|
|
|
return JsonResponse(rt, status=200)
|
|
|
|
return JsonResponse(rt, status=200)
|
|
|
|
|
|
|
|
|
|
|
|
# обработчик промо кодов с запросов
|
|
|
|
|
|
|
|
# https://dev.max.ru/docs/chatbots/bots-coding/prepare
|
|
|
|
|
|
|
|
# https://max.ru/id032606883607_2_bot?start=source_site
|
|
|
|
|
|
|
|
if data.get("payload", None):
|
|
|
|
|
|
|
|
print(data['payload'])
|
|
|
|
|
|
|
|
bot_promo(client=client, message=data, settings_max=settings_max)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# получение сообщения из бота
|
|
|
|
# получение сообщения из бота
|
|
|
|
if data['update_type'] == 'message_created':
|
|
|
|
if data['update_type'] == 'message_created':
|
|
|
|
bot_message(client=client, message=data, settings_max=settings_max, message_type='message_created')
|
|
|
|
bot_message(client=client, message=data, settings_max=settings_max, message_type='message_created')
|
|
|
|
@ -88,7 +81,13 @@ def api_start_max_v1(request, token, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
# start - запуск бота
|
|
|
|
# start - запуск бота
|
|
|
|
if data['update_type'] == 'bot_started':
|
|
|
|
if data['update_type'] == 'bot_started':
|
|
|
|
bot_started(client=client, message=data, settings=settings_max)
|
|
|
|
# https://dev.max.ru/docs/chatbots/bots-coding/prepare
|
|
|
|
|
|
|
|
# https://max.ru/id032606883607_2_bot?start=source_site
|
|
|
|
|
|
|
|
# роверка на промокод
|
|
|
|
|
|
|
|
if data.get("payload", None):
|
|
|
|
|
|
|
|
bot_promo(client=client, message=data, settings_max=settings_max)
|
|
|
|
|
|
|
|
if not common_check_registration(client=client, chat_id=data['chat_id']):
|
|
|
|
|
|
|
|
bot_started(client=client, message=data, settings=settings_max)
|
|
|
|
|
|
|
|
|
|
|
|
# выход из бота
|
|
|
|
# выход из бота
|
|
|
|
if data['update_type'] == 'bot_stopped':
|
|
|
|
if data['update_type'] == 'bot_stopped':
|
|
|
|
|