Ejemplo n.º 1
0
    def reply_text(self):
        replied = False
        message = self.event.message.text  #message from user
        if any(keyword in message for keyword in ['wallpaper']):
            wallpaper_url = get_wp_url()
            msgObj = ImageSendMessage(wallpaper_url, wallpaper_url)
            line_bot_api.reply_message(self.event.reply_token, msgObj)
            replied = True

        if not replied:
            profile = line_bot_api.get_profile(self.event.source.user_id)
            msgObj = TextSendMessage(text="Invalid command")
            line_bot_api.reply_message(self.event.reply_token, msgObj)
            stkObj = StickerSendMessage(package_id=2, sticker_id=149)
            line_bot_api.push_message(profile.user_id, stkObj)
Ejemplo n.º 2
0
def handle_send_message3(event, relpy):
    #mozaiku(event)
    result = change_image2(event)
    reply = str(relpy)

    if result:
        line_bot_api.reply_message(
            reply,
            ImageSendMessage(
                original_content_url=FQDN + "/static/" + event + "_face.jpg",
                preview_image_url=FQDN + "/static/" + event + "_face.jpg",
            ))

    else:
        handle_textmessage(event)
Ejemplo n.º 3
0
def sendAbout(event):  #關於我們
    try:
        text1 = "我們提供良好的環境及優質的住宿服務,使您有賓至如歸的感受,歡迎來體驗美好的經歷。"
        message = [
            TextSendMessage(  #旅館簡介
                text = text1
            ),
            ImageSendMessage(  #旅館圖片
                original_content_url = "https://i.imgur.com/1NSDAvo.jpg",
                preview_image_url = "https://i.imgur.com/1NSDAvo.jpg"
            ),
        ]
        line_bot_api.reply_message(event.reply_token,message)
    except:
        line_bot_api.reply_message(event.reply_token,TextSendMessage(text='發生錯誤!'))
Ejemplo n.º 4
0
def handle_message(event):
    msg = event.message.text
    if "貼圖" in msg or "sticker" in msg:
        sticker_id = random.randint(1, 10)
        message = StickerSendMessage(package_id='1',
                                     sticker_id=str(sticker_id))
        line_bot_api.reply_message(event.reply_token, message)
    if "圖片" in msg or "picture" in msg:
        message = ImageSendMessage(
            original_content_url=
            'https://s.yimg.com/zp/images/1B21BBF8B58B5D112CCC5436536C639033B48C5A',
            preview_image_url=
            'https://s.yimg.com/zp/images/1B21BBF8B58B5D112CCC5436536C639033B48C5A'
        )
        line_bot_api.reply_message(event.reply_token, message)
Ejemplo n.º 5
0
def sales_1(respond_dict):
    days = float(respond_dict["queryResult"]["outputContexts"][0]["parameters"]
                 ["days.original"])
    answer_str = f"ยอดขายย้อนหลัง {days:.0f} วัน คือ {total_previous_sales(df, days):,.2f} บาทจ้า"
    user_id = respond_dict['originalDetectIntentRequest']['payload']['data'][
        'source']['userId']
    # Generate Graph
    image_name = each_previous_sales(df, days)
    # Response Text
    line_bot_api.push_message(
        user_id,
        ImageSendMessage(
            original_content_url=f"{config['url']}/static/{image_name}",
            preview_image_url=f"{config['url']}/static/{image_name}"))
    return answer_str
Ejemplo n.º 6
0
def handle_image_message(event):
    # メッセージのID
    message_id = event.message.id

    # ユーザが送信した画像を保存
    saveImage(message_id)

    # 返す画像のURLが返ってくる
    after_image_url = fireImage(message_id)

    # 画像を返す
    line_bot_api.reply_message(
        event.reply_token,
        ImageSendMessage(original_content_url=after_image_url,
                         preview_image_url=after_image_url))
Ejemplo n.º 7
0
def handle_text_message(event):
    text = handle_pattern(event.message.text.lower())  #message from user

    if (len(text) > 0):
        message_reply = TextSendMessage(text=text)
        if (text == 'tsukkomi'):
            message_reply = ImageSendMessage(
                original_content_url=
                'https://media.tenor.com/images/d85d3a03369bdd47b87ff4dc5c803a66/tenor.gif',
                preview_image_url=
                'https://media.tenor.com/images/d85d3a03369bdd47b87ff4dc5c803a66/tenor.gif'
            )
        line_bot_api.reply_message(
            event.reply_token,
            message_reply)  #reply the same message from user
Ejemplo n.º 8
0
def sendMulti(event):  #多項傳送
    try:
        message = [  #串列
            StickerSendMessage(  #傳送貼圖
                package_id='1', sticker_id='2'),
            TextSendMessage(  #傳送y文字
                text="這是 Pizza 圖片!"),
            ImageSendMessage(  #傳送圖片
                original_content_url="https://i.imgur.com/4QfKuz1.png",
                preview_image_url="https://i.imgur.com/4QfKuz1.png")
        ]
        line_bot_api.reply_message(event.reply_token, message)
    except:
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text='發生錯誤!'))
Ejemplo n.º 9
0
def handle_message(event):
    if event.message.text in ['とって', '撮って', '取って', 'take a picture plz']:
        line_bot_api.reply_message(event.reply_token, [
            ImageSendMessage(original_content_url=obachan_full,
                             preview_image_url=obachan_thumb),
            TextSendMessage(text="オバチャンに任せとき!")
        ])
        sbs.create_queue('test')
        msg_dict = {'user_id': event.source.user_id}
        msg_json = json.dumps(msg_dict, indent=4)
        msg = Message(msg_json)
        sbs.send_queue_message('test', msg)
    else:
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=event.message.text))
Ejemplo n.º 10
0
 def send_question(user_id, prev=None, reask=False):
     '''
     Send a question.
     '''
     if prev:
         content = [TextSendMessage(text=prev)]
     else:
         content = []
     link = players[user_id].next_link(reask)
     TarungBot.reply_message(
         event.reply_token, content + [
             ImageSendMessage(original_content_url=link,
                              preview_image_url=link),
             TextSendMessage(text="Who is this person?")
         ])
Ejemplo n.º 11
0
def handle_follow(event):
    profile = line_bot_api.get_profile(event.source.user_id)
    print(event.source.user_id)
    pprint.pprint(profile)

    msg = 'user_id=' + event.source.user_id + '\nname=' + profile.display_name  # + '\nmsg=' + profile.status_message
    line_bot_api.reply_message(event.reply_token, TextSendMessage(text=msg))

    if profile.picture_url:
        line_bot_api.push_message(
            event.source.user_id,
            ImageSendMessage(original_content_url=profile.picture_url,
                             preview_image_url=profile.picture_url))

    db_add_user(event.source.user_id)
Ejemplo n.º 12
0
def handle_message(event):

    msg_source = event.source.type
    reply_msg = ''
    if msg_source == 'group':
        reply_msg = handle_group_image_message(event)
    elif msg_source == 'user':
        reply_msg = handle_user_image_message(event)

    if is_reply_img_url(reply_msg):
        send_msg = ImageSendMessage(original_content_url = reply_msg, preview_image_url = reply_msg)
        line_bot_api.reply_message(event.reply_token, send_msg)
    elif reply_msg != '':
        send_msg = TextSendMessage(text= reply_msg )
        line_bot_api.reply_message(event.reply_token, send_msg)
Ejemplo n.º 13
0
 def send_pass_image(self):
     num = re.sub("\\D", "", self.event.message.text)
     if int(num) not in num_list:
         return
     image_url = f'{heroku_url}/static/{num}.jpg'
     image_message = ImageSendMessage(original_content_url=image_url,
                                      preview_image_url=image_url)
     announce_message = TextSendMessage(
         text="はしれ!まえせつをプレイしてくれてありがとう!\n\n今回の特典写真はこちら!")
     thx_message = TextSendMessage(
         text=
         "ほかにも様々な特典が隠されているので引き続きプレイしてゲットしよう!\n\nhttps://iudaichi.github.io/maesetu_run_game/"
     )
     messages = [announce_message, image_message, thx_message]
     line_bot_api.reply_message(self.event.reply_token, messages=messages)
Ejemplo n.º 14
0
def handle_LPR(event):
    lpr_search = event.message.text
    app.logger.info("LPR = " + lpr_search)
    found, lpr_time, lpr, lpr_original, lpr_preview = lpr_serachDB(lpr_search)
    if (found == 0):
        reply_message = "Not Found"
        #line_bot_api.reply_message(event.reply_token, TextSendMessage(text=reply_message))
    else:
        reply_message = "LPR = {}\n--------------------------{}".format(
            lpr, lpr_time)
        line_bot_api.reply_message(event.reply_token, [
            TextSendMessage(text=reply_message),
            ImageSendMessage(original_content_url=lpr_original,
                             preview_image_url=lpr_preview)
        ])
Ejemplo n.º 15
0
def lineDataLatest(event):
    w = getLatestWeather()
    user = json.loads(str(event.source))['userId']
    showstr =   'PERIOD Information: \n' + \
                'ความชื้นของดิน : ' + str(int(w.s_moisture)) + ' %\n' + \
                'สภาพอากาศ : ' + w.w_description + '\n' + \
                'ความกดอากาศ : ' + str(w.a_pressure) + ' pha\n' + \
                'ความชื้นในอากาศ : ' + str(int(w.a_moisture)) + ' %\n' + \
                'อุณหภูมิ : ' + str(w.temp_c) + '°C'
    line_bot_api.push_message(user, TextMessage(text=showstr))
    pic = ImageSendMessage(
        original_content_url=w.picture,
        preview_image_url=w.picture
    )
    line_bot_api.push_message(user, pic)
Ejemplo n.º 16
0
def handle_text_message(event):
    print('text')
    print(static_tmp_path)

    if (event.message.text == 'ขั้นตอนการลงทะเบียน'):
        line_bot_api.reply_message(event.reply_token, [
            ImageSendMessage(
                original_content_url=
                "https://chulalongkornhospital.go.th/hr/row/row/b/images/S_5255540692607.jpg",
                preview_image_url=
                "https://chulalongkornhospital.go.th/hr/row/row/b/images/S_5255540692607.jpg"
            ),
        ])
    elif (event.message.text == 'เมนู'):
        line_bot_api.reply_message(
            event.reply_token, [
                TextSendMessage(text='ท่านสามารถเลือกเมนูจาก Bulletin ด้านล่าง'),
                TextSendMessage(text='หรือสามารถพิมพ์คำสั่งต่อไปนี้'+'\n'\
                                     ' 1.[ขั้นตอนการลงทะเบียน] เพื่อดูวิธีการลงทะเบียนออนไลน์'+'\n'\
                                     ' 2.[ติดต่อ] เพื่อดูเบอร์โทรศัพท์ของโรงพยาบาล'+'\n'\
                                     ' 3.[ลงทะเบียนผู้ป่วย] เพื่อเข้าสู่หน้าลงทะเบียนผู้ป่วยใหม่'+'\n'\
                                     ' 4.[คำถามที่พบบ่อย] เพื่อเข้าาสู่หน้า FAQ')
            ]
        )
    elif (event.message.text == 'ติดต่อ'):
        line_bot_api.reply_message(
            event.reply_token, [
                TextSendMessage(
                    text='เบอร์โรงพยาบาลจุฬาลงกรณ์ : 022564000'+'\n'\
                         'เบอร์ฝ่ายมะเร็งวิทยา : 022564100')
            ]
        )
    elif (event.message.text == 'ลงทะเบียนผู้ป่วย'):
        line_bot_api.reply_message(event.reply_token, [
            TextSendMessage(
                text=
                'http://chulalongkornhospital.go.th/hr/row/row/b/row3-th.php')
        ])
    elif (event.message.text == 'คำถามที่พบบ่อย'):
        line_bot_api.reply_message(event.reply_token, [
            TextSendMessage(
                text='https://www.chulacancer.net/faq-list.php?gid=62')
        ])
    else:
        line_bot_api.reply_message(event.reply_token, [
            TextSendMessage(text='ไม่รู้จักคำว่า ' + event.message.text),
            TextSendMessage(text='ลองพิมพ์ [เมนู] ดูนะครับ')
        ])
Ejemplo n.º 17
0
def _message_obj(reply):
    if 'imgur' in reply:
        match_web = re.search(r'http:\/\/imgur\.com\/[a-z0-9A-Z]{7}', reply)
        match_jpg = re.search(
            r'http:\/\/(i|m)\.imgur\.com\/[a-z0-9A-Z]{7}\.jpg', reply)
        if match_web:
            match = match_web.group()
        elif match_jpg:
            match = match_jpg.group()
        else:
            match = reply
        imgur_url = re.sub('http', 'https', match)
        return ImageSendMessage(original_content_url=imgur_url,
                                preview_image_url=imgur_url)
    else:
        return TextSendMessage(text=reply)
    def on_image(line_event):
        user = get_profile_from_event(line_event)

        is_find_faces, address_work, address_preview = process_mosaic_to_image(
            user, line_event.message.id)

        if not is_find_faces:
            LINE_BOT_API.reply_message(
                line_event.reply_token,
                TextSendMessage('顔が見つかりませんでした。\n' + MSG_ANNOUNCE_WEB))
        else:
            LINE_BOT_API.reply_message(line_event.reply_token, [
                ImageSendMessage(original_content_url=address_work,
                                 preview_image_url=address_preview),
                TextSendMessage(MSG_ANNOUNCE_WEB)
            ])
Ejemplo n.º 19
0
def sendMulti(event):
    try:
        message = [
            TextSendMessage(
                text=
                "嗨我是瑞瑞機器人,在這裡你可以:\n1.查詢台股(s+台股代碼)\n2.輸入'抽'抽表特版的圖片,但間隔不要太短喔\n3.喜歡的話,可以輸入like將最近抽出來的圖片放入名為jesseBot的google sheet中,會有屬於妳獨一無二的column區域放照片\n4.輸入gsheet可以看到google sheet共用連結的網址"
            ),
            StickerSendMessage(package_id='1', sticker_id='120'),
            ImageSendMessage(
                original_content_url="https://i.imgur.com/ZbZLJRN.jpg",
                preview_image_url="https://i.imgur.com/8ktAWex.jpg")
        ]
        line_bot_api.reply_message(event.reply_token, message)
    except:
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text='ㄜ抱歉 有bug'))
Ejemplo n.º 20
0
def handle_image(event):
    message_id = event.message.id

    src_image_path = Path(SRC_IMAGE_PATH.format(message_id)).absolute()
    main_image_path = MAIN_IMAGE_PATH.format(message_id)
    preview_image_path = PREVIEW_IMAGE_PATH.format(message_id)
    save_image(message_id, src_image_path)
    date_the_image(src=src_image_path, desc=Path(main_image_path).absolute())
    date_the_image(src=src_image_path, desc=Path(preview_image_path).absolute())
    image_message = ImageSendMessage(
        original_content_url="https://{0}.herokuapp.com/{1}".format(APP_NAME, main_image_path),
        preview_image_url="https://{0}.herokuapp.com/{1}".format(APP_NAME, preview_image_path),
    )
    app.logger.info("https://{0}herokuapp.com/{1}".format(APP_NAME, main_image_path))
    line_bot_api.reply_message(event.reply_token, image_message)
    src_image_path.unlink()
Ejemplo n.º 21
0
def handle_send_message(event, relpy):
    #mozaiku(event)
    result = mosic_change.mosic_image(event)
    reply = str(relpy)
    print("ここも通過したじょ")
    print("event:{}".format(event))
    print("reply:{}".format(reply))

    message = []
    message.append(
        ImageSendMessage(
            original_content_url=main.FQDN + "/static/" + event + "_face.jpg",
            preview_image_url=main.FQDN + "/static/" + event + "_face.jpg"))
    message.append(TextSendMessage(text="加工終了"))
    print("message:{}".format(message))
    main.line_bot_api.reply_message(reply, message)
Ejemplo n.º 22
0
def submit():
    if request.method == 'POST':
        line_bot_api.push_message(
            request.values.get('lineID'),
            TextSendMessage(
                text=f"您的RPA流程已完成\n狀態: {request.values.get('status')}"))
        if request.values.get('status') == 'success':
            line_bot_api.push_message(request.values.get('lineID'),
                                      TextSendMessage(text='使用資料視覺化模組進行預覽'))
            line_bot_api.push_message(
                request.values.get('lineID'),
                ImageSendMessage(
                    original_content_url=f"{request.values.get('imgUrl')}",
                    preview_image_url=f"{request.values.get('imgUrl')}"))
            #line_bot_api.push_message(request.values.get('lineID'), TextSendMessage(text=f"{request.values.get('imgUrl')}"))
    return 'success'
Ejemplo n.º 23
0
def handle_message(event):
    '''
    # 回應使用者輸入的話
    line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(text=event.message.text))
   '''
    #訊息回傳圖片
    message = ImageSendMessage(
        original_content_url=
        'https://storage.googleapis.com/www-cw-com-tw/article/201810/article-5bd182cf13ebb.jpg',
        preview_image_url=
        'https://storage.googleapis.com/www-cw-com-tw/article/201810/article-5bd182cf13ebb.jpg'
    )
    line_bot_api.reply_message(event.reply_token, message)
    '''
Ejemplo n.º 24
0
def handle_image(event):
    message_id = event.message.id

    src_image_path = "static/{}.jpg".format(message_id)

    # 画像を保存
    save_image(message_id, src_image_path)

    # 画像の送信
    image_message = ImageSendMessage(
        original_content_url=
        f"https://shota-imazeki.herokuapp.com/{src_image_path}",
        preview_image_url=
        f"https://shota-imazeki.herokuapp.com/{src_image_path}",
    )
    line_bot_api.reply_message(event.reply_token, image_message)
Ejemplo n.º 25
0
def product_2(respond_dict):
    numbers = int(respond_dict["queryResult"]["outputContexts"][0]
                  ["parameters"]["numbers.original"])
    store = int(respond_dict["queryResult"]["outputContexts"][0]["parameters"]
                ["store.original"])

    user_id = respond_dict['originalDetectIntentRequest']['payload']['data'][
        'source']['userId']
    answer_str = ""
    image_name = popular_item(df, numbers, store=[store])
    line_bot_api.push_message(
        user_id,
        ImageSendMessage(
            original_content_url=f"{config['url']}/static/{image_name}",
            preview_image_url=f"{config['url']}/static/{image_name}"))
    return answer_str
Ejemplo n.º 26
0
def handle_ImgMessage(event):
    print(event)
    #line_bot_api get_content (抓賴訊息傳的圖)
    ImgMessage_content = line_bot_api.get_message_content(event.message.id)
    print(ImgMessage_content)
    
    with open('./%s.png'%str(event.message.id),'wb') as f:     #二進位制寫入
        for chunk in ImgMessage_content.iter_content():
            f.write(chunk)
    
    #上傳到S3
    # response = s3_client.upload_file(('./%s.png'%str(event.message.id)), 'iii-tutorial-v2', ('Student9487/%s.png'%str(event.message.id)))
    
    line_bot_api.reply_message(event.reply_token,[TextSendMessage("你傳的圖片被我抓了哈哈哈"), ImageSendMessage(
        original_content_url = 'https://stickershop.line-scdn.net/stickershop/v1/product/1052655/LINEStorePC/main.png;compress=true',
        preview_image_url= 'https://stickershop.line-scdn.net/stickershop/v1/product/1052655/LINEStorePC/main.png;compress=true')])
Ejemplo n.º 27
0
def webhook():
    PushDis = GetMail()

    if PushDis == 10:
        user_id = "Ue8baeea0f29de588e397c74e7b3dcf31"

        messages = TextSendMessage(text="あと10m以下です!早めの補充を!")
        line_bot_api.push_message(user_id, messages=messages)

        messagesImage = ImageSendMessage(
            original_content_url=
            "https://cdn-ak.f.st-hatena.com/images/fotolife/h/hahayata/20190214/20190214182927.jpg",
            preview_image_url=
            "https://cdn-ak.f.st-hatena.com/images/fotolife/h/hahayata/20190214/20190214182927.jpg"
        )
        line_bot_api.push_message(user_id, messages=messagesImage)
Ejemplo n.º 28
0
def handle_image(event):
    message_content = line_bot_api.get_message_content(event.message.id)
    file_path = f"main/static/images/{event.message.id}.jpg"
    with open(Path(file_path).absolute(), 'wb') as fd:
        for chunk in message_content.iter_content():
            fd.write(chunk)

    main_image_path = f"static/images/{event.message.id}.jpg"
    preview_image_path = f"static/images/{event.message.id}.jpg"

    image_message = ImageSendMessage(
        original_content_url=f"https://tetsupy.herokuapp.com/{main_image_path}",
        preview_image_url=f"https://tetsupy.herokuapp.com/{preview_image_path}",
    )

    line_bot_api.reply_message(event.reply_token, image_message)
Ejemplo n.º 29
0
def message_text(event):
    if event.message.text == u'\u62bd':
        body = query_db()
        app.logger.info('body: {}'.format(body))
        image_url = body['url']

        line_bot_api.reply_message(
            event.reply_token,
            ImageSendMessage(original_content_url=image_url, preview_image_url=image_url)
        )
    else:
        resp = my_bot.respond(event.message.text)
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text=resp)
        )
Ejemplo n.º 30
0
def handle_message(event):
    msg = event.message.text
    i = random.randint(1, 6)
    if msg in ['大頭', '暖男']:
        if i == 1:
            message = ImageSendMessage(
                original_content_url='https://example.com/original.jpg',
                preview_image_url='https://i.imgur.com/A8noZDB.jpg')
            line_bot_api.reply_message(event.reply_token, message)
        elif i == 2:
            message = ImageSendMessage(
                original_content_url='https://example.com/original.jpg',
                preview_image_url='https://i.imgur.com/Q808Q6d.jpg')
            line_bot_api.reply_message(event.reply_token, message)
        elif i == 3:
            message = ImageSendMessage(
                original_content_url='https://example.com/original.jpg',
                preview_image_url='https://i.imgur.com/zzxL0hw.jpg')
            line_bot_api.reply_message(event.reply_token, message)
        elif i == 4:
            message = ImageSendMessage(
                original_content_url='https://example.com/original.jpg',
                preview_image_url='https://i.imgur.com/4RT5VB3.jpg')
            line_bot_api.reply_message(event.reply_token, message)
        elif i == 5:
            message = ImageSendMessage(
                original_content_url='https://example.com/original.jpg',
                preview_image_url='https://i.imgur.com/OYkhR9c.jpg')
            line_bot_api.reply_message(event.reply_token, message)
        elif i == 6:
            message = ImageSendMessage(
                original_content_url='https://example.com/original.jpg',
                preview_image_url='https://i.imgur.com/KpL9rsz.jpg')
            line_bot_api.reply_message(event.reply_token, message)

        return

    if '誰' in msg:
        r = '我是傑出的閃亮亮'
    elif '愷' in msg:
        r = '天母劉德華?'
    elif msg in ['曾昱瑋', '小狗']:
        r = '約妹帝王'
    elif '讀' in msg:
        r = '怎麼又有人已讀~'
    elif '彥' in msg:
        r = '彥丞該戒煙了'
    elif msg in ['股票', '石油', '退休']:
        r = '要起飛了嗎'
    elif '敦' in msg:
        r = '董事長好'
    elif msg in ['靠', '幹', '哀']:
        r = '我不許你這樣說'

    line_bot_api.reply_message(event.reply_token, TextSendMessage(text=r))