|
16 | 16 |
|
17 | 17 | import datetime
|
18 | 18 | import errno
|
| 19 | +import json |
19 | 20 | import os
|
20 | 21 | import sys
|
21 | 22 | import tempfile
|
@@ -332,6 +333,137 @@ def handle_text_message(event):
|
332 | 333 | event.reply_token,
|
333 | 334 | message
|
334 | 335 | )
|
| 336 | + elif text == 'flex_update_1': |
| 337 | + bubble_string = """ |
| 338 | + { |
| 339 | + "type": "bubble", |
| 340 | + "body": { |
| 341 | + "type": "box", |
| 342 | + "layout": "vertical", |
| 343 | + "contents": [ |
| 344 | + { |
| 345 | + "type": "image", |
| 346 | + "url": "https://line-objects-dev.com/flex/bg/eiji-k-1360395-unsplash.jpg", |
| 347 | + "position": "relative", |
| 348 | + "size": "full", |
| 349 | + "aspectMode": "cover", |
| 350 | + "aspectRatio": "1:1", |
| 351 | + "gravity": "center" |
| 352 | + }, |
| 353 | + { |
| 354 | + "type": "box", |
| 355 | + "layout": "horizontal", |
| 356 | + "contents": [ |
| 357 | + { |
| 358 | + "type": "box", |
| 359 | + "layout": "vertical", |
| 360 | + "contents": [ |
| 361 | + { |
| 362 | + "type": "text", |
| 363 | + "text": "Brown Hotel", |
| 364 | + "weight": "bold", |
| 365 | + "size": "xl", |
| 366 | + "color": "#ffffff" |
| 367 | + }, |
| 368 | + { |
| 369 | + "type": "box", |
| 370 | + "layout": "baseline", |
| 371 | + "margin": "md", |
| 372 | + "contents": [ |
| 373 | + { |
| 374 | + "type": "icon", |
| 375 | + "size": "sm", |
| 376 | + "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png" |
| 377 | + }, |
| 378 | + { |
| 379 | + "type": "icon", |
| 380 | + "size": "sm", |
| 381 | + "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png" |
| 382 | + }, |
| 383 | + { |
| 384 | + "type": "icon", |
| 385 | + "size": "sm", |
| 386 | + "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png" |
| 387 | + }, |
| 388 | + { |
| 389 | + "type": "icon", |
| 390 | + "size": "sm", |
| 391 | + "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png" |
| 392 | + }, |
| 393 | + { |
| 394 | + "type": "icon", |
| 395 | + "size": "sm", |
| 396 | + "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gray_star_28.png" |
| 397 | + }, |
| 398 | + { |
| 399 | + "type": "text", |
| 400 | + "text": "4.0", |
| 401 | + "size": "sm", |
| 402 | + "color": "#d6d6d6", |
| 403 | + "margin": "md", |
| 404 | + "flex": 0 |
| 405 | + } |
| 406 | + ] |
| 407 | + } |
| 408 | + ] |
| 409 | + }, |
| 410 | + { |
| 411 | + "type": "box", |
| 412 | + "layout": "vertical", |
| 413 | + "contents": [ |
| 414 | + { |
| 415 | + "type": "text", |
| 416 | + "text": "¥62,000", |
| 417 | + "color": "#a9a9a9", |
| 418 | + "decoration": "line-through", |
| 419 | + "align": "end" |
| 420 | + }, |
| 421 | + { |
| 422 | + "type": "text", |
| 423 | + "text": "¥42,000", |
| 424 | + "color": "#ebebeb", |
| 425 | + "size": "xl", |
| 426 | + "align": "end" |
| 427 | + } |
| 428 | + ] |
| 429 | + } |
| 430 | + ], |
| 431 | + "position": "absolute", |
| 432 | + "offsetBottom": "0px", |
| 433 | + "offsetStart": "0px", |
| 434 | + "offsetEnd": "0px", |
| 435 | + "backgroundColor": "#00000099", |
| 436 | + "paddingAll": "20px" |
| 437 | + }, |
| 438 | + { |
| 439 | + "type": "box", |
| 440 | + "layout": "vertical", |
| 441 | + "contents": [ |
| 442 | + { |
| 443 | + "type": "text", |
| 444 | + "text": "SALE", |
| 445 | + "color": "#ffffff" |
| 446 | + } |
| 447 | + ], |
| 448 | + "position": "absolute", |
| 449 | + "backgroundColor": "#ff2600", |
| 450 | + "cornerRadius": "20px", |
| 451 | + "paddingAll": "5px", |
| 452 | + "offsetTop": "10px", |
| 453 | + "offsetEnd": "10px", |
| 454 | + "paddingStart": "10px", |
| 455 | + "paddingEnd": "10px" |
| 456 | + } |
| 457 | + ], |
| 458 | + "paddingAll": "0px" |
| 459 | + } |
| 460 | + } |
| 461 | + """ |
| 462 | + message = FlexSendMessage(alt_text="hello", contents=json.loads(bubble_string)) |
| 463 | + line_bot_api.reply_message( |
| 464 | + event.reply_token, |
| 465 | + message |
| 466 | + ) |
335 | 467 | elif text == 'quick_reply':
|
336 | 468 | line_bot_api.reply_message(
|
337 | 469 | event.reply_token,
|
|
0 commit comments