Slide 1

Slide 1 text

ཧ૝ͷࣗ෼Λ๨Εͳ͍ͨΊʹ
 Slack and LINE bot Λ࡞ͬͨ࿩ @YASU11552288

Slide 2

Slide 2 text

ΤϯδχΞ=੒௕ͷ৬ۀ

Slide 3

Slide 3 text

ʮΤϯδχΞʯͱͯ͠੒௕͢Δ
 ͨΊʹ΍Βͳ͖Ό͍͚ͳ͍͜ͱ 
 ʢݸਓͷݟղʣ - ࠷৽৘ใͷΩϟονΞοϓ - ษڧձ΁ͷࢀՃ - Ξ΢τϓοτʢLT, ϒϩά etcʣ - ίʔυΛॻ͘

Slide 4

Slide 4 text

ΤϯδχΞͱͯ͠੒௕΋͍ͨ͠ ΤϯδχΞҎ֎ͷ໘Ͱ΍Γ͍ͨ͜ͱ΋͋Δ ʢීஈͷۀ຿΋΋ͪΖΜ͋Δʣ

Slide 5

Slide 5 text

ཧ૝ ଉൈ͖ VS VS ࢓ࣄ Lv 99 Lv 99 Lv 10

Slide 6

Slide 6 text

໨ͷલͷ࢓ࣄͰ๩ࡴ… ଵଦͷ༠࿭ʹෛ͚ͯ͠·͏… Ͳ͏͢Δ͔

Slide 7

Slide 7 text

ཧ૝Λҙࣝ͢Δ࣌ؒΛ૿΍͢ - ࢓ࣄ͸1೔8࣌ؒඞͣҙࣝ͢Δ - ଵଦ͸ৗʹແҙࣝʹߦ͏ - ཧ૝͚͕ͩෆఆظͰνΣοΫϙΠϯτ͕ͳ͍

Slide 8

Slide 8 text

ʮΤϯδχΞʯͱͯ͠੒௕͢Δ
 ͨΊʹ΍Βͳ͖Ό͍͚ͳ͍͜ͱ 
 ʢݸਓͷݟղʣ - ࠷৽৘ใͷΩϟονΞοϓ - ษڧձ΁ͷࢀՃ - Ξ΢τϓοτʢLT, ϒϩά etcʣ - ίʔυΛॻ͘

Slide 9

Slide 9 text

1೔ͷऴΘΓʹίʔυΛॻ͍͔ͨ ࣗ෼ʹ໰͏࢓૊ΈΛ࡞Ζ͏ʂʂ

Slide 10

Slide 10 text

ཁ݅ఆٛ - ίʔυΛॻ͍ͯΔ͔Λ൑அ - ࢦఆ࣌ࠁʹνΣοΫ - ॻ͍͍ͯΔ৔߹͸๙ΊΔ ɹʮຖ೔1commit…ͦͷੵΈॏͶ͕େࣄʂ͓ർΕ༷ࣗ෼ʂʯ - ॻ͍͍ͯͳ͍৔߹͸࠵ଅ ɹʮͳͥcommit͠ͳ͍͍͍͍͍ʂࠓ͙͢͠Ζ͓͓͓͓͓ʂʂ

Slide 11

Slide 11 text

ୈ1ষ shell
 GitHub × Slack API ×EC2 - GitHubͰͦͷ೔event͕ൃੜͯ͠Δ͔֬ೝ - ௨஌ର৅͸Slackʹ - ࣮ߦ؀ڥ͸EC2ͷt2.microͰ

Slide 12

Slide 12 text

Github API ͔ΒeventsΛऔಘ LATEST_COMMIT_DATE=`curl -u :${ACCESS_TOKEN} https:// api.github.com/users/anntoque/events | jq '.[0] | select(. ["type"]=="PushEvent")' | jq '.["created_at"]' | cut -c 2-11`

Slide 13

Slide 13 text

Slack ʹ௨஌͢Δʹ͸Incoming Webhook͕ศར 4FDSFU

Slide 14

Slide 14 text

Incoming WebhookͰ
 Slack ΁ϝοηʔδΛૹ৴ curl -X POST --data-urlencode "payload={\"channel\": \"#test- webhook\", \"username\":\"webhookbot\",\"text\": \"$ {COMMITED_MESSAGE}\", \"icon_emoji\": \":man-lifting-weights:\"}" ${WEBHOOK_URL} ※ COMMITED_MESSAGE = ૹ৴͢Δϝοηʔδͷ಺༰

Slide 15

Slide 15 text

͜Μͳײ͡Ͱ௨஌͕དྷΔ

Slide 16

Slide 16 text

ൃੜͨ͠՝୊ - SlackΛ։͔ͳ͍ͷͰ௨஌ʹؾ͔ͮͳ͍ - EC2ͷ੥ٻ͕݄1000ԁ͘Β͍ - ։ൃ؀ڥͷmacͱec2ͷcentosͷshell ͷҧ͍ʹΑΓඍົʹdateͷڍಈ͕ҧ͏ ※1 ˞.BDͰEBUFίϚϯυ͕ҧ͏݅ʹ͍ͭͯcגࣜձࣾཾ໺৘ใγεςϜ IUUQTUBUTVOPTZTUFNDPKQ NBD&"EBUF&#&&&#&&$&&&### &"#&"&&"

Slide 17

Slide 17 text

ୈ2ষ python(Flask)
 GitHub × LINE Message API ×Heroku - ௨஌ΛSlack͔Βੜ׆ʹ਎ۙͳLINEʹ - AWS͔ΒແྉͷHerokuʹҠߦ
 (lamdaͱ͔ECRͷଘࡏΛ஌͍ͬͯͨΒͦͬͪ΋͔͋ͬͨ΋) - shell͔Βςετ΋ॻ͖΍͍͢pythonʹҠߦ

Slide 18

Slide 18 text

Github API ͔ΒeventsΛऔಘ ʢpythonʣ headers = {'Authorization': 'token ' + github_token} def get_github_events(): response = requests.get( 'https://api.github.com/users/anntoque/events', headers=headers) return response.json()

Slide 19

Slide 19 text

LINE DevelopersͰMessaging APIΛ࢖༻͢ΔΞϓϦΛొ࿥

Slide 20

Slide 20 text

ϙνϙν͢ΔͱΞΫηετʔ ΫϯͳͲ͕खʹೖΔ 4FDSFU

Slide 21

Slide 21 text

LINE Message APIͰ
 ϝοηʔδΛૹ৴ʢFlaskʣ @handler.add(MessageEvent, message=TextMessage) def handle_message(event): events = get_github_events() last_commit_date = get_last_commit(events) message_text = fix_message(last_commit_date) line_bot_api.reply_message( event.reply_token, TextSendMessage(text=message_text))

Slide 22

Slide 22 text

Herokuʹ͸؀ڥม਺ͷηοτ 4FDSFU

Slide 23

Slide 23 text

GitHubϦϙδτϦͱͷ
 ࿈ܞΛઃఆ

Slide 24

Slide 24 text

ఆظ࣮ߦͷͨΊͷHeroku SchedulerΛ௥Ճ

Slide 25

Slide 25 text

ൃੜͨ͠՝୊ᶃ - ࣗ෼ͰϝοηʔδΛඈ͹͞ͳ ͍ͱ൓Ԡ͠ͳ͍ػೳΛ࡞ͬͯͨ

Slide 26

Slide 26 text

LINE Message APIͰϝοηʔδΛૹ৴ʢվʣ - APIͰ͋Δඞཁͳ͍ͷͰFlaskഉআ - reply_messageͰ͸push_messageΛ࢖༻ def main(): events = get_github_events() last_commit_date = get_last_commit(events) message_text = fix_message(last_commit_date) line_bot_api.push_message( LINE_USER_ID, TextSendMessage(text=message_text))

Slide 27

Slide 27 text

ൃੜͨ͠՝୊ᶄ - ࣮ߦΛ1೔1ճʹઃఆͨ͠ͷʹ 1೔10ճ͘Β͍௨஌͕དྷΔڪා

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Herokuʹ͸Procfileͱݺ͹ΕΔαʔόىಈ࣌ʹ࣮ߦ͢ΔίϚ ϯυΛఆٛ͢ΔϑΝΠϧ͕͋Δ Procfile+Heroku SchedulerͰ࣮ߦ͕ॏෳ͍ͯͨ͠ ͱΓ͋͑ͣProcfileΛద౰ͳ࣮ߦʹมߋ # มߋલ web: python commit-gypsum.py # มߋޙ web: python --version

Slide 30

Slide 30 text

Α͏΍͘׬੒

Slide 31

Slide 31 text

݁Ռຖ೔ίʔυΛॻ͍ͨͷ͔…

Slide 32

Slide 32 text

TMBDL ਖ਼݄ -*/& ˞࣌఺

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

TMBDL ਖ਼݄ -*/& ˞࣌఺ Ͳ͏͍͏͜ͱ͔ QZUIPO
 Ҡߦظؒ ผͷίʔυ ˞ࣗવݴޠॲཧຊϊοΫ ͳΜ͔
 ΍ΔؾͰ ͳ͔ͬͨ

Slide 35

Slide 35 text

ͭ·ΓɺΞϓϦέʔγϣϯ͕ ׬੒ͨ͠ͷ͕ࠓिͰ ·ͩӡ༻ͯ͠਺೔Ͱ͢ʂ

Slide 36

Slide 36 text

·ͱΊ ࠓޙͷల๬ - όον࣮ߦ೔࣌΍commit৘ใͳͲ৘ใΛ΋͏গ͠଍͍ͨ͠ - commit͍ͯ͠ͳ͍৔߹͸issueͷϦετΛૹ৴͢ΔͳͲ͍ͨ͠ - ςετॻ͘ ײ૝ - ຖ೔commit͢ΔͨΊͷΞϓϦΛ࡞ΔͨΊʹຖ೔ commitͯͨ͠www - bot͸؆୯ͳίʔυͰ૊ΊΔ͠ɺϥΠϑϋοΫ͠΍͍͢
 - ॳΊͯࣗ෼ͷͨΊͷΞϓϦέʔγϣϯΛ࡞͚ͬͨͲϞνϕʔγϣϯ͕ҧͬͨ - ࠷ޙʹࣗռ΋ࠐΊͯҎԼͷݴ༿Λ…

Slide 37

Slide 37 text

– Leonardo da Vinci “Iron rusts from disuse; water loses its purity from stagnation ... even so in inaction sap the vigor of the mind.” “మ΋࢖Θͳ͍ͱḊͼΔɻਫ΋ྲྀΕͳ͚Ε͹ཎΉɻ ଵଦ΋·ͨɺ৺ͷ׆ྗΛୣͬͯ͠·͏ɻ” -FPOBSEPEB7JODJ*SPOSVTUTGSPNEJTVTFXBUFSMPTFTJUT IUUQTXXXCSBJOZRVPUFDPNRVPUFTMFPOBSEP@EB@WJODJ@

Slide 38

Slide 38 text

ࢀߟࢿྉ // anntoque/commit-gypsum https://github.com/anntoque/commit-gypsum // LineBot(MessageApi)Λࢼͯ͠ΈΔ-heroku൛ - Qiita https://qiita.com/skycat_me/items/9f27cbd9354515df744a // line-bot-sdk-pythonΛ࢖ͬͯΈͨ - ࡶ৯೔ࢽ https://keinumata.hatenablog.com/entry/ 2018/05/08/122348