Beispiel #1
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='(์ฃผ)๋‚˜๋ˆ”๋กœ๋˜์—์„œ ์ œ๊ณตํ•˜๋Š” "๋กœ๋˜๋‹น์ฒจ๋ฒˆํ˜ธ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='๋กœ๋˜๋‹น์ฒจ๋ฒˆํ˜ธ ์„œ๋น„์Šค',
                                subtitle='(์ฃผ)๋‚˜๋ˆ”๋กœ๋˜์—์„œ ์ œ๊ณตํ•˜๋Š” "๋กœ๋˜๋‹น์ฒจ๋ฒˆํ˜ธ ์„œ๋น„์Šค"์—์š”.')
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            num = input_data['store'][0]['value']

            if self.fb.log_id is None:
                self.fb.log_id = 'FBSendMessage|%d' % int(time.time() * 1000)
            res = requests.get(
                url=
                'http://www.nlotto.co.kr/common.do?method=getLottoNumber&drwNo=%s'
                % num)
            save_a_log_to_server({
                'log_id': self.fb.log_id,
                'user_id': self.fb.user_id,
                'os': '',
                'application': 'facebook',
                'api_code': 'lotto',
                'api_provider_code': 'chatbrick',
                'origin': 'webhook_server',
                'end': int(time.time() * 1000),
                'remark': '์™ธ๋ถ€ ๋กœ๋˜ ๋‹น์ฒจ๋ฒˆํ˜ธ ์กฐํšŒ API ์š”์ฒญ์„ ๋ณด๋ƒ„'
            })
            parsed_result = res.json()

            await self.brick_db.delete()
            await self.fb.send_message(message=Message(
                text=
                '๋‘๊ตฌ๋‘๊ตฌ๋‘๊ตฌ ~\n์กฐํšŒํ•˜์‹  {drwNo}ํšŒ ๋‹น์ฒจ๋ฒˆํ˜ธ๋Š” {drwtNo1},{drwtNo2},{drwtNo3},{drwtNo4},{drwtNo5},{drwtNo6} ์— ๋ณด๋„ˆ์Šค๋ฒˆํ˜ธ๋Š” {bnusNo} ์ด์—์š”.\n๋ถ€๋”” 1๋“ฑ์ด๊ธธ!!'
                .format(**parsed_result),
                quick_replies=QuickReply(quick_reply_items=[
                    QuickReplyTextItem(title='๋‹ค๋ฅธํšŒ์ฐจ๊ฒ€์ƒ‰',
                                       payload='brick|lotto|get_started')
                ])))

        return None
Beispiel #2
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='geniecontents์—์„œ ์ œ๊ณตํ•˜๋Š” "๋ ๋ณ„ ์˜ค๋Š˜์˜ ์šด์„ธ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=BRICK_DEFAULT_IMAGE,
                            title='๋ ๋ณ„ ์˜ค๋Š˜์˜ ์šด์„ธ ์„œ๋น„์Šค',
                            subtitle='geniecontents์—์„œ ์ œ๊ณตํ•˜๋Š” "๋ ๋ณ„ ์˜ค๋Š˜์˜ ์šด์„ธ ์„œ๋น„์Šค"์—์š”.')
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            num = input_data['store'][0]['value']
            now = datetime.datetime.today()
            res = requests.get(
                url=
                'https://www.geniecontents.com/fortune/internal/v1/daily?birthYear=%s&targetYear=%s&targetMonth=%s&targetDay=%s'
                % (num, now.year, now.month, now.day))
            try:
                parsed_result = res.json()
                parsed_result.update(parsed_result['list'][0])
                send_message = [
                    Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”'),
                    Message(attachment=ImageAttachment(
                        url='https:%s' % parsed_result['animalImgUrl'])),
                    Message(
                        text=
                        '์ถœ์ƒ๋…„๋„ : {year}\n์šด์„ธ : {summary}\n์ž์„ธํ•œ ๋‚ด์šฉ : {description}'
                        .format(**parsed_result),
                        quick_replies=QuickReply(quick_reply_items=[
                            QuickReplyTextItem(
                                title='๋‹ค๋ฅธ ์šด์„ธ๊ฒ€์ƒ‰',
                                payload='brick|luck|get_started')
                        ]))
                ]
            except:
                send_message = [Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.')]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #3
0
 async def facebook(self, command):
     if command == 'get_started':
         send_message = [
             Message(
                 attachment=ImageAttachment(
                     url=BRICK_DEFAULT_IMAGE
                 )
             ),
             Message(
                 text='์•ˆ๋…•ํ•˜์„ธ์š”. ์žฅ์†Œ ํ…Œ์ŠคํŠธ์ž…๋‹ˆ๋‹ค.'
             ),
             Message(
                 text='ํ˜„์žฌ์œ„์น˜๋ฅผ ๋ณด๋‚ด์ฃผ์„ธ์š”.',
                 quick_replies=QuickReply(
                     quick_reply_items=[
                         QuickReplyLocationItem()
                     ]
                 )
             )
         ]
         await self.fb.send_messages(send_message)
     return None
Beispiel #4
0
from blueforge.apis.facebook import CreateFacebookApiClient, RequestDataFormat, Recipient, Message, QuickReplyTextItem, \
    QuickReply

client = CreateFacebookApiClient(
    access_token='d')



recipient = Recipient(recipient_id='1053565541409779')
quick_replies = [QuickReplyTextItem(title='์˜ˆ', payload='yes', image_url=None),
                 QuickReplyTextItem(title='์•„๋‹ˆ์š”', payload='no', image_url=None)]

message = Message(text='Hard Study', quick_replies=QuickReply(quick_reply_items=quick_replies))
final_message = RequestDataFormat(recipient=recipient, message=message)
print(client.send_message(final_message))

Beispiel #5
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='์™ธ๊ต๋ถ€์—์„œ ์ œ๊ณตํ•˜๋Š” "ํ•ด์™ธ๊ตญ๊ฐ€์ •๋ณด ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='ํ•ด์™ธ๊ตญ๊ฐ€์ •๋ณด ์„œ๋น„์Šค',
                                subtitle='์™ธ๊ต๋ถ€์—์„œ ์ œ๊ณตํ•˜๋Š” "ํ•ด์™ธ๊ตญ๊ฐ€์ •๋ณด ์„œ๋น„์Šค"์—์š”.')
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            country = input_data['store'][0]['value']

            res = requests.get(
                url=
                'http://apis.data.go.kr/1262000/CountryBasicService/getCountryBasicList?serviceKey=%s&numOfRows=10&pageSize=10&pageNo=1&startPage=1&countryName=%s'
                % (input_data['data']['api_key'],
                   urllib.parse.quote_plus(country)))
            items = get_items_from_xml(res)

            if type(items) is dict:
                if items.get('code', '00') == '99' or items.get('code',
                                                                '00') == '30':
                    send_message = [
                        Message(
                            text=
                            'chatbrick ํ™ˆํŽ˜์ด์ง€์— ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ API key๋ฅผ ์ž…๋ ฅํ–ˆ์–ด์š”. ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.',
                        )
                    ]
                else:
                    send_message = [Message(text=UNKNOWN_ERROR_MSG)]
            else:
                if len(items) == 0:
                    send_message = [
                        Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ๊ตญ๊ฐ€๊ฒ€์ƒ‰',
                                        payload='brick|country|get_started')
                                ]))
                    ]
                else:
                    items[0]['basic'] = remove_html_tag(items[0]['basic'])
                    send_message = [
                        Message(attachment=ImageAttachment(
                            url=download_and_save_image(items[0]['imgUrl']))),
                        Message(
                            text=
                            '{continent}\n*{countryName}({countryEnName})*\n{basic}'
                            .format(**items[0]),
                            quick_replies=QuickReply(quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ๊ตญ๊ฐ€๊ฒ€์ƒ‰',
                                    payload='brick|country|get_started')
                            ]))
                    ]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #6
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='Microsoft Azure-AI Cognitive์—์„œ ์ œ๊ณตํ•˜๋Š” "๋‘์žฅ์˜ ์‚ฌ์ง„์ด ์–ผ๋งˆ๋‚˜ ๋‹ฎ์•˜๋Š”์ง€ ์•Œ๋ ค๋“œ๋ฆฌ๋Š” ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=BRICK_DEFAULT_IMAGE,
                            title='๋‘์žฅ์˜ ์‚ฌ์ง„์ด ์–ผ๋งˆ๋‚˜ ๋‹ฎ์•˜๋Š”์ง€ ์•Œ๋ ค๋“œ๋ฆฌ๋Š” ์„œ๋น„์Šค',
                            subtitle=
                            'Microsoft Azure-AI Cognitive์—์„œ ์ œ๊ณตํ•˜๋Š” "๋‘์žฅ์˜ ์‚ฌ์ง„์ด ์–ผ๋งˆ๋‚˜ ๋‹ฎ์•˜๋Š”์ง€ ์•Œ๋ ค๋“œ๋ฆฌ๋Š” ์„œ๋น„์Šค"์—์š”.'
                        )
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            face_1 = input_data['store'][0]['value']
            face_2 = input_data['store'][1]['value']

            face_1_res = await Face.get_face_id(input_data['data'], face_1)

            face_2_res = await Face.get_face_id(input_data['data'], face_2)

            if type(face_2_res) is dict and face_2_res.get('error', False):
                send_message = [
                    Message(
                        text='์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.\n๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.\n\nCode: %s\nMessage: %s'
                        % (face_2_res['error'].get('code'),
                           face_2_res['error'].get('message')),
                        quick_replies=QuickReply(quick_reply_items=[
                            QuickReplyTextItem(
                                title='๋‹ค๋ฅธ ์–ผ๊ตด๋น„๊ต',
                                payload='brick|face|get_started')
                        ]))
                ]
            elif type(face_1_res) is dict and face_1_res.get('error', False):
                send_message = [
                    Message(
                        text='์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.\n๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.\n\nCode: %s\nMessage: %s'
                        % (face_1_res['error'].get('code'),
                           face_1_res['error'].get('message')),
                        quick_replies=QuickReply(quick_reply_items=[
                            QuickReplyTextItem(
                                title='๋‹ค๋ฅธ ์–ผ๊ตด๋น„๊ต',
                                payload='brick|face|get_started')
                        ]))
                ]
            else:
                if len(face_1_res) == 0 or len(face_2_res) == 0:
                    send_message = [
                        Message(text='์–ผ๊ตด ๊ฐ์ง€๋ฅผ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.\n๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.',
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์–ผ๊ตด๋น„๊ต',
                                        payload='brick|face|get_started')
                                ]))
                    ]
                else:
                    face_compare = await Face.get_data(input_data['data'],
                                                       face_1_res[0]['faceId'],
                                                       face_2_res[0]['faceId'])
                    if len(face_compare) == 0:
                        send_message = [
                            Message(
                                text='๋„๋Œ€์ฒด ๋‹ฎ์€ ๊ตฌ์„์„ ์ฐพ์œผ๋ ค์•ผ ์ฐพ์„ ์ˆ˜๊ฐ€ ์—†๋„ค์š”.',
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์–ผ๊ตด๋น„๊ต',
                                        payload='brick|face|get_started')
                                ]))
                        ]
                    else:

                        send_message = [
                            Message(
                                text=
                                '์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”.\n1์ด ๋งŒ์ ์ด์—์š”.\n์˜ˆ) 0.37508 ์€ 37% ๋‹ฎ์€๊ฑฐ์—์š”.'
                            ),
                            Message(
                                text='๋‘๊ตฌ๋‘๊ตฌ!! ๋”ฑ ์ด์ •๋„ ๋‹ฎ์•˜๋„ค์š”.\n๋‹ฎ์Œ์ˆ˜์น˜: {confidence}'.
                                format(**face_compare[0]),
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์–ผ๊ตด๋น„๊ต',
                                        payload='brick|face|get_started')
                                ]))
                        ]

            await self.fb.send_messages(send_message)
            await self.brick_db.delete()
        return None
Beispiel #7
0
def web_hook(request):
    print(request)
    if request.method == 'GET':
        if request.GET.get('hub.verify_token') == verify_token:
            return HttpResponse(request.GET.get('hub.challenge'))
    elif request.method == 'POST':
        print(request.body)
        data = json.loads(request.body.decode('UTF-8'))


        for entry in data['entry']:
            for message in entry['messaging']:
                receiver = message['sender']['id']
                if 'message' in message:
                    if 'quick_reply' in  message['message']:
                        payload = message['message']['quick_reply']['payload']
                        if payload == '1':
                            send_message = Message(text='1. ํ‰์ผ ์•„์นจ 8์‹œ ์ด์ „ ์ฃผ๋ฌธ๊ฑด๊นŒ์ง€ ๋Œ€๋ถ€๋ถ„ ๋‹น์ผ ๋ฐฐ์†ก๋ฉ๋‹ˆ๋‹ค. \n\n2. 8์‹œ ์ดํ›„ ์ฃผ๋ฌธ๊ฑด์€ ๋‹ค์Œ๋‚  ๋ฐฐ์†ก๋ฉ๋‹ˆ๋‹ค. \n๊ธˆ์š”์ผ 8์‹œ ์ดํ›„ ์ฃผ๋ฌธ๊ฑด์€ ๋‹ค์Œ์ฃผ ์›”์š”์ผ์— ๋ฐฐ์†ก๋ฉ๋‹ˆ๋‹ค.\n\n3. ๋ธŒ๋ผ์šด๋ฐฑ ์ปคํ”ผ๋Š” CJ ๋Œ€ํ•œํ†ต์šด์„ ํ†ตํ•ด ์ปคํ”ผ๋ฅผ ๋ณด๋‚ด๋“œ๋ฆฝ๋‹ˆ๋‹ค.\n์‡ผํ•‘๋ชฐ์—์„œ ๊ตฌ๋งคํ•˜์‹  ๊ฒฝ์šฐ, ํƒ๋ฐฐ ์ถœ๊ณ ์‹œ ๋ฌธ์ž๋ฉ”์‹œ์ง€๋กœ ์†ก์žฅ ๋ฒˆํ˜ธ๋ฅผ ์•ˆ๋‚ดํ•ด๋“œ๋ฆฝ๋‹ˆ๋‹ค. \n๋ฌธ์ž๋กœ ๋ฐ›์œผ์‹  ์†ก์žฅ๋ฒˆํ˜ธ๋ฅผ ๋ณต์‚ฌํ•˜์…”์„œ ์•„๋ž˜ CJ ๋Œ€ํ•œํ†ต์šด ๋ฐฐ์†ก์กฐํšŒ ์‚ฌ์ดํŠธ์—์„œ ์กฐํšŒํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.\n\n4. ์ฝœ๋“œ๋ธŒ๋ฃจ์™€ ์›๋‘๋ฅผ ๊ฐ™์ด ์ฃผ๋ฌธํ•˜์‹œ๋ฉด ๊ฐ๊ฐ ๋‹ค๋ฅธ ๊ณณ์—์„œ ๋ฐฐ์†ก๋˜์–ด, ํƒ๋ฐฐ๋ฅผ ๋‘๊ฐœ๋กœ ๋‚˜๋ˆ  ๋ฐ›์œผ์‹ญ๋‹ˆ๋‹ค.\n\n๋” ๊ถ๊ธˆํ•˜์‹  ์ ์€ ์–ธ์ œ๋“  ๋ฌธ์˜์ฃผ์„ธ์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค^^')
                        elif payload == '2':
                            send_message = Message(text='1. ์ƒ˜ํ”Œ ์‹ ์ฒญ : ์•„๋ž˜ ๋งํฌ๋ฅผ ๋ˆŒ๋Ÿฌ ์ƒ˜ํ”Œ ๋ฐœ์†ก์— ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.\n๋ง› ๋ณด์‹œ๊ณ  ๊ถ๊ธˆํ•˜์‹  ์‚ฌํ•ญ์ด๋‚˜ ์ถ”๊ฐ€ ์š”์ฒญ ์‚ฌํ•ญ์ด ์žˆ์œผ์‹œ๋ฉด ์–ธ์ œ๋“  ๋ฌธ์˜์ฃผ์„ธ์š”!\n\n2. ์ƒ˜ํ”Œ ๋ฐฐ์†ก : ์‹ ์ฒญํ•ด์ฃผ์‹  ํ›„ 2~3์ผ ์ด๋‚ด ๋ฐฐ์†ก์ด ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค. \n์‹ ์ฒญ์ด ๋“ค์–ด์˜จ ์ˆœ์„œ๋Œ€๋กœ ์ˆœ์ฐจ์ ์œผ๋กœ ๋ฐฐ์†กํ•ด๋“œ๋ฆฌ์˜ค๋‹ˆ ์กฐ๊ธˆ๋งŒ ๊ธฐ๋‹ค๋ ค์ฃผ์„ธ์š”^^ \n\n๋” ๊ถ๊ธˆํ•˜์‹  ์ ์€ ์–ธ์ œ๋“  ๋ฌธ์˜์ฃผ์„ธ์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค^^')
                    else:
                        text = message['message']['text']


                        if text =='์„ ํƒ':
                            quick_replies = [QuickReplyTextItem(title='์ œํ’ˆ ๋ฐฐ์†ก ์ผ์ •', payload='1', image_url=None),
                                             QuickReplyTextItem(title='์ƒ˜ํ”Œ ์‹ ์ฒญ ๋ฐฉ๋ฒ•๊ณผ ์ƒ˜ํ”Œ ๋ฐฐ์†ก', payload='2', image_url=None)]
                            send_message = Message(text='์›ํ•˜์‹œ๋Š” ๋ฒ„ํŠผ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”', quick_replies=QuickReply(quick_reply_items=quick_replies))
                        else :
                            send_message = Message(text='์•ˆ๋…•ํ•˜์„ธ์š”. ๋ธŒ๋ผ์šด๋ฐฑ ์ปคํ”ผ์ž…๋‹ˆ๋‹ค.\n๊ถ๊ธˆํ•˜์‹  ์ ์€ ๋ณธ ๊ณต์‹ ์นด์นด์˜คํ†ก ์•„์ด๋”” / ๊ณต์‹ ์ „ํ™” 1644-1530 ๋กœ ์—ฐ๋ฝ ์ฃผ์‹œ๋ฉด ์–ธ์ œ๋“ ์ง€ ์นœ์ ˆํžˆ ๋‹ต๋ณ€๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค! \n\n"์„ ํƒ"์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.')


                    req.send_message(RequestDataFormat(recipient=Recipient(recipient_id=receiver),
                                                           message=send_message))
        return JsonResponse(data)
    return HttpResponse('Failed to request', status=404)
Beispiel #8
0
    async def facebook(self, command):
        if command == 'get_started':
            #     send_message = [
            #         Message(
            #             attachment=ImageAttachment(
            #                 url=BRICK_DEFAULT_IMAGE
            #             )
            #         ),
            #         Message(
            #             text='์ธ์ฒœ๊ตญ์ œ๊ณตํ•ญ๊ณต์‚ฌ์—์„œ ์ œ๊ณตํ•˜๋Š” "์ถœ๊ตญ์žฅ ๋Œ€๊ธฐ์ธ์› ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.'
            #         ),
            #         Message(
            #             attachment=TemplateAttachment(
            #                 payload=GenericTemplate(
            #                     elements=[
            #                         Element(
            #                             image_url='https://www.chatbrick.io/api/static/brick/img_brick_13_002.png',
            #                             title='์ œ 1์—ฌ๊ฐํ„ฐ๋ฏธ๋„',
            #                             subtitle='์ œ 1์—ฌ๊ฐํ„ฐ๋ฏธ๋„์˜ ๊ฒŒ์ดํŠธ๋ณ„ ๋Œ€๊ธฐ์ธ์›์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
            #                             buttons=[
            #                                 PostBackButton(
            #                                     title='1์—ฌ๊ฐํ„ฐ๋ฏธ๋„ ์กฐํšŒ',
            #                                     payload='brick|icn|1'
            #                                 )
            #                             ]
            #                         ),
            #                         Element(
            #                             image_url='https://www.chatbrick.io/api/static/brick/img_brick_13_002.png',
            #                             title='์ œ 2์—ฌ๊ฐํ„ฐ๋ฏธ๋„',
            #                             subtitle='์ œ 2์—ฌ๊ฐํ„ฐ๋ฏธ๋„์˜ ๊ฒŒ์ดํŠธ๋ณ„ ๋Œ€๊ธฐ์ธ์›์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
            #                             buttons=[
            #                                 PostBackButton(
            #                                     title='2์—ฌ๊ฐํ„ฐ๋ฏธ๋„ ์กฐํšŒ',
            #                                     payload='brick|icn|2'
            #                                 )
            #                             ]
            #                         )
            #                     ]
            #                 )
            #             )
            #         )
            #     ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=BRICK_DEFAULT_IMAGE,
                            title='์ถœ๊ตญ์žฅ ๋Œ€๊ธฐ์ธ์› ์กฐํšŒ ์„œ๋น„์Šค',
                            subtitle='์ธ์ฒœ๊ตญ์ œ๊ณตํ•ญ๊ณต์‚ฌ์—์„œ ์ œ๊ณตํ•˜๋Š” "์ถœ๊ตญ์žฅ ๋Œ€๊ธฐ์ธ์› ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.')
                    ]))),
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=
                            'https://www.chatbrick.io/api/static/brick/img_brick_13_002.png',
                            title='์ œ 1์—ฌ๊ฐํ„ฐ๋ฏธ๋„',
                            subtitle='์ œ 1์—ฌ๊ฐํ„ฐ๋ฏธ๋„์˜ ๊ฒŒ์ดํŠธ๋ณ„ ๋Œ€๊ธฐ์ธ์›์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
                            buttons=[
                                PostBackButton(title='1์—ฌ๊ฐํ„ฐ๋ฏธ๋„ ์กฐํšŒ',
                                               payload='brick|icn|1')
                            ]),
                        Element(
                            image_url=
                            'https://www.chatbrick.io/api/static/brick/img_brick_13_002.png',
                            title='์ œ 2์—ฌ๊ฐํ„ฐ๋ฏธ๋„',
                            subtitle='์ œ 2์—ฌ๊ฐํ„ฐ๋ฏธ๋„์˜ ๊ฒŒ์ดํŠธ๋ณ„ ๋Œ€๊ธฐ์ธ์›์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
                            buttons=[
                                PostBackButton(title='2์—ฌ๊ฐํ„ฐ๋ฏธ๋„ ์กฐํšŒ',
                                               payload='brick|icn|2')
                            ])
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == '1' or command == '2':
            input_data = await self.brick_db.get()

            res = requests.get(
                url=
                'http://openapi.airport.kr/openapi/service/StatusOfDepartures/getDeparturesCongestion?serviceKey=%s&terno=%s'
                % (input_data['data']['api_key'], command),
                headers={
                    'User-Agent':
                    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'
                })

            items = get_items_from_xml(res)

            if type(items) is dict:
                if items.get('code', '00') == '99' or items.get('code',
                                                                '00') == '30':
                    send_message = [
                        Message(
                            text=
                            'chatbrick ํ™ˆํŽ˜์ด์ง€์— ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ API key๋ฅผ ์ž…๋ ฅํ–ˆ์–ด์š”. ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.',
                        )
                    ]
                else:
                    send_message = [Message(text=UNKNOWN_ERROR_MSG)]
            else:
                if command == '1':
                    the_other = '2'
                else:
                    the_other = '1'

                raw_data = items[0]
                sending_message = '์ œ {terno} ์—ฌ๊ฐํ„ฐ๋ฏธ๋„\n์กฐํšŒ๋‚ ์งœ : {cgtdt}\n์กฐํšŒ์‹œ๊ฐ„ : {cgthm}'.format(
                    **raw_data)

                if command == '1':
                    sending_message += '\n2๋ฒˆ ์ถœ๊ตญ์žฅ: %s๋ช… (%s)' % (
                        raw_data['gateinfo1'], GATE_INFO[raw_data['gate1']])
                    sending_message += '\n3๋ฒˆ ์ถœ๊ตญ์žฅ: %s๋ช… (%s)' % (
                        raw_data['gateinfo2'], GATE_INFO[raw_data['gate2']])
                    sending_message += '\n4๋ฒˆ ์ถœ๊ตญ์žฅ: %s๋ช… (%s)' % (
                        raw_data['gateinfo3'], GATE_INFO[raw_data['gate3']])
                    sending_message += '\n5๋ฒˆ ์ถœ๊ตญ์žฅ: %s๋ช… (%s)' % (
                        raw_data['gateinfo4'], GATE_INFO[raw_data['gate4']])
                elif command == '2':
                    sending_message += '\n1๋ฒˆ ์ถœ๊ตญ์žฅ: %s๋ช… (%s)' % (
                        raw_data['gateinfo1'], GATE_INFO[raw_data['gate1']])
                    sending_message += '\n2๋ฒˆ ์ถœ๊ตญ์žฅ: %s๋ช… (%s)' % (
                        raw_data['gateinfo2'], GATE_INFO[raw_data['gate2']])

                send_message = [
                    Message(
                        text=sending_message,
                        quick_replies=QuickReply(quick_reply_items=[
                            QuickReplyTextItem(title='์ƒˆ๋กœ๊ณ ์นจ',
                                               payload='brick|icn|%s' %
                                               command),
                            QuickReplyTextItem(title='์ œ%s์—ฌ๊ฐํ„ฐ๋ฏธ๋„ ์กฐํšŒ' % the_other,
                                               payload='brick|icn|%s' %
                                               the_other)
                        ]))
                ]

            await self.fb.send_messages(send_message)
        return None
Beispiel #9
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='ํ•œ๊ตญ์ฒœ๋ฌธ์—ฐ๊ตฌ์›์—์„œ ์ œ๊ณตํ•˜๋Š” "์‰ฌ๋Š”๋‚  ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.'
            #     ),
            #     Message(
            #         attachment=TemplateAttachment(
            #             payload=GenericTemplate(
            #                 elements=[
            #                     Element(
            #                         image_url='https://www.chatbrick.io/api/static/brick/img_brick_11_002.png',
            #                         title='์ด๋ฒˆ๋‹ฌ์— ์‰ฌ๋Š”๋‚ ',
            #                         subtitle='์ด๋ฒˆ๋‹ฌ์— ๊ณตํœด์ผ์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
            #                         buttons=[
            #                             PostBackButton(
            #                                 title='์ด๋ฒˆ๋‹ฌ์กฐํšŒ',
            #                                 payload='brick|holiday|this_month'
            #                             )
            #                         ]
            #                     ),
            #                     Element(
            #                         image_url='https://www.chatbrick.io/api/static/brick/img_brick_11_002.png',
            #                         title='์ง€์ •ํ•œ ๋…„/์›”์— ์‰ฌ๋Š”๋‚ ',
            #                         subtitle='์ž…๋ ฅํ•˜์‹  ๋…„/์›”์˜ ๊ณตํœด์ผ์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
            #                         buttons=[
            #                             PostBackButton(
            #                                 title='์กฐํšŒํ•  ๋…„/์›” ์ž…๋ ฅ',
            #                                 payload='brick|holiday|specify_month'
            #                             )
            #                         ]
            #                     )
            #                 ]
            #             )
            #         )
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='์‰ฌ๋Š”๋‚  ์กฐํšŒ ์„œ๋น„์Šค',
                                subtitle='ํ•œ๊ตญ์ฒœ๋ฌธ์—ฐ๊ตฌ์›์—์„œ ์ œ๊ณตํ•˜๋Š” "์‰ฌ๋Š”๋‚  ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.')
                    ]))),
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=
                            'https://www.chatbrick.io/api/static/brick/img_brick_11_002.png',
                            title='์ด๋ฒˆ๋‹ฌ์— ์‰ฌ๋Š”๋‚ ',
                            subtitle='์ด๋ฒˆ๋‹ฌ์— ๊ณตํœด์ผ์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
                            buttons=[
                                PostBackButton(
                                    title='์ด๋ฒˆ๋‹ฌ์กฐํšŒ',
                                    payload='brick|holiday|this_month')
                            ]),
                        Element(
                            image_url=
                            'https://www.chatbrick.io/api/static/brick/img_brick_11_002.png',
                            title='์ง€์ •ํ•œ ๋…„/์›”์— ์‰ฌ๋Š”๋‚ ',
                            subtitle='์ž…๋ ฅํ•˜์‹  ๋…„/์›”์˜ ๊ณตํœด์ผ์„ ์•Œ๋ ค๋“œ๋ ค์š”.',
                            buttons=[
                                PostBackButton(
                                    title='์กฐํšŒํ•  ๋…„/์›” ์ž…๋ ฅ',
                                    payload='brick|holiday|specify_month')
                            ])
                    ])))
            ]
            await self.fb.send_messages(send_message)
        elif command == 'specify_month':
            await self.brick_db.save()

        elif command == 'final' or command == 'next_month' or command == 'prev_month' or command == 'this_month':
            if command == 'this_month':
                await self.brick_db.save(is_pass=True)

            input_data = await self.brick_db.get()
            year = input_data['store'][0]['value']
            month = input_data['store'][1]['value']

            if year.strip() == 'pass' or month.strip() == 'pass':
                today = datetime.datetime.today()
                year = today.year
                month = today.month

            if command == 'next_month':
                plus_month = dateutil.parser.parse(
                    '%s %s 01' % (year, month)) + relativedelta(months=1)
                year = plus_month.year
                month = plus_month.month

            elif command == 'prev_month':
                plus_month = dateutil.parser.parse(
                    '%s %s 01' % (year, month)) - relativedelta(months=1)
                year = plus_month.year
                month = plus_month.month

            if command == 'next_month' or command == 'prev_month':
                rslt = await self.brick_db.update({
                    '$set': {
                        'store.0.value': str(year),
                        'store.1.value': str(month)
                    }
                })

            if self.fb.log_id is None:
                self.fb.log_id = 'FBSendMessage|%d' % int(time.time() * 1000)
            res = requests.get(
                url=
                'http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService/getRestDeInfo?serviceKey=%s&solYear=%s&solMonth=%s'
                % (input_data['data']['api_key'], year,
                   str(month).rjust(2, '0')))
            save_a_log_to_server({
                'log_id': self.fb.log_id,
                'user_id': self.fb.user_id,
                'os': '',
                'application': 'facebook',
                'api_code': 'holiday',
                'api_provider_code': 'chatbrick',
                'origin': 'webhook_server',
                'end': int(time.time() * 1000),
                'remark': '์‰ฌ๋Š”๋‚  ์กฐํšŒ ์™ธ๋ถ€ API ์š”์ฒญ์„ ๋ณด๋ƒ„'
            })
            items = get_items_from_xml(res)

            if type(items) is dict:
                if items.get('code', '00') == '99' or items.get('code',
                                                                '00') == '30':
                    send_message = [
                        Message(
                            text=
                            'chatbrick ํ™ˆํŽ˜์ด์ง€์— ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ API key๋ฅผ ์ž…๋ ฅํ–ˆ์–ด์š”. ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.',
                        )
                    ]
                else:
                    send_message = [Message(text=UNKNOWN_ERROR_MSG)]
            else:
                if len(items) == 0:
                    if command == 'prev_month' or command == 'this_month':
                        send_message = [
                            Message(attachment=TemplateAttachment(
                                payload=ButtonTemplate(
                                    text='%s-%s\n์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.' %
                                    (year, month),
                                    buttons=[
                                        PostBackButton(
                                            title='์ด์ „๋‹ฌ ์กฐํšŒ',
                                            payload='brick|holiday|prev_month'
                                        ),
                                        PostBackButton(
                                            title='๋‹ค์Œ๋‹ฌ ์กฐํšŒ',
                                            payload='brick|holiday|next_month')
                                    ])))
                        ]
                    else:
                        send_message = [
                            Message(
                                text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ๋‹ฌ ์กฐํšŒํ•˜๊ธฐ',
                                        payload='brick|holiday|get_started')
                                ]))
                        ]

                else:
                    sending_message = []
                    for item in items:
                        sending_message.append(
                            '๋‚ ์งœ: {locdate}\n๊ณตํœด์ผ ์œ ๋ฌด: {isHoliday}\n๊ณตํœด์ผ ๋‚ด์šฉ: {dateName}'
                            .format(**item))

                    send_message = [
                        Message(attachment=TemplateAttachment(
                            payload=ButtonTemplate(
                                text='\n\n'.join(sending_message),
                                buttons=[
                                    PostBackButton(
                                        title='์ด์ „๋‹ฌ ์กฐํšŒ',
                                        payload='brick|holiday|prev_month'),
                                    PostBackButton(
                                        title='๋‹ค์Œ๋‹ฌ ์กฐํšŒ',
                                        payload='brick|holiday|next_month')
                                ])))
                    ]
            await self.fb.send_messages(send_message)
        return None
Beispiel #10
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='๊ณผํ•™๊ธฐ์ˆ ์ •๋ณดํ†ต์‹ ๋ถ€ ์šฐ์ •์‚ฌ์—…๋ณธ๋ถ€์—์„œ ์ œ๊ณตํ•˜๋Š” "์šฐ์ฒด๊ตญํƒ๋ฐฐ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=BRICK_DEFAULT_IMAGE,
                            title='์šฐ์ฒด๊ตญํƒ๋ฐฐ์กฐํšŒ ์„œ๋น„์Šค',
                            subtitle='๊ณผํ•™๊ธฐ์ˆ ์ •๋ณดํ†ต์‹ ๋ถ€ ์šฐ์ •์‚ฌ์—…๋ณธ๋ถ€์—์„œ ์ œ๊ณตํ•˜๋Š” "์šฐ์ฒด๊ตญํƒ๋ฐฐ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.'
                        )
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()

        elif command == 'final':
            input_data = await self.brick_db.get()
            delivery_tracking_code = input_data['store'][0]['value']

            res = requests.get(
                url=
                'http://openapi.epost.go.kr/trace/retrieveLongitudinalService/retrieveLongitudinalService/getLongitudinalDomesticList?_type=json&serviceKey=%s&rgist=%s'
                % (input_data['data']['api_key'], delivery_tracking_code))

            parsed_data = res.json()
            items = []
            send_message = []
            if parsed_data.get('LongitudinalDomesticListResponse', False):

                if parsed_data['LongitudinalDomesticListResponse'][
                        'cmmMsgHeader']['successYN'] == 'Y':
                    if parsed_data['LongitudinalDomesticListResponse'].get(
                            'longitudinalDomesticList', False):
                        if type(parsed_data['LongitudinalDomesticListResponse']
                                ['longitudinalDomesticList']) is dict:
                            items.append(
                                parsed_data['LongitudinalDomesticListResponse']
                                ['longitudinalDomesticList'])
                        else:
                            items = parsed_data[
                                'LongitudinalDomesticListResponse'][
                                    'longitudinalDomesticList']
                    tracking_status = '๋ฐ›๋Š”๋ถ„: {addrseNm} / ๋ณด๋‚ด๋Š”๋ถ„: {applcntNm}\n๋ฐฐ์†ก์ƒํƒœ: {dlvySttus} ({dlvyDe})\n์ง„ํ–‰์ƒํ™ฉ:\n'.format(
                        **parsed_data['LongitudinalDomesticListResponse'])

                    if len(items) == 0:
                        tracking_status += '์ƒํƒœ ๊ธฐ๋ก ์—†์Œ'
                    else:
                        for item in items:
                            tracking_status += '{dlvyDate}  {dlvyTime}  {nowLc} {processSttus}  {detailDc}\n'.format(
                                **item)
                    send_message = [
                        Message(text=tracking_status,
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์šด์†ก์žฅ๋ฒˆํ˜ธ์กฐํšŒ',
                                        payload='brick|epost|get_started')
                                ]))
                    ]
                else:
                    send_message = [
                        Message(
                            text='์—๋Ÿฌ์ฝ”๋“œ: {returnCode}\n์—๋Ÿฌ๋ฉ”์‹œ์ง€: {errMsg}'.format(
                                **
                                parsed_data['LongitudinalDomesticListResponse']
                                ['cmmMsgHeader'], ),
                            quick_replies=QuickReply(quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ์šด์†ก์žฅ๋ฒˆํ˜ธ์กฐํšŒ',
                                    payload='brick|epost|get_started')
                            ]))
                    ]
            if len(send_message) == 0:
                send_message = [Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.')]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #11
0
    async def facebook(self, command):
        if command == 'get_started':
            send_message = [
                Message(
                    attachment=ImageAttachment(
                        url=BRICK_DEFAULT_IMAGE
                    )
                ),
                Message(
                    text='๊ฒฝ์ฐฐ์ฒญ์—์„œ ์ œ๊ณตํ•˜๋Š” "์Šต๋“๋ฌผ์กฐํšŒ ์„œ๋น„์Šค"์—์š”. ๋ถ„๋ฅ˜/์ง€์—ญ/๊ธฐ๊ฐ„์œผ๋กœ ์กฐํšŒ๊ธฐ๋Šฅ๊ณผ ์œ„์น˜๊ธฐ๋ฐ˜์œผ๋กœ ์กฐํšŒ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ด์š”.'
                ),
                Message(
                    attachment=TemplateAttachment(
                        payload=GenericTemplate(
                            elements=[
                                Element(
                                    image_url='https://www.chatbrick.io/api/static/brick/img_brick_02_002.png',
                                    title='๋ถ„๋ฅ˜/์ง€์—ญ/๊ธฐ๊ฐ„์œผ๋กœ ์กฐํšŒ',
                                    subtitle='์Šต๋“ํ•œ ๋ฌผํ’ˆ์— ๋Œ€ํ•œ ๋ถ„๋ฅ˜, ์ง€์—ญ, ๊ธฐ๊ฐ„ ์ •๋ณด๋ฅผ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์–ด์š”.',
                                    buttons=[
                                        PostBackButton(
                                            title='์กฐํšŒํ•˜๊ธฐ',
                                            payload='brick|lostnfound|Menu1'
                                        )
                                    ]
                                ),
                                Element(
                                    image_url='https://www.chatbrick.io/api/static/brick/img_brick_02_002.png',
                                    title='์œ„์น˜๊ธฐ๋ฐ˜์œผ๋กœ ์กฐํšŒ',
                                    subtitle='ํ˜„์žฌ ์œ„์น˜์ฃผ์†Œ์™€ ๊ทผ์ฒ˜์— ์œ„์น˜ํ•œ ์ง€๊ตฌ๋Œ€์˜ ์Šต๋“๋ฌผ ์ •๋ณด๋ฅผ ์กฐํšŒ ํ•  ์ˆ˜ ์žˆ์–ด์š”.',
                                    buttons=[
                                        PostBackButton(
                                            title='์กฐํšŒํ•˜๊ธฐ',
                                            payload='brick|lostnfound|Menu2'
                                        )
                                    ]
                                )
                            ]
                        )
                    )
                )
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save(show_msg=False)
        elif command == 'Menu1':
            pass
        elif command == 'final':
            input_data = await self.brick_db.get()
            keyword = input_data['store'][0]['value']
            to = datetime.datetime.today()
            today = '%d-%02d-%02d' % (to.year, to.month, to.day)
            res = requests.get(
                url='http://openapi.mpm.go.kr/openapi/service/RetrievePblinsttEmpmnInfoService/getList?serviceKey=%s&pageNo=1&startPage=1&numOfRows=20&pageSize=20&Pblanc_ty=e01&Begin_de=%s&Sort_order=1&Kwrd=%s' % (
                    input_data['data']['api_key'], today, keyword))

            items = get_items_from_xml(res)

            if len(items) == 0:
                send_message = [
                    Message(
                        text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                        quick_replies=QuickReply(
                            quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ํ‚ค์›Œ๋“œ๊ฒ€์ƒ‰',
                                    payload='brick|public_jobs|get_started'
                                )
                            ]
                        )
                    )
                ]
            else:
                sending_message = []
                for item in items:
                    sending_message.append('*{title}*\n{deptName}\n{regdate} ~ {enddate}'.format(**item))
                send_message = [
                    Message(
                        text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”'
                    ),
                    Message(
                        text='\n\n'.join(sending_message),
                        quick_replies=QuickReply(
                            quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ํ‚ค์›Œ๋“œ๊ฒ€์ƒ‰',
                                    payload='brick|public_jobs|get_started'
                                )
                            ]
                        )
                    )
                ]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #12
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='์ธํ„ฐ๋„ท์šฐ์ฒด๊ตญํŒ€์—์„œ ์ œ๊ณตํ•˜๋Š” "์šฐํŽธ๋ฒˆํ˜ธ์ฐพ๊ธฐ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(
                    attachment=TemplateAttachment(
                        payload=GenericTemplate(
                            elements=[
                                Element(image_url=BRICK_DEFAULT_IMAGE,
                                        title='์šฐํŽธ๋ฒˆํ˜ธ์ฐพ๊ธฐ ์„œ๋น„์Šค',
                                        subtitle='์ธํ„ฐ๋„ท์šฐ์ฒด๊ตญํŒ€์—์„œ ์ œ๊ณตํ•˜๋Š” "์šฐํŽธ๋ฒˆํ˜ธ์ฐพ๊ธฐ ์„œ๋น„์Šค"์—์š”.')
                            ]
                        )
                    )
                )
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            add_type = input_data['store'][0]['value']
            address = input_data['store'][1]['value']

            if add_type == '์ง€๋ฒˆ':
                a_type = 'dong'
            else:
                a_type = 'road'

            res = requests.get(
                url='http://openapi.epost.go.kr/postal/retrieveNewAdressAreaCdService/retrieveNewAdressAreaCdService/getNewAddressListAreaCd?_type=json&serviceKey=%s&searchSe=%s&srchwrd=%s&countPerPage=10&currentPage=1' % (
                    input_data['data']['api_key'], a_type, urllib.parse.quote_plus(address)))

            parsed_data = res.json()

            items = []
            if parsed_data.get('NewAddressListResponse', False):
                if parsed_data['NewAddressListResponse'].get('newAddressListAreaCd', False):
                    if type(parsed_data['NewAddressListResponse']['newAddressListAreaCd']) is dict:
                        items.append(parsed_data['NewAddressListResponse']['newAddressListAreaCd'])
                    else:
                        items = parsed_data['NewAddressListResponse']['newAddressListAreaCd']

            items.reverse()
            if len(items) == 0:
                send_message = [
                    Message(
                        text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                        quick_replies=QuickReply(
                            quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค์‹œ ๊ฒ€์ƒ‰ํ•˜๊ธฐ',
                                    payload='brick|address|get_started'
                                )
                            ]
                        )
                    )
                ]
            else:
                sending_message = []
                for item in items:
                    sending_message.append('{zipNo}\n{lnmAdres}\n{rnAdres}'.format(**item))

                send_message = [
                    Message(
                        text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”'
                    ),
                    Message(
                        text='\n\n'.join(sending_message),
                        quick_replies=QuickReply(
                            quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ์šฐํŽธ๋ฒˆํ˜ธ๊ฒ€์ƒ‰',
                                    payload='brick|address|get_started'
                                )
                            ]
                        )
                    )
                ]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #13
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='Microsoft Azure-AI Cognitive์—์„œ ์ œ๊ณตํ•˜๋Š” "์‚ฌ์ง„์† ๊ฐ์ •์„ ์ฝ์–ด๋“œ๋ฆฌ๋Š” ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=BRICK_DEFAULT_IMAGE,
                            title='์‚ฌ์ง„์† ๊ฐ์ •์„ ์ฝ์–ด๋“œ๋ฆฌ๋Š” ์„œ๋น„์Šค',
                            subtitle=
                            'Microsoft Azure-AI Cognitive์—์„œ ์ œ๊ณตํ•˜๋Š” "์‚ฌ์ง„์† ๊ฐ์ •์„ ์ฝ์–ด๋“œ๋ฆฌ๋Š” ์„œ๋น„์Šค"์—์š”.'
                        )
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            face_1 = input_data['store'][0]['value']

            res = await Emotion.get_data(input_data['data'], face_1)

            if type(res) is dict and res.get('error', False):
                send_message = [
                    Message(
                        text=
                        '[์—๋Ÿฌ๋ฐœ์ƒ]\nCode: {code}\nMessage: {message}\n\n๊ด€๋ฆฌ์ž์—๊ฒŒ ๋ฌธ์˜ ๋ฐ”๋ž๋‹ˆ๋‹ค.\[email protected]'
                        .format(**res['error']),
                        quick_replies=QuickReply(quick_reply_items=[
                            QuickReplyTextItem(
                                title='๋‹ค๋ฅธ ์‚ฌ์ง„๋ถ„์„',
                                payload='brick|emotion|get_started')
                        ]))
                ]
            else:
                if len(res) == 0:
                    send_message = [
                        Message(text='๊ฐ์ •์„ ์•Œ ์ˆ˜ ์—†์–ด์š” ใ…œใ…œ\n๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.',
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์‚ฌ์ง„๋ถ„์„',
                                        payload='brick|emotion|get_started')
                                ]))
                    ]
                else:
                    res_face = res[0]['faceAttributes']['emotion']
                    sorted_score = sorted(res_face.items(),
                                          key=operator.itemgetter(1),
                                          reverse=True)

                    send_message = [
                        Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”.'),
                        Message(text='๋‘๊ตฌ๋‘๊ตฌ!!\n์‚ฌ์ง„ ์†์˜ ์‚ฌ๋žŒ์˜ ๊ฐ์ •์€ %s์ด๋„ค์š”.' %
                                EMOTION[sorted_score[0][0]],
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์‚ฌ์ง„๋ถ„์„',
                                        payload='brick|emotion|get_started')
                                ]))
                    ]

            await self.fb.send_messages(send_message)
            await self.brick_db.delete()
        return None
Beispiel #14
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='์ธ์‚ฌํ˜์‹ ์ฒ˜์—์„œ ์ œ๊ณตํ•˜๋Š” "๊ณต๊ณต์ทจ์—…์ •๋ณด๊ฒ€์ƒ‰ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='๊ณต๊ณต์ทจ์—…์ •๋ณด๊ฒ€์ƒ‰ ์„œ๋น„์Šค',
                                subtitle='์ธ์‚ฌํ˜์‹ ์ฒ˜์—์„œ ์ œ๊ณตํ•˜๋Š” "๊ณต๊ณต์ทจ์—…์ •๋ณด๊ฒ€์ƒ‰ ์„œ๋น„์Šค"์—์š”.')
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
            await self.facebook('final')
        elif command == 'final':
            input_data = await self.brick_db.get()
            res = await PublicJobs.get_data(input_data)

            items = get_items_from_xml(res)

            if type(items) is dict:
                if items.get('code', '00') == '99' or items.get('code',
                                                                '00') == '30':
                    send_message = [
                        tg.SendMessage(
                            text=
                            'chatbrick ํ™ˆํŽ˜์ด์ง€์— ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ API key๋ฅผ ์ž…๋ ฅํ–ˆ์–ด์š”. ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.',
                        )
                    ]
                else:
                    send_message = [tg.SendMessage(text=UNKNOWN_ERROR_MSG)]
            else:
                if len(items) == 0:
                    send_message = [
                        Message(
                            text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                            quick_replies=QuickReply(quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค์‹œ ์‹œ๋„ํ•˜๊ธฐ',
                                    payload='brick|public_jobs|get_started')
                            ]))
                    ]
                else:
                    sending_message = []
                    for item in items:
                        sending_message.append(
                            '*{title}*\n{deptName}\n{regdate} ~ {enddate}'.
                            format(**item))
                    send_message = [
                        Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”'),
                        Message(
                            text='\n\n'.join(sending_message),
                            quick_replies=QuickReply(quick_reply_items=[
                                QuickReplyTextItem(
                                    title='์ƒˆ๋กœ๊ณ ์นจ',
                                    payload='brick|public_jobs|get_started')
                            ]))
                    ]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #15
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='ํ•œ๊ตญ์ˆ˜์ถœ์ž…์€ํ–‰์—์„œ ์ œ๊ณตํ•˜๋Š” "ํ™˜์œจ์ •๋ณด ์„œ๋น„์Šค"์—์š”.'
            #     ),
            #     Message(
            #         text='chatbrick์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ธˆ์œต์ •๋ณด๋Š” ํ•œ๊ตญ์ˆ˜์ถœ์ž…์€ํ–‰์œผ๋กœ๋ถ€ํ„ฐ ๋ฐ›๋Š” ์ •๋ณด๋กœ ํˆฌ์ž ์ฐธ๊ณ ์‚ฌํ•ญ์ด๋ฉฐ, ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๊ฑฐ๋‚˜ ์ง€์—ฐ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.\nchatbrick์€ ์ œ๊ณต๋œ ์ •๋ณด์— ์˜ํ•œ ํˆฌ์ž๊ฒฐ๊ณผ์— ๋ฒ•์ ์ฑ…์ž„์„ ์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ฒŒ์‹œ๋œ ์ •๋ณด๋Š” ๋ฌด๋‹จ์œผ๋กœ ๋ฐฐํฌํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='ํ™˜์œจ์ •๋ณด ์„œ๋น„์Šค',
                                subtitle='ํ•œ๊ตญ์ˆ˜์ถœ์ž…์€ํ–‰์—์„œ ์ œ๊ณตํ•˜๋Š” "ํ™˜์œจ์ •๋ณด ์„œ๋น„์Šค"์—์š”.')
                    ]))),
                Message(
                    text=
                    'chatbrick์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ธˆ์œต์ •๋ณด๋Š” ํ•œ๊ตญ์ˆ˜์ถœ์ž…์€ํ–‰์œผ๋กœ๋ถ€ํ„ฐ ๋ฐ›๋Š” ์ •๋ณด๋กœ ํˆฌ์ž ์ฐธ๊ณ ์‚ฌํ•ญ์ด๋ฉฐ, ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๊ฑฐ๋‚˜ ์ง€์—ฐ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.\nchatbrick์€ ์ œ๊ณต๋œ ์ •๋ณด์— ์˜ํ•œ ํˆฌ์ž๊ฒฐ๊ณผ์— ๋ฒ•์ ์ฑ…์ž„์„ ์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ฒŒ์‹œ๋œ ์ •๋ณด๋Š” ๋ฌด๋‹จ์œผ๋กœ ๋ฐฐํฌํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.'
                )
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            currency = input_data['store'][0]['value']

            rslt = await Currency.get_data(input_data['data']['api_key'])

            if len(rslt) == 0:
                send_message = [Message(text='๊ธˆ์ผ์˜ ํ†ตํ™” ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.')]
            else:
                send_message = []
                for money in rslt:
                    try:
                        if money['cur_unit'] == CURRENCY_UNIT['%02d' %
                                                              int(currency)]:
                            send_message = [
                                Message(
                                    text=
                                    '๊ตญ๊ฐ€/ํ†ตํ™”๋ช… : {cur_nm}\nํ†ตํ™”์ฝ”๋“œ : {cur_unit}\n์†ก๊ธˆ ๋ฐ›์„ ๋•Œ (1 {cur_nm} ๊ธฐ์ค€) : {ttb}์›\n์†ก๊ธˆ ๋ณด๋‚ผ ๋•Œ (1 {cur_nm} ๊ธฐ์ค€) : {tts}์›\n๋งค๋งค ๊ธฐ์ค€์œจ : {deal_bas_r} ์›\n์žฅ๋ถ€๊ฐ€๊ฒฉ : {bkpr}\n\n๋…„ํ™˜๊ฐ€๋ฃŒ์œจ : {yy_efee_r}\n10์ผํ™˜๊ฐ€๋ฃŒ์œจ : {ten_dd_efee_r}\n์„œ์šธ์™ธ๊ตญํ™˜์ค‘๊ณ„ ๋งค๋งค๊ธฐ์ค€์œจ : {kftc_deal_bas_r}\n์„œ์šธ์™ธ๊ตญํ™˜์ค‘๊ณ„ ์žฅ๋ถ€๊ฐ€๊ฒฉ : {kftc_bkpr}'
                                    .format(**money),
                                    quick_replies=QuickReply(
                                        quick_reply_items=[
                                            QuickReplyTextItem(
                                                title='๋‹ค๋ฅธ ํ™˜์œจ์ •๋ณด์กฐํšŒ',
                                                payload=
                                                'brick|currency|get_started')
                                        ]))
                            ]
                            break
                    except ValueError as ex:
                        send_message = [
                            Message(
                                text='์ˆซ์ž๋งŒ ์ž…๋ ฅํ•˜์…”์•ผ ๋˜์š”.\n์—๋Ÿฌ ๋ฉ”์‹œ์ง€: %s' % str(ex),
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ํ™˜์œจ์ •๋ณด์กฐํšŒ',
                                        payload='brick|currency|get_started')
                                ]))
                        ]

                if len(send_message) == 0:
                    send_message = [Message(text='๊ฒ€์ƒ‰๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.')]

            await self.fb.send_messages(send_message)
            await self.brick_db.delete()
        return None
Beispiel #16
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='IBM Bluemix์—์„œ ์ œ๊ณตํ•˜๋Š” "์ž์†Œ์„œ๋ฅผ ๋ถ„์„ํ•ด์ฃผ๋Š” ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(
                    attachment=TemplateAttachment(
                        payload=GenericTemplate(
                            elements=[
                                Element(image_url=BRICK_DEFAULT_IMAGE,
                                        title='์ž์†Œ์„œ๋ฅผ ๋ถ„์„ํ•ด์ฃผ๋Š” ์„œ๋น„์Šค',
                                        subtitle='IBM Bluemix์—์„œ ์ œ๊ณตํ•˜๋Š” "์ž์†Œ์„œ๋ฅผ ๋ถ„์„ํ•ด์ฃผ๋Š” ์„œ๋น„์Šค"์—์š”.')
                            ]
                        )
                    )
                )
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            contents = input_data['store'][0]['value']

            try:
                parsed_result = await PersonalityInsight.get_data(input_data['data'], contents)

                sending_message = '๋‘๊ตฌ๋‘๊ตฌ!\n์ž์†Œ์„œ์— ๋ถ„์„๊ฒฐ๊ณผ\n\n์ด ๋‹จ์–ด์ˆ˜ {word_count}\n'.format(
                    word_count=parsed_result.get('word_count', '0'))

                for item in parsed_result.get('personality', [])[:5]:
                    sending_message += '{name} : {percentile}\n'.format(**item)

                sending_message += '\n'

                for item in parsed_result.get('warnings', []):
                    sending_message += '\n{warning_id}\n{message}\n'.format(**item)

                send_message = [
                    Message(
                        text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”.'
                    ),
                    Message(
                        text=sending_message,
                        quick_replies=QuickReply(
                            quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ์ž์†Œ์„œ๋ถ„์„',
                                    payload='brick|personality|get_started'
                                )
                            ]
                        )
                    )
                ]
            except Exception as ex:
                send_message = [
                    Message(
                        text='์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.\n์ตœ์†Œ 100๋‹จ์–ด ์ด์ƒ์ธ ์ž์†Œ์„œ ๊ธ€์„ ์ž…๋ ฅํ•˜์‹œ๊ฑฐ๋‚˜ ์ž ์‹œ ํ›„์— ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.\n\n์—๋Ÿฌ ๋ฉ”์‹œ์ง€: %s' % str(ex)
                    )]

            await self.fb.send_messages(send_message)
            await self.brick_db.delete()
        return None
Beispiel #17
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='Naver Developers์—์„œ ์ œ๊ณตํ•˜๋Š” "์‚ฌ์ง„์† ์œ ๋ช…์ธ ์ฐพ๊ธฐ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='์‚ฌ์ง„์† ์œ ๋ช…์ธ ์ฐพ๊ธฐ ์„œ๋น„์Šค',
                                subtitle=
                                'Naver Developers์—์„œ ์ œ๊ณตํ•˜๋Š” "์‚ฌ์ง„์† ์œ ๋ช…์ธ ์ฐพ๊ธฐ ์„œ๋น„์Šค"์—์š”.')
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            contents = input_data['store'][0]['value']
            parsed_result = await Who.get_data(input_data['data'], contents)

            if parsed_result.get('faces', False):
                if len(parsed_result['faces']) == 0:
                    send_message = [Message(text='ํƒ์ง€๋œ ์–ผ๊ตด์ด ์—†์Šต๋‹ˆ๋‹ค.')]
                else:
                    send_message = [
                        Message(
                            text=
                            '์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”.\n1์ด ๋งŒ์ ์ด์—์š”.\n์˜ˆ) 0.37508 ์€ 37% ํ™•๋ฅ ์„ ๋งํ•˜๋Š”๊ฑฐ์—์š”. 56%์ •๋„๋ฉด ๊ฑฐ์˜ ๋™์ผ์ธ์ด๋ผ๊ณ  ๋ณผ ์ˆ˜ ์žˆ์–ด์š”.'
                        ),
                        Message(
                            text=
                            '๋‘๊ตฌ๋‘๊ตฌ!!\n์‚ฌ์ง„ ์†์˜ ์‚ฌ๋žŒ์€ {celebrity[confidence]}์˜ ํ™•๋ฅ ๋กœ {celebrity[value]}์ด๋„ค์š”.'
                            .format(**parsed_result['faces'][0]),
                            quick_replies=QuickReply(quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ์‚ฌ์ง„๋ถ„์„',
                                    payload='brick|who|get_started')
                            ]))
                    ]
            else:
                send_message = [
                    Message(
                        text='์—๋Ÿฌ์ฝ”๋“œ: {errorCode}\n์—๋Ÿฌ๋ฉ”์‹œ์ง€: {errorMessage}'.format(
                            **parsed_result),
                        quick_replies=QuickReply(quick_reply_items=[
                            QuickReplyTextItem(title='๋‹ค๋ฅธ ์‚ฌ์ง„๋ถ„์„',
                                               payload='brick|who|get_started')
                        ]))
                ]

            await self.fb.send_messages(send_message)
            await self.brick_db.delete()
        return None
Beispiel #18
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='์ค‘์•™์‘๊ธ‰์˜๋ฃŒ์„ผํ„ฐ์—์„œ ์ œ๊ณตํ•˜๋Š” "์‘๊ธ‰์‹ค๊ฒ€์ƒ‰ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='์‘๊ธ‰์‹ค๊ฒ€์ƒ‰ ์„œ๋น„์Šค',
                                subtitle='์ค‘์•™์‘๊ธ‰์˜๋ฃŒ์„ผํ„ฐ์—์„œ ์ œ๊ณตํ•˜๋Š” "์‘๊ธ‰์‹ค๊ฒ€์ƒ‰ ์„œ๋น„์Šค"์—์š”.')
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            state = input_data['store'][0]['value']
            town = input_data['store'][1]['value']

            res = requests.get(
                url=
                'http://apis.data.go.kr/B552657/ErmctInfoInqireService/getEgytListInfoInqire?serviceKey=%s&Q0=%s&Q1=%s&ORD=NAME&pageNo=1&startPage=1&numOfRows=3&pageSize=3'
                % (input_data['data']['api_key'], state, town))
            items = get_items_from_xml(res)

            if type(items) is dict:
                if items.get('code', '00') == '99' or items.get('code',
                                                                '00') == '30':
                    send_message = [
                        Message(
                            text=
                            'chatbrick ํ™ˆํŽ˜์ด์ง€์— ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ API key๋ฅผ ์ž…๋ ฅํ–ˆ์–ด์š”. ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.',
                        )
                    ]
                else:
                    send_message = [Message(text=UNKNOWN_ERROR_MSG)]
            else:
                if len(items) == 0:
                    send_message = [
                        Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์ง€์—ญ๊ฒ€์ƒ‰',
                                        payload='brick|emergency|get_started')
                                ]))
                    ]
                else:
                    send_message = [
                        Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ์—์š”'),
                        Message(
                            text=
                            '{dutyName}\n{dutyEmclsName}\n{dutyAddr}\n{dutyTel1}\n{dutyTel3}'
                            .format(**items[0]),
                            quick_replies=QuickReply(quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค๋ฅธ ์ง€์—ญ๊ฒ€์ƒ‰',
                                    payload='brick|emergency|get_started')
                            ]))
                    ]
                    if len(items) > 1:
                        for surplus_item in items[1:]:
                            send_message.insert(
                                1,
                                Message(
                                    text=
                                    '{dutyName}\n{dutyEmclsName}\n{dutyAddr}\n{dutyTel1}\n{dutyTel3}'
                                    .format(**surplus_item)))

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #19
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='Naver Developers์—์„œ ์ œ๊ณตํ•˜๋Š” "URL ์ค„์ด๊ธฐ ์„œ๋น„์Šค"์—์š”.'
            #     ),
            #     Message(
            #         attachment=TemplateAttachment(
            #             payload=GenericTemplate(
            #                 elements=[
            #                     Element(
            #                         image_url='https://www.chatbrick.io/api/static/brick/img_brick_23_002.png',
            #                         title='URL ์ค„์ด๊ธฐ',
            #                         subtitle='๋„ˆ๋ฌด ๊ธธ์—ˆ๋˜ URL์„ ์ค„์—ฌ๋“œ๋ ค์š”.',
            #                         buttons=[
            #                             PostBackButton(
            #                                 title='์ค„์ด๊ธฐ',
            #                                 payload='brick|shortener|short'
            #                             )
            #                         ]
            #                     )
            #                 ]
            #             )
            #         )
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=BRICK_DEFAULT_IMAGE,
                            title='URL ์ค„์ด๊ธฐ ์„œ๋น„์Šค',
                            subtitle='Naver Developers์—์„œ ์ œ๊ณตํ•˜๋Š” "URL ์ค„์ด๊ธฐ ์„œ๋น„์Šค"์—์š”.'
                        )
                    ]))),
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(
                            image_url=
                            'https://www.chatbrick.io/api/static/brick/img_brick_23_002.png',
                            title='URL ์ค„์ด๊ธฐ',
                            subtitle='๋„ˆ๋ฌด ๊ธธ์—ˆ๋˜ URL์„ ์ค„์—ฌ๋“œ๋ ค์š”.',
                            buttons=[
                                PostBackButton(title='์ค„์ด๊ธฐ',
                                               payload='brick|shortener|short')
                            ])
                    ])))
            ]
            await self.fb.send_messages(send_message)
        elif command == 'short':
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            url = input_data['store'][0]['value']

            result = await Shortener.get_short_url(
                input_data['data']['client_id'],
                input_data['data']['client_secret'], url)

            if result.get('errorCode', False):
                send_message = [Message(text='์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.\n๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.')]

                logger.error(result)
            else:
                send_message = [
                    Message(text='์ค„์—ฌ์ง„ URL ๊ฒฐ๊ณผ์—์š”.'),
                    Message(
                        text='%s' % result['result'].get('url', ''),
                        quick_replies=QuickReply(quick_reply_items=[
                            QuickReplyTextItem(title='๋‹ค๋ฅธ URL ์ค„์ด๊ธฐ',
                                               payload='brick|shortener|short')
                        ]))
                ]

            await self.fb.send_messages(send_message)
            await self.brick_db.delete()
        return None
Beispiel #20
0
    async def facebook(self, command):
        if command == 'get_started':
            send_message = [
                Message(
                    attachment=ImageAttachment(
                        url=BRICK_DEFAULT_IMAGE[1]
                    )
                ),
                Message(
                    text='๋ธ”๋ฃจํ•ต์—์„œ ์ œ๊ณตํ•˜๋Š” "๋ฉ”์ผ๋ณด๋‚ด๊ธฐ ์„œ๋น„์Šค"์˜ˆ์š”.'
                ),
                Message(
                    attachment=TemplateAttachment(
                        payload=GenericTemplate(
                            elements=[
                                Element(title='๋ฉ”์ผ์ „์†ก',
                                        subtitle='์ฑ—๋ด‡์—์„œ ๋ฉ”์ผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์–ด์š”',
                                        buttons=[
                                            PostBackButton(
                                                title='๋ฉ”์ผ๋ณด๋‚ด๊ธฐ',
                                                payload='brick|mailer|show_data'
                                            )
                                        ])
                            ]
                        )
                    )
                )
            ]
            await self.fb.send_messages(send_message)
        elif command == 'show_data':
            await self.brick_db.save()
        elif command == 'cancel':
            await self.brick_db.delete()
            await self.fb.send_message(
                message=Message(
                    text='๋ฉ”์ผ ๋ณด๋‚ด๊ธฐ๋ฅผ ์ทจ์†Œํ–ˆ์–ด์š”.',
                    quick_replies=QuickReply(
                        quick_reply_items=[
                            QuickReplyTextItem(
                                title='์ƒˆ ๋ฉ”์ผ๋ณด๋‚ด๊ธฐ',
                                payload='brick|mailer|show_data'
                            )
                        ]
                    )
                ))
        elif command == 'final':
            input_data = await self.brick_db.get()
            msg = MIMEText(input_data['store'][2]['value'])
            msg['Subject'] = '%s๋กœ๋ถ€ํ„ฐ ์ด๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.' % input_data['store'][0]['value']
            msg['To'] = input_data['store'][1]['value']
            self.smtp.ehlo()
            self.smtp.starttls()
            self.smtp.login(self.sender_email, self.sender_password)
            self.smtp.sendmail(self.sender_email, input_data['store'][1]['value'], msg.as_string())
            await self.fb.send_message(
                message=Message(
                    text='๋ฉ”์ผ ๋ณด๋‚ด๊ธฐ๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์–ด์š”.',
                    quick_replies=QuickReply(
                        quick_reply_items=[
                            QuickReplyTextItem(
                                title='์—ฐ์†ํ•˜์—ฌ ๋ฉ”์ผ๋ณด๋‚ด๊ธฐ',
                                payload='brick|mailer|show_data'
                            )
                        ]
                    )
                ))

        return None
Beispiel #21
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='ํ•œ๊ตญ์ „๋ ฅ๊ณต์‚ฌ์—์„œ ์ œ๊ณตํ•˜๋Š” "์ „๊ธฐ์ฐจ์ถฉ์ „์†Œ ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.'
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='์ „๊ธฐ์ฐจ์ถฉ์ „์†Œ ์กฐํšŒ ์„œ๋น„์Šค',
                                subtitle='ํ•œ๊ตญ์ „๋ ฅ๊ณต์‚ฌ์—์„œ ์ œ๊ณตํ•˜๋Š” "์ „๊ธฐ์ฐจ์ถฉ์ „์†Œ ์กฐํšŒ ์„œ๋น„์Šค"์—์š”.')
                    ])))
            ]
            await self.fb.send_messages(send_message)
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            place = input_data['store'][0]['value']

            res = requests.get(
                url=
                'http://openapi.kepco.co.kr/service/evInfoService/getEvSearchList?serviceKey=%s&numOfRows=100&pageSize=100&pageNo=1&startPage=1&addr=%s'
                % (input_data['data']['api_key'],
                   urllib.parse.quote_plus(place)))
            items = get_items_from_xml(res)

            if type(items) is dict:
                if items.get('code', '00') == '99' or items.get('code',
                                                                '00') == '30':
                    send_message = [
                        Message(
                            text=
                            'chatbrick ํ™ˆํŽ˜์ด์ง€์— ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ API key๋ฅผ ์ž…๋ ฅํ–ˆ์–ด์š”. ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.',
                        )
                    ]
                else:
                    send_message = [Message(text=UNKNOWN_ERROR_MSG)]
            else:
                if len(items) == 0:
                    send_message = [
                        Message(text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์ง€์—ญ๊ฒ€์ƒ‰',
                                        payload='brick|electric|get_started')
                                ]))
                    ]
                else:
                    sending_message = ''
                    for item in items:
                        sending_message += '์ถฉ์ „์†Œ๋ช… : {csNm}\n์ถฉ์ „์†ŒID : {cpId}\n์ถฉ์ „ํƒ€์ž… : {cpNm}\n์ƒํƒœ : {cpStat}\n์ฃผ์†Œ : {addr}\n\n'.format(
                            **item)

                    send_message = [
                        Message(text=sending_message,
                                quick_replies=QuickReply(quick_reply_items=[
                                    QuickReplyTextItem(
                                        title='๋‹ค๋ฅธ ์ถฉ์ „์†Œ ๊ฒ€์ƒ‰',
                                        payload='brick|electric|get_started')
                                ]))
                    ]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #22
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='๊ตญํ† ๊ตํ†ต๋ถ€์—์„œ ์ œ๊ณตํ•˜๋Š” "์—ด์ฐจ์กฐํšŒ ์„œ๋น„์Šค"์—์š”. ์ฝ”๋ ˆ์ผ/SRT ๋ชจ๋‘ ์กฐํšŒ ๊ฐ€๋Šฅํ•ด์š”.'
            #     ),
            #     Message(
            #         attachment=TemplateAttachment(
            #             payload=GenericTemplate(
            #                 elements=[
            #                     Element(
            #                         image_url='https://www.chatbrick.io/api/static/brick/img_brick_01_002.png',
            #                         title='์—ด์ฐจ์กฐํšŒ',
            #                         subtitle='์ฝ”๋ ˆ์ผ/SRT ๋ชจ๋‘ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์–ด์š”',
            #                         buttons=[
            #                             PostBackButton(
            #                                 title='์กฐํšŒํ•˜๊ธฐ',
            #                                 payload='brick|train|show_data'
            #                             )
            #                         ]
            #                     )
            #                 ]
            #             )
            #         )
            #     )
            # ]
            send_message = [
                Message(
                    attachment=TemplateAttachment(
                        payload=GenericTemplate(
                            elements=[
                                Element(image_url=BRICK_DEFAULT_IMAGE,
                                        title='์—ด์ฐจ์กฐํšŒ ์„œ๋น„์Šค',
                                        subtitle='๊ตญํ† ๊ตํ†ต๋ถ€์—์„œ ์ œ๊ณตํ•˜๋Š” "์—ด์ฐจ์กฐํšŒ ์„œ๋น„์Šค"์—์š”. ์ฝ”๋ ˆ์ผ/SRT ๋ชจ๋‘ ์กฐํšŒ ๊ฐ€๋Šฅํ•ด์š”.')
                            ]
                        )
                    )
                ),
                Message(
                    attachment=TemplateAttachment(
                        payload=GenericTemplate(
                            elements=[
                                Element(
                                    image_url='https://www.chatbrick.io/api/static/brick/img_brick_01_002.png',
                                    title='์—ด์ฐจ์กฐํšŒ',
                                    subtitle='์ฝ”๋ ˆ์ผ/SRT ๋ชจ๋‘ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์–ด์š”',
                                    buttons=[
                                        PostBackButton(
                                            title='์กฐํšŒํ•˜๊ธฐ',
                                            payload='brick|train|show_data'
                                        )
                                    ]
                                )
                            ]
                        )
                    )
                )
            ]
            await self.fb.send_messages(send_message)
        elif command == 'show_data':
            await self.brick_db.save()
        elif command == 'final':
            input_data = await self.brick_db.get()
            departure_station = input_data['store'][0]['value'].strip()
            destination_station = input_data['store'][1]['value'].strip()
            departure_date = input_data['store'][2]['value']
            train_type = input_data['store'][3]['value']

            if STATION.get(departure_station) is None:
                send_message = [
                    Message(
                        text='์ถœ๋ฐœ์—ญ์ด ์กฐํšŒํ•  ์ˆ˜ ์—†๋Š” ์—ญ์ž…๋‹ˆ๋‹ค.',
                        quick_replies=QuickReply(
                            quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค์‹œ ๊ฒ€์ƒ‰ํ•˜๊ธฐ',
                                    payload='brick|train|show_data'
                                )
                            ]
                        )
                    )
                ]
            elif STATION.get(destination_station) is None:
                send_message = [
                    Message(
                        text='๋„์ฐฉ์—ญ์ด ์กฐํšŒํ•  ์ˆ˜ ์—†๋Š” ์—ญ์ž…๋‹ˆ๋‹ค.',
                        quick_replies=QuickReply(
                            quick_reply_items=[
                                QuickReplyTextItem(
                                    title='๋‹ค์‹œ ๊ฒ€์ƒ‰ํ•˜๊ธฐ',
                                    payload='brick|train|show_data'
                                )
                            ]
                        )
                    )
                ]
            else:
                res = requests.get(
                    url='http://openapi.tago.go.kr/openapi/service/TrainInfoService/getStrtpntAlocFndTrainInfo?serviceKey=%s&numOfRows=500&pageSize=500&pageNo=1&startPage=1&depPlaceId=%s&arrPlaceId=%s&depPlandTime=%s&trainGradeCode=%s' % (
                        input_data['data']['api_key'], STATION[departure_station], STATION[destination_station],
                        departure_date, train_type))

                items = get_items_from_xml(res)

                if type(items) is dict:
                    if items.get('code', '00') == '99' or items.get('code', '00') == '30':
                        send_message = [
                            Message(
                                text='chatbrick ํ™ˆํŽ˜์ด์ง€์— ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์€ API key๋ฅผ ์ž…๋ ฅํ–ˆ์–ด์š”. ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.',
                            )
                        ]
                    else:
                        send_message = [
                            Message(
                                text=UNKNOWN_ERROR_MSG
                            )
                        ]
                else:
                    if len(items) == 0:
                        send_message = [
                            Message(
                                text='์กฐํšŒ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.',
                                quick_replies=QuickReply(
                                    quick_reply_items=[
                                        QuickReplyTextItem(
                                            title='๋‹ค์‹œ ๊ฒ€์ƒ‰ํ•˜๊ธฐ',
                                            payload='brick|train|show_data'
                                        )
                                    ]
                                )
                            )
                        ]
                    else:
                        result_message = '{depplacename} -> {arrplacename}\n\n'.format(**items[0])
                        for item in items:
                            departure_train_datetime = dateutil.parser.parse(item['depplandtime'])
                            arrive_train_datetime = dateutil.parser.parse(item['arrplandtime'])
                            gap = Train.days_hours_minutes(arrive_train_datetime - departure_train_datetime)

                            item['fromtodatetime'] = '%02d:%02d -> %02d:%02d' % (
                                departure_train_datetime.hour, departure_train_datetime.minute, arrive_train_datetime.hour,
                                arrive_train_datetime.minute)
                            item['time_delta'] = '%02d:%02d' % (gap[0], gap[1])
                            item['adultcharge_formmated'] = format(int(item['adultcharge']), ',')
                            result_message += '{traingradename} {fromtodatetime}    {time_delta}    {adultcharge_formmated}\n'.format(
                                **item)

                        send_message = [
                            Message(
                                text=result_message,
                                quick_replies=QuickReply(
                                    quick_reply_items=[
                                        QuickReplyTextItem(
                                            title='๋‹ค์‹œ ๊ฒ€์ƒ‰ํ•˜๊ธฐ',
                                            payload='brick|train|get_started'
                                        )
                                    ]
                                )
                            )
                        ]

            await self.brick_db.delete()
            await self.fb.send_messages(send_message)
        return None
Beispiel #23
0
    async def facebook(self, command):
        if command == 'get_started':
            # send_message = [
            #     Message(
            #         attachment=ImageAttachment(
            #             url=BRICK_DEFAULT_IMAGE
            #         )
            #     ),
            #     Message(
            #         text='๋ธ”๋ฃจํ•ต์—์„œ ์ œ๊ณตํ•˜๋Š” "๋ฉ”์ผ๋ณด๋‚ด๊ธฐ ์„œ๋น„์Šค"์˜ˆ์š”.'
            #     ),
            #     Message(
            #         attachment=TemplateAttachment(
            #             payload=GenericTemplate(
            #                 elements=[
            #                     Element(title='๋ฉ”์ผ์ „์†ก',
            #                             subtitle='์ฑ—๋ด‡์—์„œ ๋ฉ”์ผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์–ด์š”',
            #                             image_url=BRICK_GENERIC_TEMPLATE_IMAGE,
            #                             buttons=[
            #                                 PostBackButton(
            #                                     title='๋ฉ”์ผ๋ณด๋‚ด๊ธฐ',
            #                                     payload='brick|mailer|show_data'
            #                                 )
            #                             ])
            #                 ]
            #             )
            #         )
            #     )
            # ]
            send_message = [
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(image_url=BRICK_DEFAULT_IMAGE,
                                title='๋ฉ”์ผ๋ณด๋‚ด๊ธฐ ์„œ๋น„์Šค',
                                subtitle='๋ธ”๋ฃจํ•ต์—์„œ ์ œ๊ณตํ•˜๋Š” "๋ฉ”์ผ๋ณด๋‚ด๊ธฐ ์„œ๋น„์Šค"์˜ˆ์š”.')
                    ]))),
                Message(attachment=TemplateAttachment(payload=GenericTemplate(
                    elements=[
                        Element(title='๋ฉ”์ผ์ „์†ก',
                                subtitle='์ฑ—๋ด‡์—์„œ ๋ฉ”์ผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์–ด์š”',
                                image_url=BRICK_GENERIC_TEMPLATE_IMAGE,
                                buttons=[
                                    PostBackButton(
                                        title='๋ฉ”์ผ๋ณด๋‚ด๊ธฐ',
                                        payload='brick|mailer|show_data')
                                ])
                    ])))
            ]
            await self.fb.send_messages(send_message)
        elif command == 'show_data':
            await self.brick_db.save()
        elif command == 'cancel':
            await self.brick_db.delete()
            await self.fb.send_message(message=Message(
                text='๋ฉ”์ผ ๋ณด๋‚ด๊ธฐ๋ฅผ ์ทจ์†Œํ–ˆ์–ด์š”.',
                quick_replies=QuickReply(quick_reply_items=[
                    QuickReplyTextItem(title='์ƒˆ ๋ฉ”์ผ๋ณด๋‚ด๊ธฐ',
                                       payload='brick|mailer|show_data')
                ])))
        elif command == 'final':
            input_data = await self.brick_db.get()
            msg = MIMEText(input_data['store'][2]['value'])
            msg['Subject'] = '%s๋กœ๋ถ€ํ„ฐ ์ด๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.' % input_data['store'][0]['value']
            msg['To'] = input_data['store'][1]['value']
            result = '๋ฉ”์ผ ๋ณด๋‚ด๊ธฐ๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์–ด์š”.'
            if self.fb.log_id is None:
                self.fb.log_id = 'FBSendMessage|%d' % int(time.time() * 1000)
            try:
                self.smtp.ehlo()
                self.smtp.starttls()
                self.smtp.login(self.sender_email, self.sender_password)
                self.smtp.sendmail(self.sender_email,
                                   input_data['store'][1]['value'],
                                   msg.as_string())
            except:
                result = '๋ฉ”์ผ ์ „์†ก์„ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.\n์ž ์‹œ ํ›„ ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.'
            save_a_log_to_server({
                'log_id': self.fb.log_id,
                'user_id': self.fb.user_id,
                'os': '',
                'application': 'facebook',
                'api_code': 'mail',
                'api_provider_code': 'chatbrick',
                'origin': 'webhook_server',
                'end': int(time.time() * 1000),
                'remark': 'SMTP ํ†ต์‹ ์œผ๋กœ ์ด๋ฉ”์ผ ์ „์†กํ•จ'
            })

            await self.fb.send_message(message=Message(
                text=result,
                quick_replies=QuickReply(quick_reply_items=[
                    QuickReplyTextItem(title='์—ฐ์†ํ•˜์—ฌ ๋ฉ”์ผ๋ณด๋‚ด๊ธฐ',
                                       payload='brick|mailer|show_data')
                ])))

            await self.brick_db.delete()
        return None