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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
510
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
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
700
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
56
37k
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
5.9k
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
150
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
300
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
280
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
660
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
130
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
1.8k
AIエージェント時代のコードレビューを設計する
nogu66
6
2.6k
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
240
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
210
Featured
See All Featured
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
65k
The Limits of Empathy - UXLibs8
cassininazir
1
650
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
490
Discover your Explorer Soul
emna__ayadi
2
1.3k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
660
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
210
The Spectacular Lies of Maps
axbom
PRO
1
990
Ruling the World: When Life Gets Gamed
codingconduct
0
330
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
560
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
·ͱΊ • ඪ४ϥΠϒϥϦ͕ॆ࣮Ͱऔ͖͍ͬ͢ • ϥΠτͳॻ͖৺͕ྑ͍ײ͡ • ιʔεՇ