This repository was archived by the owner on Oct 1, 2022. It is now read-only.
generated from NCKU-CCS/TOC-Project-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
58 lines (50 loc) · 1.88 KB
/
utils.py
File metadata and controls
58 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
from linebot import LineBotApi, WebhookParser
from linebot.models import MessageEvent, TextMessage, TextSendMessage, TemplateSendMessage, ImageCarouselColumn, ImageCarouselTemplate, URITemplateAction, ButtonsTemplate, MessageTemplateAction, ImageSendMessage,FlexSendMessage
import json
from datetime import date, timedelta
channel_access_token = os.getenv("LINE_CHANNEL_ACCESS_TOKEN", None)
def send_text_message(reply_token, text):
line_bot_api = LineBotApi(channel_access_token)
line_bot_api.reply_message(reply_token, TextSendMessage(text=text))
return "OK"
"""
def send_image_url(id, img_url):
pass
"""
def send_button_message_URL(reply_token, title, text, btn, url):
line_bot_api = LineBotApi(channel_access_token)
message = TemplateSendMessage(
alt_text='button template',
template = ButtonsTemplate(
title = title,
text = text,
thumbnail_image_url = url,
actions = btn
)
)
line_bot_api.reply_message(reply_token, message)
return "OK"
def send_button_message_NoneURL(reply_token, title, text, btn):
line_bot_api = LineBotApi(channel_access_token)
message = TemplateSendMessage(
alt_text='button template',
template = ButtonsTemplate(
title = title,
text = text,
actions = btn
)
)
line_bot_api.reply_message(reply_token, message)
return "OK"
def send_Multi_Image(reply_token,message):
line_bot_api = LineBotApi(channel_access_token)
line_bot_api.reply_message(reply_token, message)
return "OK"
def send_Flex_message(reply_token,FlexMessage):
line_bot_api = LineBotApi(channel_access_token)
line_bot_api.reply_message(reply_token, FlexSendMessage('profile',FlexMessage))
return "OK"
def CountDay(count):
day = date.today() - timedelta(days=count)
return day.strftime("20%y-%m-%d")