Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CrystalでTwitter botを作ってみた / Create a Twitter b...
Search
Mihyaeru
July 31, 2015
Programming
0
1.3k
CrystalでTwitter botを作ってみた / Create a Twitter bot in Crystal
東京 Crystal 勉強会 #1 in 五反田
Mihyaeru
July 31, 2015
Tweet
Share
More Decks by Mihyaeru
See All by Mihyaeru
会計 freee バックエンドの今後 / freee backend api
mihyaeru21
8
26k
Railsで実装されている機能のマイクロサービスへの切り離し / split to microservices from rails
mihyaeru21
1
840
WebエンジニアのためのMySQLデータ構造基礎(再) / mysql data structure for web developer 2
mihyaeru21
0
310
WebエンジニアのためのMySQLデータ構造基礎 / mysql data structure for web developer
mihyaeru21
1
700
WebエンジニアのためのMySQL入門 / learning mysql for web developer
mihyaeru21
7
2.7k
入門ReactiveX / about ReactiveX
mihyaeru21
3
480
RxSwiftと愉快な仲間たち / RxSwift with Units
mihyaeru21
4
2.8k
RxSwiftでTwitterの ライブラリを作ってる話 / RxTwift
mihyaeru21
4
760
Gotanda.pm #1
mihyaeru21
1
180
Other Decks in Programming
See All in Programming
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6.1k
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
380
Implementation Patterns
denyspoltorak
0
290
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.6k
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
290
CSC307 Lecture 03
javiergs
PRO
1
490
CSC307 Lecture 09
javiergs
PRO
1
840
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
980
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.4k
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
100
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
120
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
0
2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.6k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
120
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
120
Designing Experiences People Love
moore
144
24k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
180
Game over? The fight for quality and originality in the time of robots
wayneb77
1
120
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
180
AI: The stuff that nobody shows you
jnunemaker
PRO
2
260
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
·ͱΊ • ඪ४ϥΠϒϥϦ͕ॆ࣮Ͱऔ͖͍ͬ͢ • ϥΠτͳॻ͖৺͕ྑ͍ײ͡ • ιʔεՇ