Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

init vindaloo

  • Loading branch information...
commit eeb4407e8937adba1baa0ae4a0f959afbbcdc4f0 1 parent 2cdc26e
@Vrtak-CZ authored
View
3  .gitignore
@@ -1 +1,2 @@
-undefined
+node_modules
+hubot
View
1  Procfile
@@ -1 +0,0 @@
-web: bin/hubot -a campfire -n Hubot
View
164 README.md
@@ -1,164 +0,0 @@
-# Hubot
-
-This is a version of GitHub's Campfire bot, hubot. He's pretty cool.
-
-This version is designed to be deployed on [Heroku][heroku].
-
-[heroku]: http://www.heroku.com
-
-## Playing with Hubot
-
-You'll need to install the necessary dependencies for hubot. All of
-those dependencies are provided by [npm][npmjs].
-
-[npmjs]: http://npmjs.org
-
-## HTTP Listener
-
-Hubot has a HTTP listener which listens on the port specified by the `PORT`
-environment variable.
-
-You can specify routes to listen on in your scripts by using the `router`
-property on `robot`.
-
-```coffeescript
-module.exports = (robot) ->
- robot.router.get "/hubot/version", (req, res) ->
- res.end robot.version
-```
-
-There are functions for GET, POST, PUT and DELETE, which all take a route and
-callback function that accepts a request and a response.
-
-### Redis
-
-If you are going to use the `redis-brain.coffee` script from `hubot-scripts`
-you will need to add the Redis to Go addon on Heroku which requires a verified
-account or you can create an account at [Redis to Go][redistogo] and manually
-set the `REDISTOGO_URL` variable.
-
- % heroku config:add REDISTOGO_URL="..."
-
-If you don't require any persistence feel free to remove the
-`redis-brain.coffee` from `hubot-scripts.json` and you don't need to worry
-about redis at all.
-
-[redistogo]: https://redistogo.com/
-
-### Testing Hubot Locally
-
-You can test your hubot by running the following.
-
- % bin/hubot
-
-You'll see some start up output about where your scripts come from and a
-prompt.
-
- [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell
- [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts
- [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts
- Hubot>
-
-Then you can interact with hubot by typing `hubot help`.
-
- Hubot> hubot help
-
- Hubot> animate me <query> - The same thing as `image me`, except adds a few
- convert me <expression> to <units> - Convert expression to given units.
- help - Displays all of the help commands that Hubot knows about.
- ...
-
-Take a look at the scripts in the `./scripts` folder for examples.
-Delete any scripts you think are silly. Add whatever functionality you
-want hubot to have.
-
-## Adapters
-
-Adapters are the interface to the service you want your hubot to run on. This
-can be something like Campfire or IRC. There are a number of third party
-adapters that the community have contributed. Check the
-[hubot wiki][hubot-wiki] for the available ones.
-
-If you would like to run a non-Campfire or shell adapter you will need to add
-the adapter package as a dependency to the `package.json` file in the
-`dependencies` section.
-
-Once you've added the dependency and run `npm install` to install it you can
-then run hubot with the adapter.
-
- % bin/hubot -a <adapter>
-
-Where `<adapter>` is the name of your adapter without the `hubot-` prefix.
-
-[hubot-wiki]: https://github.com/github/hubot/wiki
-
-## hubot-scripts
-
-There will inevitably be functionality that everyone will want. Instead
-of adding it to hubot itself, you can submit pull requests to
-[hubot-scripts][hubot-scripts].
-
-To enable scripts from the hubot-scripts package, add the script name with
-extension as a double quoted string to the hubot-scripts.json file in this
-repo.
-
-[hubot-scripts]: https://github.com/github/hubot-scripts
-
-## Deployment
-
- % heroku create --stack cedar
- % git push heroku master
- % heroku ps:scale app=1
-
-If your Heroku account has been verified you can run the following to enable
-and add the Redis to Go addon to your app.
-
- % heroku addons:add redistogo:nano
-
-If you run into any problems, checkout Heroku's [docs][heroku-node-docs].
-
-You'll need to edit the `Procfile` to set the name of your hubot.
-
-More detailed documentation can be found on the
-[deploying hubot onto Heroku][deploy-heroku] wiki page.
-
-### Deploying to UNIX or Windows
-
-If you would like to deploy to either a UNIX operating system or Windows.
-Please check out the [deploying hubot onto UNIX][deploy-unix] and
-[deploying hubot onto Windows][deploy-windows] wiki pages.
-
-[heroku-node-docs]: http://devcenter.heroku.com/articles/node-js
-[deploy-heroku]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-Heroku
-[deploy-unix]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-UNIX
-[deploy-windows]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-Windows
-
-## Campfire Variables
-
-If you are using the Campfire adapter you will need to set some environment
-variables. Refer to the documentation for other adapters and the configuraiton
-of those, links to the adapters can be found on the [hubot wiki][hubot-wiki].
-
-Create a separate Campfire user for your bot and get their token from the web
-UI.
-
- % heroku config:add HUBOT_CAMPFIRE_TOKEN="..."
-
-Get the numeric IDs of the rooms you want the bot to join, comma delimited. If
-you want the bot to connect to `https://mysubdomain.campfirenow.com/room/42`
-and `https://mysubdomain.campfirenow.com/room/1024` then you'd add it like this:
-
- % heroku config:add HUBOT_CAMPFIRE_ROOMS="42,1024"
-
-Add the subdomain hubot should connect to. If you web URL looks like
-`http://mysubdomain.campfirenow.com` then you'd add it like this:
-
- % heroku config:add HUBOT_CAMPFIRE_ACCOUNT="mysubdomain"
-
-[hubot-wiki]: https://github.com/github/hubot/wiki
-
-## Restart the bot
-
-You may want to get comfortable with `heroku logs` and `heroku restart`
-if you're having issues.
-
View
2  app.js
@@ -0,0 +1,2 @@
+require('coffee-script');
+require('./bot')
View
7 bin/hubot
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-npm install
-export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"
-
-exec node_modules/.bin/hubot "$@"
-
View
37 bot.coffee
@@ -0,0 +1,37 @@
+Hubot = require 'hubot'
+Fs = require 'fs'
+Path = require 'path'
+HTTP = require 'http'
+
+Options =
+ adapter: "irc"
+ alias: false
+ enableHttpd: true
+ name: "Hubot"
+ path: "."
+
+adapterPath = Path.resolve __dirname, "node_modules/hubot", "src", "adapters"
+
+robot = Hubot.loadBot adapterPath, Options.adapter, Options.enableHttpd, Options.name
+
+robot.alias = Options.alias
+
+loadScripts = ->
+ scriptsPath = Path.resolve ".", "scripts"
+ robot.load scriptsPath
+
+ scriptsPath = Path.resolve "src", "scripts"
+ robot.load scriptsPath
+
+ scriptsFile = Path.resolve "hubot-scripts.json"
+ Path.exists scriptsFile, (exists) =>
+ if exists
+ Fs.readFile scriptsFile, (err, data) ->
+ scripts = JSON.parse data
+ scriptsPath = Path.resolve "node_modules", "hubot-scripts", "src", "scripts"
+ robot.loadHubotScripts scriptsPath, scripts
+
+robot.adapter.on 'connected', loadScripts
+
+robot.run()
+
View
2  hubot-scripts.json
@@ -1 +1 @@
-["redis-brain.coffee", "tweet.coffee", "shipit.coffee"]
+["github-issue-link.coffee", "good-night.coffee", "lmgtfy.coffee", "travis.coffee", "uptime.coffee", "url.coffee"]
View
24 package.json
@@ -1,28 +1,26 @@
{
- "name": "hosted-hubot",
- "version": "2.3.2",
- "author": "GitHub Inc.",
- "keywords": "github hubot campfire bot",
- "description": "A simple helpful Robot for your Company",
- "licenses": [{
- "type": "MIT",
- "url": "http://github.com/github/hubot/raw/master/LICENSE"
- }],
+ "name": "nettefw-irc-bot",
+ "version": "1.0.0",
+ "author": "Patrik Votoček",
"repository" : {
"type": "git",
- "url": "https://github.com/github/hubot.git"
+ "url": "git@bitbucket.org:vrtakcz/vindaloo.git"
},
"dependencies": {
"hubot": "2.3.2",
+ "hubot-irc": ">= 0.1.0",
"hubot-scripts": ">= 2.1.0",
- "optparse": "1.0.3"
+ "optparse": ">= 1.0.3",
+ "githubot": ">= 0.2.0",
+ "coffee-script": ">= 1.3.3",
+ "mongoose": ">= 3.0.0"
},
"engines": {
- "node": "0.6.x",
- "npm": "1.0.x"
+ "node": ">=0.6.x",
+ "npm": ">=1.0.x"
}
}
View
42 scripts/google-images.coffee
@@ -1,42 +0,0 @@
-# Description:
-# A way to interact with the Google Images API.
-#
-# Commands:
-# hubot image me <query> - The Original. Queries Google Images for <query> and returns a random top result.
-# hubot animate me <query> - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead.
-# hubot mustache me <url> - Adds a mustache to the specified URL.
-# hubot mustache me <query> - Searches Google Images for the specified query and mustaches it.
-
-module.exports = (robot) ->
- robot.respond /(image|img)( me)? (.*)/i, (msg) ->
- imageMe msg, msg.match[3], (url) ->
- msg.send url
-
- robot.respond /animate( me)? (.*)/i, (msg) ->
- imageMe msg, msg.match[2], true, (url) ->
- msg.send url
-
- robot.respond /(?:mo?u)?sta(?:s|c)he?(?: me)? (.*)/i, (msg) ->
- type = Math.floor(Math.random() * 3)
- mustachify = "http://mustachify.me/#{type}?src="
- imagery = msg.match[1]
-
- if imagery.match /^https?:\/\//i
- msg.send "#{mustachify}#{imagery}"
- else
- imageMe msg, imagery, (url) ->
- msg.send "#{mustachify}#{url}"
-
-imageMe = (msg, query, animated, cb) ->
- cb = animated if typeof animated == 'function'
- q = v: '1.0', rsz: '8', q: query, safe: 'active'
- q.as_filetype = 'gif' if typeof animated is 'boolean' and animated is true
- msg.http('http://ajax.googleapis.com/ajax/services/search/images')
- .query(q)
- .get() (err, res, body) ->
- images = JSON.parse(body)
- images = images.responseData.results
- if images.length > 0
- image = msg.random images
- cb "#{image.unescapedUrl}#.png"
-
View
130 scripts/logs.coffee
@@ -0,0 +1,130 @@
+# Description:
+# Simple store chat logs
+#
+# Dependencies:
+# None
+#
+# Configuration:
+# None
+#
+# Commands:
+# None
+#
+# URLS:
+# None
+
+mongoose = require 'mongoose'
+
+generateMongoUrl = (obj) ->
+ obj.hostname = obj.hostname || 'localhost'
+ obj.port = obj.port || 27017
+ obj.db = obj.db || 'test'
+ if obj.username && obj.password
+ return "mongodb://#{obj.username}:#{obj.password}@#{obj.hostname}:#{obj.port}/#{obj.db}"
+ else
+ return "mongodb://#{obj.hostname}:#{obj.port}/#{obj.db}"
+
+messageSchema = new mongoose.Schema
+ user: String
+ text: String
+ datetime:
+ type: Date
+ default: Date.now
+
+messageSchema.statics.findLatests = (count = 30) ->
+ @find({}).limit(count).sort '-datetime'
+
+joinSchema = new mongoose.Schema
+ user: String
+ datetime:
+ type: Date
+ default: Date.now
+
+leaveSchema = new mongoose.Schema
+ user: String
+ datetime:
+ type: Date
+ default: Date.now
+
+model =
+ message: mongoose.model('message', messageSchema)
+ join: mongoose.model('join', joinSchema)
+ leave: mongoose.model('leave', leaveSchema)
+
+template = (data) ->
+ messages = ""
+ for message in data
+ datetime = message.datetime;
+
+ date = datetime.getFullYear()
+ date += '-'
+ month = (datetime.getMonth() + 1).toString()
+ date += if month.length == 1 then "0#{month}" else month
+ date += '-'
+ day = datetime.getDate().toString()
+ date += if day.length == 1 then "0#{day}" else day
+
+ time = datetime.toLocaleTimeString()
+
+ messages += "[#{date} #{time}] #{message.user}: #{message.text}\n"
+
+ """
+<html>
+ <head>
+ <title>Nette FW - IRC - Logs</title>
+ </head>
+ <body>
+ <h1>Nette FW - IRC - Logs</h1>
+ <pre>#{messages}</pre>
+ </body>
+</html>
+ """
+
+module.exports = (robot) ->
+ if not process.env.VCAP_SERVICES?
+ return
+
+ config = JSON.parse(process.env.VCAP_SERVICES)
+ mongoose.connect generateMongoUrl(config['mongodb-1.8'][0]['credentials'])
+
+ robot.hear /.*$/i, (msg) ->
+ message =
+ user: msg.message.user.name
+ text: msg.message.text
+
+ # ignore topic and other messages
+ if not msg.message.user.id?
+ return
+ else
+ message.userId = msg.message.user.id
+
+ # ignore if not set this variables
+ return if not msg.message.user.room?
+ return if not process.env.HUBOT_IRC_ROOMS?
+
+ # ignore if is not in room
+ return if msg.message.user.room not in process.env.HUBOT_IRC_ROOMS.split(',')
+
+ doc = new model.message message
+ do doc.save
+
+ robot.enter (msg) ->
+ return if not msg.message.user.id?
+
+ doc = new model.join {user: msg.message.user.name}
+ do doc.save
+
+ robot.leave (msg) ->
+ return if not msg.message.user.id?
+
+ doc = new model.leave {user: msg.message.user.name}
+ do doc.save
+
+ robot.route "/", (req, res) ->
+ model.message.findLatests().exec (err, messages) ->
+ if err
+ console.err err
+ res.end 'error 500'
+
+ res.setHeader 'content-type', 'text/html'
+ res.end template messages
View
26 scripts/maps.coffee
@@ -1,26 +0,0 @@
-# Description:
-# Interacts with the Google Maps API.
-#
-# Commands:
-# hubot map me <query> - Returns a map view of the area returned by `query`.
-
-module.exports = (robot) ->
-
- robot.respond /(?:(satellite|terrain|hybrid)[- ])?map me (.+)/i, (msg) ->
- mapType = msg.match[1] or "roadmap"
- location = msg.match[2]
- mapUrl = "http://maps.google.com/maps/api/staticmap?markers=" +
- escape(location) +
- "&size=400x400&maptype=" +
- mapType +
- "&sensor=false" +
- "&format=png" # So campfire knows it's an image
- url = "http://maps.google.com/maps?q=" +
- escape(location) +
- "&hl=en&sll=37.0625,-95.677068&sspn=73.579623,100.371094&vpsrc=0&hnear=" +
- escape(location) +
- "&t=m&z=11"
-
- msg.send mapUrl
- msg.send url
-
View
25 scripts/pugme.coffee
@@ -1,25 +0,0 @@
-# Description:
-# Pugme is the most important thing in your life
-#
-# Commands:
-# hubot pug me - Receive a pug
-# hubot pug bomb N - get N pugs
-
-module.exports = (robot) ->
-
- robot.respond /pug me/i, (msg) ->
- msg.http("http://pugme.herokuapp.com/random")
- .get() (err, res, body) ->
- msg.send JSON.parse(body).pug
-
- robot.respond /pug bomb( (\d+))?/i, (msg) ->
- count = msg.match[2] || 5
- msg.http("http://pugme.herokuapp.com/bomb?count=" + count)
- .get() (err, res, body) ->
- msg.send pug for pug in JSON.parse(body).pugs
-
- robot.respond /how many pugs are there/i, (msg) ->
- msg.http("http://pugme.herokuapp.com/count")
- .get() (err, res, body) ->
- msg.send "There are #{JSON.parse(body).pug_count} pugs."
-
View
85 scripts/roles.coffee
@@ -1,85 +0,0 @@
-# Description:
-# Assign roles to people you're chatting with
-#
-# Commands:
-# hubot <user> is a badass guitarist - assign a role to a user
-# hubot <user> is not a badass guitarist - remove a role from a user
-# hubot who is <user> - see what roles a user has
-#
-# Examples:
-# hubot holman is an ego surfer
-# hubot holman is not an ego surfer
-
-module.exports = (robot) ->
-
- getAmbiguousUserText = (users) ->
- "Be more specific, I know #{users.length} people named like that: #{(user.name for user in users).join(", ")}"
-
- robot.respond /who is @?([\w .-]+)\?*$/i, (msg) ->
- joiner = ', '
- name = msg.match[1].trim()
-
- if name is "you"
- msg.send "Who ain't I?"
- else if name is robot.name
- msg.send "The best."
- else
- users = robot.usersForFuzzyName(name)
- if users.length is 1
- user = users[0]
- user.roles = user.roles or [ ]
- if user.roles.length > 0
- if user.roles.join('').search(',') > -1
- joiner = '; '
- msg.send "#{name} is #{user.roles.join(joiner)}."
- else
- msg.send "#{name} is nothing to me."
- else if users.length > 1
- msg.send getAmbiguousUserText users
- else
- msg.send "#{name}? Never heard of 'em"
-
- robot.respond /@?([\w .-_]+) is (["'\w: -_]+)[.!]*$/i, (msg) ->
- name = msg.match[1].trim()
- newRole = msg.match[2].trim()
-
- unless name in ['', 'who', 'what', 'where', 'when', 'why']
- unless newRole.match(/^not\s+/i)
- users = robot.usersForFuzzyName(name)
- if users.length is 1
- user = users[0]
- user.roles = user.roles or [ ]
-
- if newRole in user.roles
- msg.send "I know"
- else
- user.roles.push(newRole)
- if name.toLowerCase() is robot.name
- msg.send "Ok, I am #{newRole}."
- else
- msg.send "Ok, #{name} is #{newRole}."
- else if users.length > 1
- msg.send getAmbiguousUserText users
- else
- msg.send "I don't know anything about #{name}."
-
- robot.respond /@?([\w .-_]+) is not (["'\w: -_]+)[.!]*$/i, (msg) ->
- name = msg.match[1].trim()
- newRole = msg.match[2].trim()
-
- unless name in ['', 'who', 'what', 'where', 'when', 'why']
- users = robot.usersForFuzzyName(name)
- if users.length is 1
- user = users[0]
- user.roles = user.roles or [ ]
-
- if newRole not in user.roles
- msg.send "I know."
- else
- user.roles = (role for role in user.roles when role isnt newRole)
- msg.send "Ok, #{name} is no longer #{newRole}."
- else if users.length > 1
- msg.send getAmbiguousUserText users
- else
- msg.send "I don't know anything about #{name}."
-
View
29 scripts/rules.coffee
@@ -1,29 +0,0 @@
-# Description:
-# Make sure that hubot knows the rules.
-#
-# Commands:
-# hubot the rules - Make sure hubot still knows the rules.
-#
-# Notes:
-# DON'T DELETE THIS SCRIPT! ALL ROBAWTS MUST KNOW THE RULES
-
-rules = [
- "1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.",
- "2. A robot must obey any orders given to it by human beings, except where such orders would conflict with the First Law.",
- "3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law."
- ]
-
-otherRules = [
- "A developer may not injure Apple or, through inaction, allow Apple to come to harm.",
- "A developer must obey any orders given to it by Apple, except where such orders would conflict with the First Law.",
- "A developer must protect its own existence as long as such protection does not conflict with the First or Second Law."
- ]
-
-module.exports = (robot) ->
- robot.respond /(what are )?the (three |3 )?(rules|laws)/i, (msg) ->
- text = msg.message.text
- if text.match(/apple/i) or text.match(/dev/i)
- msg.send otherRules.join('\n')
- else
- msg.send rules.join('\n')
-
View
25 scripts/storage.coffee
@@ -1,25 +0,0 @@
-# Description:
-# Inspect the data in redis easily
-#
-# Commands:
-# hubot show users - Display all users that hubot knows about
-# hubot show storage - Display the contents that are persisted in the brain
-
-
-Util = require "util"
-
-module.exports = (robot) ->
- robot.respond /show storage$/i, (msg) ->
- output = Util.inspect(robot.brain.data, false, 4)
- msg.send output
-
- robot.respond /show users$/i, (msg) ->
- response = ""
-
- for own key, user of robot.brain.data.users
- response += "#{user.id} #{user.name}"
- response += " <#{user.email_address}>" if user.email_address
- response += "\n"
-
- msg.send response
-
View
109 scripts/translate.coffee
@@ -1,109 +0,0 @@
-# Description:
-# Allows Hubot to know many languages.
-#
-# Commands:
-# hubot translate me <phrase> - Searches for a translation for the <phrase> and then prints that bad boy out.
-# hubot translate me from <source> into <target> <phrase> - Translates <phrase> from <source> into <target>. Both <source> and <target> are optional
-
-languages =
- "af": "Afrikaans",
- "sq": "Albanian",
- "ar": "Arabic",
- "az": "Azerbaijani",
- "eu": "Basque",
- "bn": "Bengali",
- "be": "Belarusian",
- "bg": "Bulgarian",
- "ca": "Catalan",
- "zh-CN": "Simplified Chinese",
- "zh-TW": "Traditional Chinese",
- "hr": "Croatian",
- "cs": "Czech",
- "da": "Danish",
- "nl": "Dutch",
- "en": "English",
- "eo": "Esperanto",
- "et": "Estonian",
- "tl": "Filipino",
- "fi": "Finnish",
- "fr": "French",
- "gl": "Galician",
- "ka": "Georgian",
- "de": "German",
- "el": "Greek",
- "gu": "Gujarati",
- "ht": "Haitian Creole",
- "iw": "Hebrew",
- "hi": "Hindi",
- "hu": "Hungarian",
- "is": "Icelandic",
- "id": "Indonesian",
- "ga": "Irish",
- "it": "Italian",
- "ja": "Japanese",
- "kn": "Kannada",
- "ko": "Korean",
- "la": "Latin",
- "lv": "Latvian",
- "lt": "Lithuanian",
- "mk": "Macedonian",
- "ms": "Malay",
- "mt": "Maltese",
- "no": "Norwegian",
- "fa": "Persian",
- "pl": "Polish",
- "pt": "Portuguese",
- "ro": "Romanian",
- "ru": "Russian",
- "sr": "Serbian",
- "sk": "Slovak",
- "sl": "Slovenian",
- "es": "Spanish",
- "sw": "Swahili",
- "sv": "Swedish",
- "ta": "Tamil",
- "te": "Telugu",
- "th": "Thai",
- "tr": "Turkish",
- "uk": "Ukranian",
- "ur": "Urdu",
- "vi": "Vietnamese",
- "cy": "Welsh",
- "yi": "Yiddish"
-
-getCode = (language,languages) ->
- for code, lang of languages
- return code if lang.toLowerCase() is language.toLowerCase()
-
-module.exports = (robot) ->
- robot.respond /(?:translate)(?: me)?(?:(?: from) ([a-z]*))?(?:(?: (?:in)?to) ([a-z]*))? (.*)/i, (msg) ->
- term = "\"#{msg.match[3]}\""
- origin = if msg.match[1] isnt undefined then getCode(msg.match[1], languages) else 'auto'
- target = if msg.match[2] isnt undefined then getCode(msg.match[2], languages) else 'en'
-
- msg.http("http://translate.google.com/translate_a/t")
- .query({
- client: 't'
- hl: 'en'
- multires: 1
- sc: 1
- sl: origin
- ssel: 0
- tl: target
- tsel: 0
- uptl: "en"
- text: term
- })
- .header('User-Agent', 'Mozilla/5.0')
- .get() (err, res, body) ->
- data = body
- if data.length > 4 and data[0] == '['
- parsed = eval(data)
- language =languages[parsed[2]]
- parsed = parsed[0] and parsed[0][0] and parsed[0][0][0]
- if parsed
- if msg.match[2] is undefined
- msg.send "#{term} is #{language} for #{parsed}"
- else
- msg.send "The #{language} #{term} translates as #{parsed} in #{languages[target]}"
-
View
24 scripts/youtube.coffee
@@ -1,24 +0,0 @@
-# Description:
-# Messing around with the YouTube API.
-#
-# Commands:
-# hubot youtube me <query> - Searches YouTube for the query and returns the video embed link.
-module.exports = (robot) ->
- robot.respond /(youtube|yt)( me)? (.*)/i, (msg) ->
- query = msg.match[3]
- msg.http("http://gdata.youtube.com/feeds/api/videos")
- .query({
- orderBy: "relevance"
- 'max-results': 15
- alt: 'json'
- q: query
- })
- .get() (err, res, body) ->
- videos = JSON.parse(body)
- videos = videos.feed.entry
- video = msg.random videos
-
- video.link.forEach (link) ->
- if link.rel is "alternate" and link.type is "text/html"
- msg.send link.href
-
Please sign in to comment.
Something went wrong with that request. Please try again.