Внедрение проекта

main
pilot 2 months ago
parent 71974e2dce
commit b8f5d30f4b

@ -52,10 +52,6 @@ def maxbot_send_menu_button(client: Client, chat_id: str, max_token: str, messag
button = []
cnt = 0
for mn in menu:
if cnt == 2:
cnt = 0
buttons.append(button)
button = []
if mn.emojii:
emojii = str(mn.emojii)
else:
@ -64,10 +60,14 @@ def maxbot_send_menu_button(client: Client, chat_id: str, max_token: str, messag
button_data = {"type": "callback", "text": " ".join([emojii, str(mn.title)]),
"payload": json.dumps(payload_data)}
button.append(button_data)
if cnt == 2 or str(mn.slug) == 'menu_1':
cnt = 0
buttons.append(button)
button = []
cnt = cnt + 1
buttons.append(button)
print(buttons)
payload = json.dumps({
"text": message,
"attachments": [
@ -212,7 +212,7 @@ def maxbot_send_month_button(client: Client, chat_id: str, max_token: str, messa
buttons.append(button)
button = []
payload_data = {"payload_type": "month_birthday", "data": dt}
button_data = {"type": "callback", "text": months[dt-1], "payload": json.dumps(payload_data)}
button_data = {"type": "callback", "text": months[dt - 1], "payload": json.dumps(payload_data)}
button.append(button_data)
cnt = cnt + 1
@ -256,3 +256,39 @@ def maxbot_send_content(client: Client, chat_id: str, max_token: str, message: s
return True
return False
def maxbot_send_feedback_button(client: Client, chat_id: str, max_token: str, message: str):
url = f"https://platform-api.max.ru/messages?chat_id={chat_id}"
buttons = []
button = []
cnt = 0
for dt in range(1, 6):
payload_data = {"payload_type": "feedback", "data": f"feedback{dt}"}
button_data = {"type": "callback", "text": dt, "payload": json.dumps(payload_data)}
button.append(button_data)
cnt = cnt + 1
buttons.append(button)
payload = json.dumps({
"text": message,
"attachments": [
{"type": "inline_keyboard",
"payload": {
"buttons": buttons
}
}
]
})
headers = {
'Authorization': f'{max_token}',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
rt = {'success': True, 'error': '', 'data': response}
return rt

@ -109,6 +109,10 @@ def bot_message(client: Client, message: dict, settings: dict, message_type):
maxbot_send_text_message(chat_id=chat_id, max_token=settings['token'],
message=f"Ваши бонусы: {bonus} руб")
if dt.title == '##feedback##':
maxbot_send_feedback_button(client=client, message='👇', chat_id=chat_id, max_token=settings['token'])
return True
if dt.img:
url = f"https://cdn.telefon-ip.ru/{dt.img}?thumb=600"
maxbot_send_img_message(chat_id=chat_id, max_token=settings['token'], img=url, message=dt.descr)

@ -68,7 +68,7 @@ def get_registration_birthday(client: Client, chat_id: str, settings: dict):
def check_registration(client: Client, chat_id: str, message: dict, settings: dict):
contact = get_registration_phone(client=client, chat_id=chat_id, settings=settings)
if not contact:
maxbot_send_content(client=client, chat_id=chat_id, max_token=settings['token'], message='start')
# maxbot_send_content(client=client, chat_id=chat_id, max_token=settings['token'], message='start')
return False
if contact.field1 is None or contact.field1 == '':

@ -14,7 +14,8 @@ def common_get_data(client: Client, key: str) -> Product:
def common_get_menu(client: Client) -> ProductCategory:
menu = ProductCategory.objects.filter(client=client, status=1, src=1, slug='menu').order_by('ord')
menu = ProductCategory.objects.filter(client=client, status=1, src=1,
slug__in=['menu', 'menu_1', 'menu_2']).order_by('ord')
return menu

Loading…
Cancel
Save