Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (28 sloc) 0.802 kb
# Description:
# Pokemon fun!
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# pokefact - get a random pokefact!
#
# Author:
# eliperkins
module.exports = (robot) ->
robot.respond /pokefact/i, (msg) ->
msg.http('https://api.twitter.com/1/statuses/user_timeline.json')
.query(screen_name: 'pokefacts', count: 100)
.get() (err, res, body) ->
tweets = JSON.parse(body)
msg.send tweets.length
if tweets? and tweets.length > 0
tweet = msg.random tweets
while(tweet.text.toLowerCase().indexOf('#pokefact') == -1)
tweet = msg.random tweets
msg.send "PokeFACT: " + tweet.text.replace(/\#pokefact/i, "");
else
msg.reply "Couldn't find a PokeFACT"
Jump to Line
Something went wrong with that request. Please try again.