-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
65 lines (54 loc) · 1.96 KB
/
utils.py
File metadata and controls
65 lines (54 loc) · 1.96 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
59
60
61
62
63
64
65
from linebot.models import template
from linebot.models.actions import MessageAction
from linebot.models.send_messages import ImageSendMessage
from linebot.models.template import (
ButtonsTemplate,
ConfirmTemplate,
TemplateSendMessage,
)
def Separate(n):
return "=" * n
def ConfirmWindow(context, success_string, error_string):
"""
重複使用只有對或錯的確認視窗
:params context
:params sucess_string
:params error_string
"""
confirm_template_message = TemplateSendMessage(
alt_text="歡迎使用中華大學宿網會的簡易小機器人, 請至手機查看訊息。",
template=ConfirmTemplate(
text=f"{context}",
actions=[
MessageAction(label=f"{success_string}", text=f"{success_string}"),
MessageAction(label=f"{error_string}", text=f"{error_string}"),
],
),
)
return confirm_template_message
def ButtonWindow(title, context, number, label_list):
if number == len(label_list):
actions = []
for i in range(0, number):
ButtonAction = MessageAction(
label=f"{label_list[i]}", text=f"{label_list[i]}"
)
actions.append(ButtonAction)
buttons_template_message = TemplateSendMessage(
alt_text="歡迎使用中華大學宿網會的簡易小機器人, 請至手機查看訊息。",
template=ButtonsTemplate(
title=f"{title}", text=f"{context}", actions=actions
),
)
return buttons_template_message
else:
# FIXME 這邊到時候再寫判斷,基本上我自己寫不會去故意設不一樣的值 ...
pass
def ImageWindow(origin_path, preview_path=None):
if preview_path == None:
preview_path = origin_path
image_message = ImageSendMessage(
original_content_url=f"{origin_path}",
preview_image_url=f"{preview_path}",
)
return image_message