Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CrystalでTwitter botを作ってみた / Create a Twitter b...
Search
Mihyaeru
July 31, 2015
Programming
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CrystalでTwitter botを作ってみた / Create a Twitter bot in Crystal
東京 Crystal 勉強会 #1 in 五反田
Mihyaeru
July 31, 2015
More Decks by Mihyaeru
See All by Mihyaeru
会計 freee バックエンドの今後 / freee backend api
mihyaeru21
8
27k
Railsで実装されている機能のマイクロサービスへの切り離し / split to microservices from rails
mihyaeru21
1
880
WebエンジニアのためのMySQLデータ構造基礎(再) / mysql data structure for web developer 2
mihyaeru21
0
330
WebエンジニアのためのMySQLデータ構造基礎 / mysql data structure for web developer
mihyaeru21
1
740
WebエンジニアのためのMySQL入門 / learning mysql for web developer
mihyaeru21
7
2.7k
入門ReactiveX / about ReactiveX
mihyaeru21
3
520
RxSwiftと愉快な仲間たち / RxSwift with Units
mihyaeru21
4
2.9k
RxSwiftでTwitterの ライブラリを作ってる話 / RxTwift
mihyaeru21
4
800
Gotanda.pm #1
mihyaeru21
1
200
Other Decks in Programming
See All in Programming
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
350
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
120
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
16k
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
160
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2k
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
740
Simple Storage Service(S3) is not simple
iwatsukayura
0
230
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
140
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.6k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
590
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
52k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
470
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Paper Plane
katiecoart
PRO
4
54k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
980
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
What's in a price? How to price your products and services
michaelherold
247
13k
Balancing Empowerment & Direction
lara
6
1.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
720
Transcript
CrystalͰTwitter botΛ࡞ͬͯΈͨ ౦ژ Crystal ษڧձ #1 in ޒా @mihyaeru21
© 2015 Mihyaeru ͓લͩΕΑ • ϛώϟΤϧ @mihyaeru21 • ࠷ۙSwiftͱPerlΛʑͰ •
ͨ·ʹPython • YAPCͰొஃ͢Δ͜ͱʹͳͬͯΨΫϒϧ 2
© 2015 Mihyaeru ࡞ͬͯΈͨܥLT • ܀΅ͬͱ https://twitter.com/crybot21 • https://github.com/mihyaeru21/crybot •
UserStreamʹܨ͍Ͱϝϯγϣϯͱಉ͡༰Λݴ ͍ฦ͚ͩ͢ • ϩʔΧϧͰಈ͔ͯ͠Δ͔Β͙͢ಈ͔ͳ͘ͳΔӡ໋ 3
© 2015 Mihyaeru ΊͬͪΌ͠ΐ΅͍σϞ 4
ݴ͍ฦ͚ͩ͢Ͱͨ͠
© 2015 Mihyaeru CrystalΛͬͯΈͨײ • ·ΔͰLLΛॻ͍͍ͯΔײ֮ • ๛ͳඪ४Ϟδϡʔϧ͕͋ͬͯศར • Streaming
APIॳΊ࣮͚ͯͨ͠ͲͳΜͱ͔ ͳͬͨ 6
© 2015 Mihyaeru CrystalΛͬͯΈͨײ • ϥΠτʹ͔͚Δ͚Ͳɺܕͷѻ͍ϥΠτͰ ͳ͔ͬͨ • ٽ͘ٽ͘Ϩϕϧͳͱ͜ΖΛॻ͍ͨ •
υΩϡϝϯτιʔείʔυ • RubyΛ͋·ΓΒͳ͔͔ͬͨΒײͨ͡͠͞ 7
© 2015 Mihyaeru ͬͨඪ४Ϟδϡʔϧ • cgi • env • http
• json • oauth • openssl • secure_random • socket • time 8
© 2015 Mihyaeru cgi • URLΤϯίʔυʹ༻ • cgiۭؒʹ͋ͬͨͷ͔ɻɻɻ • uriͱ͔httpͱ͔Λݟ͍ͯͨ
9
© 2015 Mihyaeru env • ڥมͷಡΈࠐΈ • access tokenͱ͔ͷಡΈࠐΈʹ༻ •
ී௨ʹHashͬΆ͑ͨ͘ 10
© 2015 Mihyaeru http (./client ./request) • ΧδϡΞϧʹ͑Δ • ௨৴ͷ్தͰίʔϧόοΫͱ͔ʹσʔλΛྲྀ
ͯ͘͠ΕΔ͕ͭ(ݟͨݶΓ)ແ͔ͬͨ • υΩϡϝϯτ͔ΒભҠ͢Διʔείʔυ͕Ϧ Ϧʔε൛ΑΓ৽ͯ͘͠ϋϚͬͨ 11
© 2015 Mihyaeru json • ͱΓ͋͑ͣ JSON.parse • σίʔυ݁Ռ͍͢͝ܕʹͳ͍ͬͯͯฦΓ ͷѻ͍͕ຯʹ͔ͬͨ͠
12
© 2015 Mihyaeru oauth • ௨৴·Ͱͬͯ͘ΕΔ͔ͱࢥ͚ͬͨͲҧͬͨ • ͬͨͷ OAuth::Signature •
໘ͳAuthϔομΛͺͬͱ࡞Ε͍͍ͯײ͡ • খճΓ͕ޮ͘ײ 13
© 2015 Mihyaeru openssl • OpenSSL::SSL::Socket • SSL༻ʹTCPSocketΛแΈࠐΜͰ͚͋͛ͨͩ 14
© 2015 Mihyaeru secure_random • nonceΛ࡞Δͷʹར༻ • SecureRandom.hex(32) ͰɺͱΓ͋͑ͣ32ܻ ͷ16ਐจࣈྻ͕ಘΒΕΔ
• nonceʹUUIDͷϋογϡΛ͓͏ͱࢥͬͯ ͚ͨͲUUIDϞδϡʔϧ͕ແ͔ͬͨ 15
© 2015 Mihyaeru socket • TCPSocket • ίωΫγϣϯΛுΓͬͺͳ͠ͰಡΈଓ͚Δ෦ Ͱ༻ •
ൺֱతϨϕϧͳ෦͚ͩͲ৮Γ͔ͬͨ͢ 16
© 2015 Mihyaeru time • Time.utc_now.to_i ͚͓͚֮ͩ͑ͯ ͻͱ·ͣੜ͖͍͚ͯͦ͏ • Time.now.to_i
ͬͯॻ͍ͯͯϋϚͬͨ 17
·ͱΊ • ඪ४ϥΠϒϥϦ͕ॆ࣮Ͱऔ͖͍ͬ͢ • ϥΠτͳॻ͖৺͕ྑ͍ײ͡ • ιʔεՇ