Skip to content

Instantly share code, notes, and snippets.

@MKtalk
MKtalk / google_form.py
Created August 17, 2018 08:00
구글 설문지 정보 가져오기
# -*- coding: utf-8 -*-
import json
import re
import requests
base_url = 'https://docs.google.com/forms/d/1Zf-XM4WWG_6xisG83W8SQY2MueXEZzStPl9xiNH25u4'
response = requests.get(base_url).text
# -*- coding: utf-8 -*-
import requests
from datetime import datetime
def coin_detail(coin):
base_url = 'https://api.bitfinex.com/v1/pubticker/'
url = '{}{}'.format(base_url, coin)
response = requests.get(url)
msg = message(response.json())
@MKtalk
MKtalk / downloader.py
Created April 16, 2020 08:59
file downloader
#-*- coding:utf-8 -*-
import urllib.request
import uuid
from concurrent.futures import ThreadPoolExecutor
from multiprocessing import Pool
def get_image(url):
filename = str(uuid.uuid4())
out = f'./download/{filename}.jpg'
@MKtalk
MKtalk / bot.py
Created November 9, 2018 02:26
new bot.py
from bothub_client.bot import BaseBot
from bothub_client.decorators import channel
class Bot(BaseBot):
@channel()
def default_handler(self, event, context):
self.send_message('Echo: {}'.format(event['content']))
@MKtalk
MKtalk / bot.py
Last active September 7, 2018 07:15
간단한 설문 조사 챗봇을 위한 코드 구현
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function, unicode_literals)
from bothub_client.bot import BaseBot
from bothub_client.messages import Message
from bothub_client.decorators import command, intent
class Bot(BaseBot):
@MKtalk
MKtalk / bot.py
Created August 17, 2018 07:42
간단한 설문 조사 챗봇과 구글 설문지 연동
def set_pools(self, event, context, **kwargs):
q1 = kwargs.get('question1') # slots id 와 대응
q2 = kwargs.get('question2')
form_url = 'https://docs.google.com/forms/d/e/1FAIpQLScsCKP5Arszf84igEzoL5Yrbr5qcZIND9a4NeJyNw_onUUavw/formResponse'
params = '?entry.1894278833={}&entry.281957015={}'.format(q1, q2)
url = form_url + params
requests.post(url)
msg = '설문이 등록 되었습니다.'.format(q1, q2)
self.send_message(msg)
@MKtalk
MKtalk / bothub.yml
Created August 16, 2018 05:12
간단한 설문 챗봇을 위한 YML 구성
programming-language: python3
intents:
pools:
slots:
- id: question1
question: 오늘 점심은 어떤걸 드셨나요?
options:
- '자장면'
- '돈가스'
- '냉면'
@MKtalk
MKtalk / html-style.py
Last active January 29, 2018 07:31
bothub-sdk 0.1.27 html style
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function, unicode_literals)
from bothub_client.bot import BaseBot
from bothub_client.messages import HTML
from bothub_client.messages import Markdown
from bothub_client.messages import Message
@MKtalk
MKtalk / markdown.py
Last active January 29, 2018 07:31
bothub-sdk 0.1.27 - Markdown 적용
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function, unicode_literals)
from bothub_client.bot import BaseBot
from bothub_client.messages import Markdown
from bothub_client.messages import Message
class Bot(BaseBot):
@MKtalk
MKtalk / new-style.py
Last active January 27, 2018 07:17
BotHub.Studio new style
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function, unicode_literals)
from bothub_client.bot import BaseBot
from bothub_client.decorators import channel, command
@channel()
def default_handler(self, event, context):
self.send_message('default message')