измененение статического пути

main
pilot 2 months ago
parent 03932ca334
commit 84be006940

@ -335,3 +335,34 @@ def maxbot_send_booking_count_people_button(client: Client, chat_id: str, max_to
rt = {'success': True, 'error': '', 'data': response} rt = {'success': True, 'error': '', 'data': response}
return rt return rt
def maxbot_send_link_button(text, title_button, link, chat_id, max_token):
url = f"https://platform-api.max.ru/messages?chat_id={chat_id}"
payload = json.dumps({
"text": text,
"attachments": [
{"type": "inline_keyboard",
"payload": {
"buttons": [
[
{
"type": "link",
"text": title_button,
"url": link
}
]
]
}
}
]
})
headers = {
'Authorization': f'{max_token}',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
rt = {'success': True, 'error': '', 'data': response}

@ -6,7 +6,7 @@ from restoran_max_bot.common import *
from restoran_max_bot.iiko_api import customer_info, customer_create, customer_wallet from restoran_max_bot.iiko_api import customer_info, customer_create, customer_wallet
from restoran_max_bot.rkiper_api import rkiper_customer_info, rkiper_customer_create from restoran_max_bot.rkiper_api import rkiper_customer_info, rkiper_customer_create
from restoran_max_bot.settings import STATICFILES_DIRS from restoran_max_bot.settings import STATICFILES_DIRS
from restoran_max_bot.utils import has_key from restoran_max_bot.utils import has_key, is_json
# получение информации по интеграции с терминалом ikko, rkeeper # получение информации по интеграции с терминалом ikko, rkeeper
@ -119,23 +119,33 @@ def bot_message(client: Client, message: dict, settings: dict, message_type):
chat_id=chat_id, max_token=settings['token']) chat_id=chat_id, max_token=settings['token'])
return True return True
# для более сложных функций
if is_json(dt.title):
data = json.loads(dt.title)
if 'type' in dt.title:
if data['type'] == 'linkbutton':
maxbot_send_link_button(text=dt.descr, title_button=data['button'], link=dt.url, chat_id=chat_id,
max_token=settings['token'])
if dt.img: if dt.img:
url = f"https://cdn.telefon-ip.ru/{dt.img}?thumb=600" 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) maxbot_send_img_message(chat_id=chat_id, max_token=settings['token'], img=url, message=dt.descr)
if '##' not in dt.title and not dt.img: if '##' not in dt.title and not dt.img and not is_json(dt.title):
maxbot_send_text_message(chat_id=chat_id, max_token=settings['token'], message=dt.descr) maxbot_send_text_message(chat_id=chat_id, max_token=settings['token'], message=dt.descr)
if dt.url: if dt.url and not is_json(dt.title):
maxbot_send_text_message(chat_id=chat_id, max_token=settings['token'], message=dt.url) maxbot_send_text_message(chat_id=chat_id, max_token=settings['token'], message=dt.url)
# отправка меню # отправка меню
maxbot_send_menu_button(chat_id=chat_id, max_token=settings['token'], message='👇 Выберите раздел', client=client) maxbot_send_menu_button(chat_id=chat_id, max_token=settings['token'], message='👇 Выберите раздел',
client=client)
else: else:
if payload['payload_type'] == 'booking_count_people': if payload['payload_type'] == 'booking_count_people':
print('запрос даты') print('запрос даты')
# отправка меню # отправка меню
maxbot_send_menu_button(chat_id=chat_id, max_token=settings['token'], message='👇 Выберите раздел', client=client) maxbot_send_menu_button(chat_id=chat_id, max_token=settings['token'], message='👇 Выберите раздел',
client=client)
return True return True

Loading…
Cancel
Save