コード例 #1
0
ファイル: start.py プロジェクト: wonsokoh1019/samplebot2
def image_introduce():
    action1 = make_postback_action("a",
                                   display_text="Timeclock can be recorded "
                                   "easily just by clicking buttons",
                                   label="Try it now")

    column1 = make_image_carousel_column(
        image_url=IMAGE_CAROUSEL["resource_url"][0], action=action1)

    action2 = make_postback_action(
        "b",
        display_text="Entered attendance records "
        "are automatically entered "
        "in Shared Calendar",
        label="Try it now",
    )
    column2 = make_image_carousel_column(
        image_url=IMAGE_CAROUSEL["resource_url"][1], action=action2)

    action3 = make_postback_action("c",
                                   display_text="Attendance records of all "
                                   "employees can be checked at a"
                                   " glance via Attendance "
                                   "Management Shared Calendar",
                                   label="Try it now")

    column3 = make_image_carousel_column(
        image_url=IMAGE_CAROUSEL["resource_url"][2], action=action3)

    columns = [column1, column2, column3]
    return make_image_carousel(columns)
コード例 #2
0
ファイル: message.py プロジェクト: winsss123/sample_bot_test
def create_quick_replay_items(confirm_callback, previous_callback):

    action1 = make_postback_action(confirm_callback,
                                   label="yes", display_text="yes",)
    reply_item1 = make_quick_reply_item(action1)

    action2 = make_postback_action(previous_callback,
                                   label="No", display_text="No")
    reply_item2 = make_quick_reply_item(action2)

    return [reply_item1, reply_item2]
コード例 #3
0
def make_add_rich_menu_body(rich_menu_name):
    """
    add rich menu body
    reference: https://developers.worksmobile.com/kr/document/100504001?lang=en

    :param rich_menu_name: rich menu name
    :return: rich menu id
    """
    size = make_size(2500, 1686)

    bound0 = make_bound(0, 0, 1250, 1286)
    action0 = make_postback_action(
        "sign_in",
        display_text="Record clock-in",
        label="Record clock-in",
    )

    bound1 = make_bound(1250, 0, 1250, 1286)
    action1 = make_postback_action("sign_out",
                                   display_text="Record clock-out",
                                   label="Record clock-out")

    bound2 = make_bound(0, 1286, 2500, 400)
    action2 = make_postback_action("to_first",
                                   display_text="Start over",
                                   label="Start over")

    rich_menu = make_add_rich_menu(rich_menu_name, size, [
        make_area(bound0, action0),
        make_area(bound1, action1),
        make_area(bound2, action2)
    ])

    headers = API_BO["headers"]
    headers["consumerKey"] = OPEN_API["consumerKey"]

    url = API_BO["rich_menu_url"]
    url = utils.replace_url_bot_no(url)

    LOGGER.info("register richmenu. url:%s", url)

    response = auth_post(url, data=json.dumps(rich_menu), headers=headers)
    if response.status_code != 200:
        LOGGER.info("register richmenu failed. url:%s text:%s body:%s", url,
                    response.text, response.content)
        raise Exception("register richmenu. http return error.")

    LOGGER.info("register richmenu success. url:%s txt:%s body:%s", url,
                response.text, response.content)

    tmp = json.loads(response.content)
    return tmp["richMenuId"]
コード例 #4
0
def image_introduce():
    """
    This function constructs three image carousels for self introduction.
    Check also: calendar_bot/model/data.py
    reference: https://developers.worksmobile.com/kr/document/100500809?lang=en

    :return: image carousels type message content.
    """

    action1 = make_postback_action("a",
                                   display_text="Timeclock can be recorded "
                                                "easily just by clicking buttons",
                                   label="Try it now")

    column1 = make_image_carousel_column(
        image_url=IMAGE_CAROUSEL["resource_url"][0],
        action=action1)

    action2 = make_postback_action("b",
                                   display_text="Entered attendance records "
                                                "are automatically entered "
                                                "in Shared Calendar",
                                   label="Try it now",)
    column2 = make_image_carousel_column(
        image_url=IMAGE_CAROUSEL["resource_url"][1],
        action=action2)

    action3 = make_postback_action("c",
                                   display_text="Attendance records of all "
                                                "employees can be checked at a"
                                                " glance via Attendance "
                                                "Management Shared Calendar",
                                   label="Try it now")

    column3 = make_image_carousel_column(
        image_url=IMAGE_CAROUSEL["resource_url"][2],
        action=action3)

    columns = [column1, column2, column3]
    return make_image_carousel(columns)
コード例 #5
0
def create_quick_replay_items(confirm_callback, previous_callback):
    """
    Building a quick reply floating window for messages.
    Check also: calendar_bot/model/data.py
    reference: https://developers.worksmobile.com/jp/document/100500807?lang=en

    :param confirm_callback: callback string for the first button.
    :param previous_callback: callback string for the seconds button.
    :return:
    """
    action1 = make_postback_action(
        confirm_callback,
        label="yes",
        display_text="yes",
    )
    reply_item1 = make_quick_reply_item(action1)

    action2 = make_postback_action(previous_callback,
                                   label="No",
                                   display_text="No")
    reply_item2 = make_quick_reply_item(action2)

    return [reply_item1, reply_item2]
コード例 #6
0
ファイル: start.py プロジェクト: lineworks-test/new
def image_introduce():
    resource_kr0 = make_i18n_image_url("ko_KR",
                                       IMAGE_CAROUSEL["resource_url"]["kr"][0])
    resource_en0 = make_i18n_image_url("en_US",
                                       IMAGE_CAROUSEL["resource_url"]["en"][0])
    resource_jp0 = make_i18n_image_url("ja_JP",
                                       IMAGE_CAROUSEL["resource_url"]["jp"][0])
    i18n_resource0 = [resource_kr0, resource_en0, resource_jp0]

    jp_text0 = make_i18n_label("ja_JP", "今使ってみてください")
    en_text0 = make_i18n_label("en_US", "Try it now")
    kr_text0 = make_i18n_label("ko_KR", "지금 사용해 보세요")
    display_label0 = [jp_text0, en_text0, kr_text0]

    display_text_jp0 = i18n_display_text(
        "ja_JP", "ボタンをクリックするだけで簡単に出"
        "退勤時間を記録することができます。")
    display_text_en0 = i18n_display_text(
        "en_US", "Timeclock can be recorded "
        "easily just by clicking buttons")
    display_text_kr0 = i18n_display_text("ko_KR", "버튼 클릭만으로 손쉽게 "
                                         "출퇴근  시간을 기록할 수 있습니다")
    i18n_display_text0 = [display_text_jp0, display_text_en0, display_text_kr0]
    action1 = make_postback_action("a",
                                   display_text="버튼 클릭만으로 손쉽게 출퇴근 "
                                   "시간을 기록할 수 있습니다",
                                   i18n_display_texts=i18n_display_text0,
                                   label="지금 사용해 보세요",
                                   i18n_labels=display_label0)

    column1 = make_image_carousel_column(
        image_url=IMAGE_CAROUSEL["resource_url"]["kr"][0],
        i18n_image_urls=i18n_resource0,
        action=action1)

    resource_kr1 = make_i18n_image_url("ko_KR",
                                       IMAGE_CAROUSEL["resource_url"]["kr"][1])
    resource_en1 = make_i18n_image_url("en_US",
                                       IMAGE_CAROUSEL["resource_url"]["en"][1])
    resource_jp1 = make_i18n_image_url("ja_JP",
                                       IMAGE_CAROUSEL["resource_url"]["jp"][1])
    i18n_resource1 = [resource_kr1, resource_en1, resource_jp1]

    display_text_jp1 = \
        i18n_display_text("ja_JP",
                          "入力された勤怠記録は、"
                          "共有カレンダー に自動で入力されます。")
    display_text_en1 = \
        i18n_display_text("en_US",
                          "Entered attendance records are automatically "
                          "entered in Shared Calendar")
    display_text_kr1 = \
        i18n_display_text("ko_KR",
                          "입력된 근태 기록은 공유 "
                          "캘린더에 자동으로 입력됩니다")
    i18n_display_text1 = [display_text_jp1, display_text_en1, display_text_kr1]

    action2 = \
        make_postback_action("b",
                             display_text="입력된 근태 기록은 공유 "
                                          "캘린더에 자동으로 입력됩니다",
                             i18n_display_texts=i18n_display_text1,
                             label="지금 사용해 보세요",
                             i18n_labels=display_label0)
    column2 = \
        make_image_carousel_column(
            image_url=IMAGE_CAROUSEL["resource_url"]["kr"][1],
            i18n_image_urls=i18n_resource1,
            action=action2)

    resource_kr2 = make_i18n_image_url("ko_KR",
                                       IMAGE_CAROUSEL["resource_url"]["kr"][2])
    resource_en2 = make_i18n_image_url("en_US",
                                       IMAGE_CAROUSEL["resource_url"]["en"][2])
    resource_jp2 = make_i18n_image_url("ja_JP",
                                       IMAGE_CAROUSEL["resource_url"]["jp"][2])
    i18n_resource2 = [resource_kr2, resource_en2, resource_jp2]

    display_text_jp2 = i18n_display_text(
        "ja_JP", "勤怠管理共有カレンダーですべての"
        "社員の勤怠記録を一目で確認できます。")
    display_text_en2 = i18n_display_text(
        "en_US", "Attendance records of all employees "
        "can be checked at a glance via "
        "Attendance Management "
        "Shared Calendar")
    display_text_kr2 = i18n_display_text(
        "ko_KR", "공유 캘린더에서 모든 직원의 근태 "
        "기록을 한눈에 확인해볼 수 있습니다")
    i18n_display_text2 = [display_text_jp2, display_text_en2, display_text_kr2]

    action3 = make_postback_action("c",
                                   display_text="공유 캘린더에서 모든 직원의 "
                                   "근태 기록을 한눈에 확인해볼 "
                                   "수 있습니다",
                                   i18n_display_texts=i18n_display_text2,
                                   label="지금 사용해 보세요",
                                   i18n_labels=display_label0)

    column3 = \
        make_image_carousel_column(
            image_url=IMAGE_CAROUSEL["resource_url"]["kr"][2],
            i18n_image_urls=i18n_resource2,
            action=action3)

    columns = [column1, column2, column3]
    return make_image_carousel(columns)
コード例 #7
0
def make_add_rich_menu_body(rich_menu_name):
    size = make_size(2500, 1686)

    bound0 = make_bound(0, 0, 1250, 1286)
    jp_text0 = i18n_display_text("ja_JP", "出勤を記録する")
    en_text0 = i18n_display_text("en_US", "Record clock-in")
    kr_text0 = i18n_display_text("ko_KR", "출근 기록하기")
    display_text0 = [jp_text0, en_text0, kr_text0]

    jp_label_text0 = make_i18n_label("ja_JP", "出勤を記録する")
    en_label_text0 = make_i18n_label("en_US", "Record clock-in")
    kr_label_text0 = make_i18n_label("ko_KR", "출근 기록하기")
    display_label0 = [jp_label_text0, en_label_text0, kr_label_text0]

    action0 = make_postback_action("sign_in",
                                   display_text="출근 기록하기",
                                   label="출근 기록하기",
                                   i18n_display_texts=display_text0,
                                   i18n_labels=display_label0)

    bound1 = make_bound(1250, 0, 1250, 1286)
    jp_text1 = i18n_display_text("ja_JP", "退勤を記録する")
    en_text1 = i18n_display_text("en_US", "Record clock-out")
    kr_text1 = i18n_display_text("ko_KR", "퇴근 기록하기")
    display_text1 = [jp_text1, en_text1, kr_text1]

    jp_label_text1 = make_i18n_label("ja_JP", "退勤を記録する")
    en_label_text1 = make_i18n_label("en_US", "Record clock-out")
    kr_label_text1 = make_i18n_label("ko_KR", "퇴근 기록하기")
    display_label1 = [jp_label_text1, en_label_text1, kr_label_text1]

    action1 = make_postback_action("sign_out",
                                   display_text="퇴근 기록하기",
                                   label="퇴근 기록하기",
                                   i18n_display_texts=display_text1,
                                   i18n_labels=display_label1)

    bound2 = make_bound(0, 1286, 2500, 400)
    jp_text2 = i18n_display_text("ja_JP", "最初へ")
    en_text2 = i18n_display_text("en_US", "Start over")
    kr_text2 = i18n_display_text("ko_KR", "처음으로")
    display_text2 = [jp_text2, en_text2, kr_text2]

    jp_label_text2 = make_i18n_label("ja_JP", "最初へ")
    en_label_text2 = make_i18n_label("en_US", "Start over")
    kr_label_text2 = make_i18n_label("ko_KR", "처음으로")
    display_label2 = [jp_label_text2, en_label_text2, kr_label_text2]

    action2 = make_postback_action("to_first",
                                   display_text="처음으로",
                                   label="처음으로",
                                   i18n_display_texts=display_text2,
                                   i18n_labels=display_label2)

    rich_menu = make_add_rich_menu(
                    rich_menu_name,
                    size,
                    [
                        make_area(bound0, action0),
                        make_area(bound1, action1),
                        make_area(bound2, action2)
                    ])

    headers = API_BO["headers"]
    headers["consumerKey"] = OPEN_API["consumerKey"]

    url = API_BO["rich_menu_url"]
    url = utils.replace_url_bot_no(url)

    LOGGER.info("register richmenu. url:%s", url)

    response = auth_post(url, data=json.dumps(rich_menu), headers=headers)
    if response.status_code != 200:
        LOGGER.info("register richmenu failed. url:%s text:%s body:%s",
                    url, response.text, response.content)
        raise Exception("register richmenu. http return error.")

    LOGGER.info("register richmenu success. url:%s txt:%s body:%s",
                url, response.text, response.content)

    tmp = json.loads(response.content)
    return tmp["richMenuId"]