import requests
import json

# headers = {"Authorization":"Bearer 2i2Q2ShkvC0nOWZ+9E6AsMPsF/UMEC3+ihtoaOo99/sNFYtNwsRKnZbGeDizNAYXT1g8BWJIlXvkYcs+g7ED51dNQ+zyYQdo28q1T0tKpNH9lF9EYtt6AsGMIBKkMnkZXLoLPgGA+hys4D3/U45/3QdB04t89/1O/w1cDnyilFU=","Content-Type":"application/json"}
#
# body = {
#   "size": {
#     "width": 2500,
#     "height": 1686
#   },
#   "selected": "true",
#   "name": "kitchen ",
#   "chatBarText": "關於廚房",
#   "areas": [
#     {
#       "bounds": {
#         "x": 1935,
#         "y": 597,
#         "width": 451,
#         "height": 792
#       },
#       "action": {
#         "type": "message",
#         "text": "來喝點東西吧"
#       }
#     },
#     {
#       "bounds": {
#         "x": 917,
#         "y": 316,
#         "width": 916,
#         "height": 698
#       },
#       "action": {
#         "type": "message",
#         "text": "上次的碗盤怎麼都沒洗阿，都發臭了，噁噁噁~~"
#       }
#     },
#     {
#       "bounds": {
#         "x": 665,
#         "y": 1375,
#         "width": 1312,
#         "height": 311
#       },
#       "action": {
#         "type": "message",
#         "text": "肚子有點餓了"
#       }
#     },
#     {
#       "bounds": {
#         "x": 551,
#         "y": 219,
#         "width": 316,
#         "height": 1136
#       },
#       "action": {
#         "type": "message",
#         "text": "前往大廳"
#       }
#     },
#     {
#       "bounds": {
#         "x": 25,
#         "y": 168,
#         "width": 522,
#         "height": 1518
#       },
#       "action": {
#         "type": "message",
#         "text": "前往陽台"
#       }
#     }
#   ]
# }
#
# req = requests.request('POST', 'https://api.line.me/v2/bot/richmenu',
#                        headers=headers,data=json.dumps(body).encode('utf-8'))
#
# print(req.text)

# {"richMenuId":"richmenu-7e1cbf2b1f5653d672e06c7fed11ea72"}

# 設定 Rich menus 的圖片
from linebot import (
    LineBotApi, WebhookHandler
)

line_bot_api = LineBotApi('2i2Q2ShkvC0nOWZ+9E6AsMPsF/UMEC3+ihtoaOo99/sNFYtNwsRKnZbGeDizNAYXT1g8BWJIlXvkYcs+g7ED51dNQ+zyYQdo28q1T0tKpNH9lF9EYtt6AsGMIBKkMnkZXLoLPgGA+hys4D3/U45/3QdB04t89/1O/w1cDnyilFU=')

with open("image/kitchen.jpg", 'rb') as f:
    line_bot_api.set_rich_menu_image("richmenu-7e1cbf2b1f5653d672e06c7fed11ea72", "image/jpeg", f)

# 啟用 Rich menus
# import requests
#
# headers = {"Authorization":"Bearer 2i2Q2ShkvC0nOWZ+9E6AsMPsF/UMEC3+ihtoaOo99/sNFYtNwsRKnZbGeDizNAYXT1g8BWJIlXvkYcs+g7ED51dNQ+zyYQdo28q1T0tKpNH9lF9EYtt6AsGMIBKkMnkZXLoLPgGA+hys4D3/U45/3QdB04t89/1O/w1cDnyilFU=","Content-Type":"application/json"}
#
# req = requests.request('POST', 'https://api.line.me/v2/bot/user/all/richmenu/richmenu-bd2aaf50b872f0d7b506550f157e03ac',
#                        headers=headers)
#
# print(req.text)


# 查看所有 Rich menus
# from linebot import (
#     LineBotApi, WebhookHandler
# )
#
# line_bot_api = LineBotApi('2i2Q2ShkvC0nOWZ+9E6AsMPsF/UMEC3+ihtoaOo99/sNFYtNwsRKnZbGeDizNAYXT1g8BWJIlXvkYcs+g7ED51dNQ+zyYQdo28q1T0tKpNH9lF9EYtt6AsGMIBKkMnkZXLoLPgGA+hys4D3/U45/3QdB04t89/1O/w1cDnyilFU=')
#
# rich_menu_list = line_bot_api.get_rich_menu_list()
#
# for rich_menu in rich_menu_list:
#     print(rich_menu.rich_menu_id)


# 刪除rich menu
# from linebot import (
#     LineBotApi, WebhookHandler
# )
#
# line_bot_api = LineBotApi('2i2Q2ShkvC0nOWZ+9E6AsMPsF/UMEC3+ihtoaOo99/sNFYtNwsRKnZbGeDizNAYXT1g8BWJIlXvkYcs+g7ED51dNQ+zyYQdo28q1T0tKpNH9lF9EYtt6AsGMIBKkMnkZXLoLPgGA+hys4D3/U45/3QdB04t89/1O/w1cDnyilFU=')
#
# line_bot_api.delete_rich_menu(rich_menu.rich_menu_id)