Your SlideShare is downloading. ×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Building Social IDC Bots with Node.js and MongoDB

2,100
views

Published on

Improve your team's productivity and encourage participation with social IRC bots! Find out how to create scoreboards, encourage positive communication by awarding points, and bring your bot to life …

Improve your team's productivity and encourage participation with social IRC bots! Find out how to create scoreboards, encourage positive communication by awarding points, and bring your bot to life using OpenShift, Red Hat's free auto-scaling Platform as a Service. We'll power our bot using an OpenShift "gear", then add a MongoDB for memory, and teach it to speak using a javascript-based IRC library for node.js.


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,100
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 3/11/13 reveal.js - The HTML Presentation Framework SOCIAL IRC BOTS IN THE CLOUD with node.js and MongoDB http://bit.ly/11Qft8jryanjarvinen.com/presentations/irc/#/ 1/72
  • 2. 3/11/13 reveal.js - The HTML Presentation Framework presented by ryan jarvinen / @ryanjryanjarvinen.com/presentations/irc/#/ 2/72
  • 3. 3/11/13 reveal.js - The HTML Presentation Framework Open Platform Evangelist at Red Hat ryanj@redhat.comryanjarvinen.com/presentations/irc/#/ 3/72
  • 4. 3/11/13 reveal.js - The HTML Presentation Framework AGENDA Learn some IRC basics Create a bot and teach it to speak Learn some MongoDB basics Build a social leaderboard Go live with a Mongo-powered IRC bot in ~30 minsryanjarvinen.com/presentations/irc/#/ 4/72
  • 5. 3/11/13 reveal.js - The HTML Presentation Framework CODE DU JOUR https://github.com/openshift-quickstart/irc- leaderboard-quickstartryanjarvinen.com/presentations/irc/#/ 5/72
  • 6. 3/11/13 reveal.js - The HTML Presentation Framework IRC is just multiplayer notepadryanjarvinen.com/presentations/irc/#/ 6/72
  • 7. 3/11/13 reveal.js - The HTML Presentation Framework “Hello, nice to troll you!”ryanjarvinen.com/presentations/irc/#/ 7/72
  • 8. 3/11/13 reveal.js - The HTML Presentation Framework IRC is just multiplayer notepad a drama club for nerdsryanjarvinen.com/presentations/irc/#/ 8/72
  • 9. 3/11/13 reveal.js - The HTML Presentation Framework ACTING / EMOTING “ An emote is an entry into a text-based chat client that indicates an action taking place. Unlike emoticons, they are not text art, and instead describe the action using words.” http://en.wikipedia.org/wiki/Emoteryanjarvinen.com/presentations/irc/#/ 9/72
  • 10. 3/11/13 reveal.js - The HTML Presentation Framework REAL DRAMA The Hamnet Players http://www.hambule.co.uk/hamnet/ The Plaintext Players http://yin.arts.uci.edu/~players/ryanjarvinen.com/presentations/irc/#/ 10/72
  • 11. 3/11/13 reveal.js - The HTML Presentation Framework THE CYPOSIUM? http://www.cyposium.net/ryanjarvinen.com/presentations/irc/#/ 11/72
  • 12. 3/11/13 reveal.js - The HTML Presentation Framework MAKING A BIG ENTRANCE To perform an action, type /me followed by a description of an action: /erlsee a ICoe-cos m ol ys t R vratrryanjarvinen.com/presentations/irc/#/ 12/72
  • 13. 3/11/13 reveal.js - The HTML Presentation Framework IRC BOTSryanjarvinen.com/presentations/irc/#/ 13/72
  • 14. 3/11/13 reveal.js - The HTML Presentation Framework IRC BOTS ARE talking applications scripted actors who appear to be another user in the room generally benevolent (they fight for the users)ryanjarvinen.com/presentations/irc/#/ 14/72
  • 15. 3/11/13 reveal.js - The HTML Presentation Framework IRC BOT ABILITIES most bots know a few simple jokes many know how to assist with bug reports they may offer links to relevant information or even fight against spamryanjarvinen.com/presentations/irc/#/ 15/72
  • 16. 3/11/13 reveal.js - The HTML Presentation Framework IRC IS just multiplayer notepad drama club for nerds✓ an open protocol for realtime mutiuser communication via text ( rfc1459 )✓ found at the heart of every high-tech company that Ive worked for✓ a serious contender for "most valuable communication tool" in many organizations✓ realtime communication✓ryanjarvinen.com/presentations/irc/#/ 16/72
  • 17. 3/11/13 reveal.js - The HTML Presentation Framework IRC IS OPENryanjarvinen.com/presentations/irc/#/ 17/72
  • 18. 3/11/13 reveal.js - The HTML Presentation Framework OPEN CLIENTS XCHAT, COLLOQUYryanjarvinen.com/presentations/irc/#/ 18/72
  • 19. 3/11/13 reveal.js - The HTML Presentation Framework WEB CLIENTS Give it a try: http://webchat.freenode.net/ryanjarvinen.com/presentations/irc/#/ 19/72
  • 20. 3/11/13 reveal.js - The HTML Presentation Framework OPEN SERVERS /on#pnhf ji oesit FREENODE OpenShift on freenode IRCryanjarvinen.com/presentations/irc/#/ 20/72
  • 21. 3/11/13 reveal.js - The HTML Presentation Framework HOSTING OPTIONS DIY / ON PREMISE PUBLIC IRC (FREENODE) CLOUD SERVERSryanjarvinen.com/presentations/irc/#/ 21/72
  • 22. 3/11/13 reveal.js - The HTML Presentation Framework IRC is built on an open standard, allowing you to host it as a service (on your own hardware), or from within a private network (for added security). OpenShift was designed with many of the same characteristics in mind, minus the drama.ryanjarvinen.com/presentations/irc/#/ 22/72
  • 23. 3/11/13 reveal.js - The HTML Presentation Framework OPENSHIFT IS OPENryanjarvinen.com/presentations/irc/#/ 23/72
  • 24. 3/11/13 reveal.js - The HTML Presentation Framework OPEN CLIENT INTERFACE https://github.com/openshift/rhcryanjarvinen.com/presentations/irc/#/ 24/72
  • 25. 3/11/13 reveal.js - The HTML Presentation Framework OPEN CARTRIDGE FORMATryanjarvinen.com/presentations/irc/#/ 25/72
  • 26. 3/11/13 reveal.js - The HTML Presentation Frameworkryanjarvinen.com/presentations/irc/#/ 26/72
  • 27. 3/11/13 reveal.js - The HTML Presentation Framework PAAS SOURCE OPENSHIFT ORIGINryanjarvinen.com/presentations/irc/#/ 27/72
  • 28. 3/11/13 reveal.js - The HTML Presentation Frameworkryanjarvinen.com/presentations/irc/#/ 28/72
  • 29. 3/11/13 reveal.js - The HTML Presentation Framework OPENSHIFT HOSTING DIY / ORIGIN ONLINE ENTERPRISEryanjarvinen.com/presentations/irc/#/ 29/72
  • 30. 3/11/13 reveal.js - The HTML Presentation Framework DEVELOPER PREVIEW Sign up for an OpenShift Online account: http://openshift.redhat.com/ Free-as-in-beer (no cost) Free-as-in-freedom (open source) 512 MB RAM / 1 GB storage per gear (3 free) Need more resources? (just ask!) REALLY a Developer Preview (GA this summer)ryanjarvinen.com/presentations/irc/#/ 30/72
  • 31. 3/11/13 reveal.js - The HTML Presentation Framework THE CLOUD LANDSCAPEryanjarvinen.com/presentations/irc/#/ 31/72
  • 32. 3/11/13 reveal.js - The HTML Presentation Framework OPENSHIFT IS...ryanjarvinen.com/presentations/irc/#/ 32/72
  • 33. 3/11/13 reveal.js - The HTML Presentation Frameworkryanjarvinen.com/presentations/irc/#/ 33/72
  • 34. 3/11/13 reveal.js - The HTML Presentation Framework THE BIG PICTUREryanjarvinen.com/presentations/irc/#/ 34/72
  • 35. 3/11/13 reveal.js - The HTML Presentation Frameworkryanjarvinen.com/presentations/irc/#/ 35/72
  • 36. 3/11/13 reveal.js - The HTML Presentation Framework OPENSTACK IS OPEN and FOCUSED ON IAASryanjarvinen.com/presentations/irc/#/ 36/72
  • 37. 3/11/13 reveal.js - The HTML Presentation Framework BUZZ WORDS PUBLIC CLOUD + PRIVATE CLOUD = HYBRID CLOUDryanjarvinen.com/presentations/irc/#/ 37/72
  • 38. 3/11/13 reveal.js - The HTML Presentation Framework GETTING STARTED WITH OPENSHIFT PRE-REQUISITES: ruby, rubygems gitryanjarvinen.com/presentations/irc/#/ 38/72
  • 39. 3/11/13 reveal.js - The HTML Presentation Framework INSTALLING THE RHC CLIENT TOOL sd gmisalrc uo e ntl h and install node.jsryanjarvinen.com/presentations/irc/#/ 39/72
  • 40. 3/11/13 reveal.js - The HTML Presentation Framework HELP WITH CLIENT TOOLS RHC client tool installation https://openshift.redhat.com/community/get-started#cli Openshift Getting Started guide https://openshift.redhat.com/community/developers/get- startedryanjarvinen.com/presentations/irc/#/ 40/72
  • 41. 3/11/13 reveal.js - The HTML Presentation Framework CONFIGURING YOUR DEV ENVIRONMENT rcstp h eu Will automatically: set your openshift email address verify your ssh key configuration configure your application namespaceryanjarvinen.com/presentations/irc/#/ 41/72
  • 42. 3/11/13 reveal.js - The HTML Presentation Framework GEARING UP A NEW APP ON OPENSHIFT rcapcet APNM APCRRDE h p rae P_AE P_ATIG or rcapcet ico ndj-. h p rae rbt oes06ryanjarvinen.com/presentations/irc/#/ 42/72
  • 43. 3/11/13 reveal.js - The HTML Presentation Framework ApiainOtos plcto pin ---------- --------- Nmsae raj aepc: yn Crrde:ndj-. atigs oes06 Ga Sz: dfut er ie eal Saig cln: no Cetn apiainrbt ..dn raig plcto ico . oe Wiigfryu DSnm t b aalbe..dn atn o or N ae o e vial . oe DwlaigteapiainGtrpstr .. onodn h plcto i eoioy . Coigit rbt.. lnn no ico.ryanjarvinen.com/presentations/irc/#/ 43/72
  • 44. 3/11/13 reveal.js - The HTML Presentation Framework ico @ht:/rbtrajrcodcm (ud 2980b8468 rbt tp/ico-yn.hlu.o/ ui: 5134fd0e 90ae4030 821626a) -------------------------- ------------------------- Cetd rae: 1:3P 02 M Ga Sz:sal er ie ml GtUL i R: sh/2980b8468821626a@rbtrajrcodcm~ s:/5134fd0e90ae4030ico-yn.hlu.o// gtico.i/ i/rbtgt SH S: 2980b8468821626a@rbtrajrcod 5134fd0e90ae4030ico-yn.hlu .o cm ndj-. (oej 06 oes06 Nd.s .) ------------ ------------ RSL: EUT Apiainico wscetd plcto rbt a rae.ryanjarvinen.com/presentations/irc/#/ 44/72
  • 45. 3/11/13 reveal.js - The HTML Presentation Framework SUCCESS! You now have a basic node.js app up an running on OpenShift! Your gear is now configured with: its own git repo its own web server ssh access logging publicly accessible DNSryanjarvinen.com/presentations/irc/#/ 45/72
  • 46. 3/11/13 reveal.js - The HTML Presentation Framework BUILDING YOUR BOT c ico d rbtryanjarvinen.com/presentations/irc/#/ 46/72
  • 47. 3/11/13 reveal.js - The HTML Presentation Framework INSTALLING DEPENDENCIES Using Nodes npm package manager : nmisalic- p ntl r S Include the `-S` flag in order to save this dependency to your applications `package.json` file. http://npmjs.org/package/irc/ryanjarvinen.com/presentations/irc/#/ 47/72
  • 48. 3/11/13 reveal.js - The HTML Presentation Framework BOT BASICS Add the following to your server.js to load and configure the irc library: vric=rqier; a r eur(ic) vrbtnm =poesevOESITAPNM | rbt; a o_ae rcs.n.PNHF_P_AE | ico vrbt=nwicCin(ca.reoent,btnm,{ a o e r.lethtfend.e o_ae canl:[#ozo,bta, hnes bto #owr] pr:80, ot 01 dbg tu eu: re }; )ryanjarvinen.com/presentations/irc/#/ 48/72
  • 49. 3/11/13 reveal.js - The HTML Presentation Framework TEACHING YOUR BOT TO SPEAK Listen and respond to conversations as they happen: btaditnresg fnto(rm t,msae { o.dLsee(msae, ucinfo, o esg) i( msaeidxfnwaygo jks >- f esg.neO(Ko n od oe?) 1 | msaeidxfodjk >- | esg.neO(go oe) 1 ){ btsyt,nc kok; o.a(o Kok nc!) } }; )ryanjarvinen.com/presentations/irc/#/ 49/72
  • 50. 3/11/13 reveal.js - The HTML Presentation Framework Getting to the punchline: btaditnresg fnto(rm t,msae { o.dLsee(msae, ucinfo, o esg) i( msaeidxfh i tee >- f esg.neO(wo s hr?) 1 | msaeidxf"h tee" >- | esg.neO(wos hr?) 1 | msaeidxf"h tee" >- | esg.neO(Wos hr?) 1 | msaeidxf"h i tee" >- | esg.neO(Wo s hr?) 1 ) { btsyt,oi; o.a(o Drs) } }; ) btaditnresg fnto(rm t,msae { o.dLsee(msae, ucinfo, o esg) i( msaeidxfoi wo >- f esg.neO(Drs h?) 1 | msaeidxf"oi wo" >- | esg.neO(drs h?) 1 ) { btsyt,"oi lce,ta wyImkokn!) o.a(o Drs okd hts h ncig"; } }; )ryanjarvinen.com/presentations/irc/#/ 50/72
  • 51. 3/11/13 reveal.js - The HTML Presentation Framework COMMITTING YOUR CHANGES git add package.json server.js Commit your changes locally git commit -m adding irc npm dependency, initializing irc library, adding a few jokesryanjarvinen.com/presentations/irc/#/ 51/72
  • 52. 3/11/13 reveal.js - The HTML Presentation Framework DEPLOYMENT gtps i uh Done! Your bot should now be live on IRC.ryanjarvinen.com/presentations/irc/#/ 52/72
  • 53. 3/11/13 reveal.js - The HTML Presentation Framework INTERACTING WITH YOUR NEW BOT Login to IRC, and enter one of the channels that your bot has been configured to join: /on#ozo ji bto If you dont already have an IRC client, you can connect to freenode on the web: http://webchat.freenode.net/ryanjarvinen.com/presentations/irc/#/ 53/72
  • 54. 3/11/13 reveal.js - The HTML Presentation Framework Ask if anyone knows a good joke: [us] Ko aygo jks get nw n od oe? [rbt Kokkok ico] nc nc! [us] Woi tee get h s hr? [rbt Drs ico] oi [us] Drswo get oi h? [rbt Drslce,ta wyImkokn! ico] oi okd hts h ncig [us] mh. get e..ryanjarvinen.com/presentations/irc/#/ 54/72
  • 55. 3/11/13 reveal.js - The HTML Presentation Framework BOT DEBUGGING AND MAINTAINANCE If your bot decides to quit mid-conversation, it may be suffering from a bug. Checking its logs may reveal what set it off: rcti ico h al rbt Or, debug it while running locally: nmsat p trryanjarvinen.com/presentations/irc/#/ 55/72
  • 56. 3/11/13 reveal.js - The HTML Presentation Framework TEACHING YOUR BOT TO KEEP SCOREryanjarvinen.com/presentations/irc/#/ 56/72
  • 57. 3/11/13 reveal.js - The HTML Presentation Framework SETTING UP MONGODB ON OPENSHIFT rccrrdeadmnob22 h atig d ogd-.ryanjarvinen.com/presentations/irc/#/ 57/72
  • 58. 3/11/13 reveal.js - The HTML Presentation Framework Adn mnob22t apiainrbt ..Sces dig ogd-. o plcto ico . ucs mnob22(ogD NSLDtbs 22 ogd-. MnoB oQ aaae .) -------------------- -------------------- Cneto UL mnob/1761219207 oncin R: ogd:/2..0.2:71/ Dtbs Nm: ico aaae ae rbt Pswr: asod TxwiZG 5JCDYn Uenm: srae amn di RSL: EUT Addmnob22t apiainico de ogd-. o plcto rbtryanjarvinen.com/presentations/irc/#/ 58/72
  • 59. 3/11/13 reveal.js - The HTML Presentation Framework Adn mnob22t apiainrbt ..Sces dig ogd-. o plcto ico . ucs MnoB22dtbs add Pes mk nt o teeceetas ogD . aaae de. lae ae oe f hs rdnil : Ro Ue:amn ot sr di Ro Pswr:TxwiZG ot asod 5JCDYn Dtbs Nm:ico aaae ae rbt Cneto UL mnob/$PNHF_OGD_BHS:OESITM oncin R: ogd:/OESITMNOBD_OT$PNHF_O NOBD_OT GD_BPR/ Yucnmng yu nwMnoBb as ebdigrcmno11 o a aae or e ogD y lo medn okog-. Tercmnouenm adpswr wl b tesm a teMno h okog srae n asod il e h ae s h ogD Bceetasaoe rdnil bv.ryanjarvinen.com/presentations/irc/#/ 59/72
  • 60. 3/11/13 reveal.js - The HTML Presentation Framework ROCKMONGO ON OPENSHIFT rccrrdeadrcmno11 h atig d okog-. (optional)ryanjarvinen.com/presentations/irc/#/ 60/72
  • 61. 3/11/13 reveal.js - The HTML Presentation Framework ADDING A MONGOJS DEPENDENCY nmisal- mnos p ntl S ogjryanjarvinen.com/presentations/irc/#/ 61/72
  • 62. 3/11/13 reveal.js - The HTML Presentation Framework CONNECTING TO MONGODB vrmnos=rqieogj; a ogj eur(mnos) vrcneto_tig=btnm; a oncinsrn o_ae i(rcs.n.PNHF_OGD_BPSWR) fpoesevOESITMNOBD_ASOD{ cneto_tig=poesevOESITMNOBD_SRAE+ oncinsrn rcs.n.PNHF_OGD_BUENM ""+ : poesevOESITMNOBD_ASOD+""+ rcs.n.PNHF_OGD_BPSWR @ poesevOESITMNOBD_OT++ rcs.n.PNHF_OGD_BHS / poesevOESITAPNM; rcs.n.PNHF_P_AE } vrd =mnoscneto_tig [soeor) a b ogj(oncinsrn, crbad];ryanjarvinen.com/presentations/irc/#/ 62/72
  • 63. 3/11/13 reveal.js - The HTML Presentation Framework SETTING A SCORE btaditnresg fnto(rm t,msae { o.dLsee(msae, ucinfo, o esg) i( msaeidxf+)>- ) f esg.neO(+ 1 { vrsbet=msaesie0msaeidxf+); a ujc esg.lc(,esg.neO(+) d.crbadfn(qey {ae sbet}.ii(,fn bsoeor.id{ur: nm: ujc})lmt1 uc to(r,dc { iner o) i(tpo(o)=ojc& (o isaco Ary & f yefdc=bet & dc ntnef ra) & dc0 & dc0.ae{ o[] & o[]nm) / udt / pae d.crbadudt(nm:sbet,{ic{cr bsoeor.pae{ae ujc} $n:so e1} fnto(r){ :}, uciner btsyt,"cr:"+(1+dc0.cr ) o.a(o soe o[]soe ) ; }; ) }le es{ / isr / net d.crbadisr(nm:sbet soe 1,f bsoeor.net{ae ujc, cr: } uciner { nto(r) btsyt,"cr:1) o.a(o soe "; }; ) } }; ) } }; )ryanjarvinen.com/presentations/irc/#/ 63/72
  • 64. 3/11/13 reveal.js - The HTML Presentation Framework SHOWING THE SCOREBOARD btaditnresg fnto(rm t,msae { o.dLsee(msae, ucinfo, o esg) i( msaeidxfcrbad)>- ) f esg.neO(soeor 1 { d.crbadfn(.ot{cr:1)lmt1)frahf bsoeor.id)sr(soe-}.ii(0.oEc(u nto(r,dc{ ciner o) i (o & dcnm & dcsoe){ f dc & o.ae & o.cr btsyt,dcnm +" "+dcsoe; o.a(o o.ae : o.cr) } }; ) } }; )ryanjarvinen.com/presentations/irc/#/ 64/72
  • 65. 3/11/13 reveal.js - The HTML Presentation Framework UPDATING YOUR APP gtadpcaejo sre.s i d akg.sn evrj gtcmi - digasca soeor i omt m adn oil crbad gtps i uhryanjarvinen.com/presentations/irc/#/ 65/72
  • 66. 3/11/13 reveal.js - The HTML Presentation Framework SOCIAL REWARDSryanjarvinen.com/presentations/irc/#/ 66/72
  • 67. 3/11/13 reveal.js - The HTML Presentation Framework ALLOCATING POINTS tr+ em+ [ahe] Ayn dw frpza rpal noe on o iz? [oael]pza+ dntlo iz+ [rbt ico] soe 4 cr: 3 [ahe] Ltsodrto rpal e re w [enro Go ie,Rp!rpal+ load] od da ah ahe+ [rbt ico] soe 2 cr: 3ryanjarvinen.com/presentations/irc/#/ 67/72
  • 68. 3/11/13 reveal.js - The HTML Presentation Framework CHECKING THE SCOREBOARD ico soeor rbt crbad [rbt ico:7 ico] rbt [rbt raj 4 ico] yn: [rbt drs - ico] oi: 2ryanjarvinen.com/presentations/irc/#/ 68/72
  • 69. 3/11/13 reveal.js - The HTML Presentation Framework BOTS ON-DEMAND rcapcet ico ndj-. mnob22-fo-oehts/g h p rae rbt oes06 ogd-. -rmcd=tp:/ ihbcmoesitqiktr/r-edror-ucsatgt tu.o/pnhf-ucsaticlaebadqiktr.iryanjarvinen.com/presentations/irc/#/ 69/72
  • 70. 3/11/13 reveal.js - The HTML Presentation Framework You can find much more information about this npm IRC library here: https://github.com/martynsmith/node-ircryanjarvinen.com/presentations/irc/#/ 70/72
  • 71. 3/11/13 reveal.js - The HTML Presentation Framework Thanks for following along! --ryanjryanjarvinen.com/presentations/irc/#/ 71/72
  • 72. 3/11/13 reveal.js - The HTML Presentation Framework REFERENCES Building social IRC Bots with Node.js (Part 1) Leaderboards for IRC - Social Node.js Bots (Part 2) RHC command-line installer help Why contact Freenode on port 8001? IRC - Its how hackers talk. Luckily, I speak "leet" node-irc Run any version of Node.js on OpenShiftryanjarvinen.com/presentations/irc/#/ 72/72

×