Coder Social home page Coder Social logo

hubot-google-images's Introduction

hubot-google-images

A hubot script that interacts with the Google Custom Search API for greater productivity and lulz.

See src/google-images.coffee for full documentation.

Installation

In hubot project repo, run:

npm install hubot-google-images --save

Then add hubot-google-images to your external-scripts.json:

[
  "hubot-google-images"
]

Configuration

Custom Search Engine

Google no longer offers an unregistered image search API. You must set up a Google Custom Search API and set the environment variables HUBOT_GOOGLE_CSE_ID and HUBOT_GOOGLE_CSE_KEY.

The Custom Search API provides up to 100 search queries per day for free. If you need more than that you'll have to pay.

CSE setup details

  1. Create a CSE via these instructions.
  • To simulate the old behavior: select "Search the entire web but emphasize included sites" in 'Sites to Search'
  • Give it any site on creation, and then remove it when it's selected, unless you want to emphasize that site(s).
  1. Turn on images in Edit Search Engine > Setup > Basic > Image Search
  2. Get the CSE ID in Edit Search Engine > Setup > Basic > Details (via these instructions)
  3. Get the CSE KEY here https://code.google.com/apis/console
  • You will need a project, you may reuse an existing one, or create a new one
  • Select the project
  • Goto the API manager and create a server credential and use the key from that credential
  1. Enable Custom Search API
  1. Update your conf (and your modules if necessary)

Custom Mustachification Service

To enable the mustache me feature, set the environment variable HUBOT_MUSTACHIFY_URL to your mustachify server url. More info and the source code of mustachify can be found at https://github.com/afeld/mustachio

Listen for image me and animate me

If you want to have your bot respond to any chat that begins with image me or animate me, you can add HUBOT_GOOGLE_IMAGES_HEAR to a non-empty value to have the robot listen to all chat.

Sample Interaction

user1>> hubot image me bananas
hubot>> http://upload.wikimedia.org/wikipedia/commons/4/4c/Bananas.jpg
user2>> hubot animate me it's happening
hubot>> http://i.kinja-img.com/gawker-media/image/upload/s--8U6TKXoi--/thfydh8egnt8he5esoz8.gif
user3>> hubot mustache me family portrait
hubot>> http://mustachify.me/1?src=http://www.daviddanielsphotography.com/wp-content/uploads/2013/03/Chowen-Family-Portraits-east-of-Park-City-13.jpg

hubot-google-images's People

Contributors

afeld avatar carsonb avatar denwey avatar dhendler avatar emilong avatar fkchang avatar gr2m avatar jeffbyrnes avatar louim avatar okize avatar seriallos avatar splunk-djenkins avatar taviscaron avatar technicalpickles avatar trmcnvn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hubot-google-images's Issues

CSE API 1.0 Deprecation

Anyone else get the deprecation email from Google?

The Custom Search Element API 1.0, which was deprecated in 2012 in favor of API 2.0, is now no longer maintained. API 1.0 may experience outages and failures, and possibly stop working entirely.

You’re receiving this message because our records show you might currently be using the Custom Search Element API 1.0. You can confirm if you’re using this version by looking at the code on your search page for a call to google.search.CustomSearchControl.

Next Steps

To avoid any potential interruptions in service, please update your website to use the Custom Search Element API 2.0. The easiest way to transition is through the CSE Control Panel at cse.google.com, where you can generate your new Custom Search Engine code and add it to your website.

Adding Limit Option per User

Hi, I wonder if it's possible to add such feature, because some people don't want to get flooded with the others who keep issuing Hubot to "image me" or "animate me" in some channels.

The idea is limiting a user from keep issuing those commands, like quota request per day, then in the next day the quota will be reset to zero.

I wrote a code to use HubotBrain to store the data for users (https://gist.github.com/irfanfadilah/2c46208eb4dcb2f03d05) but not sure how to integrate it to Google Images Script.

  • the Gist is for Slack adapter and using Heroku + Redis.

So what do you think guys?

Image results appear twice.

For a few weeks now, possibly since a Slack update, hubot-google-images' results are displayed twice. The actual image URL isn't sent twice, the image is just displayed twice. I thought it was just an issue with Slack but no other integration is having any issues.

double image

collapsed

Expected Behavior:

  • Image results are displayed one time.

Prereq(s):

  • Must have hubot set up in a slack channel.
  • Must have the hubot-google-images library installed and configured.

Steps to Reproduce:

  • Say hubot animate a puppy in the room with hubot.
  • Observe the image displays twice.

Animated results are hit or miss

If you say animate me kittens you might not get an actual animation. Google image search API does not seem to provide an equivalent to the "experimental" imgtype=animated neither in the deprecated image search API nor the Custom Search Engine API. The current makeshift approach is to tack "animated" on to the query.

A better approach would be to use the giphy API. or some other reliable source of animated GIF's.

Bad HTTP response :( 400

Getting this error when asking for images. Is there a log or a way to debug what's going on? I can see the request being returned as a 400 in the Google Developers Console stats, but can't see the actual request to be able to debug.

Request timeout crashes Hubot

Hello!

I have an issue with Google images search: because of the proxy I'm behind, the request sometimes timeout.

Though the timeout is nothing you can do about, the problem is that whenever the requests timeout, my hubot instance crashes.

The problem is hubot-google-images tries to get the statusCode field of an answer that doesn't contain any; I get the following answer:

{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' }

I cannot test it easily on my side (because I do not have full control of my development environment), but I think replacing line 84 of hubot-google-images.coffee:

if res.statusCode is 403

by

if not ('statusCode' of res)
  ms.send "Timeout :("
else if res.statusCode is 403

should fix this problem.

Adding maintainers?

Would y'all be amenable to adding to the maintainer team? I've got a handful of Hubot script packages I maintain, happy to take this one on for general purpose maintenance.

(Mainly looking to get #50 taken care of for Hubot 9+ compatibility.)

cc @technicalpickles @HaroldPutman

HTTPS links?

My hubot is giving me http images, but that leaks metadata in cleartext, how can I make it return only https results?

Manage default ban site or recommand site list.

Hi, I really appreciate this module. When I chat on slack, it is very useful finding proper image quickly.

However, sometimes I need to filtering like "hubot img -" or "hubot img site:".

I tried to add that list automatically at hubot level parsing msg part. But, It makes complex code sequence and interrupt other module.

If you have any idea for improvement of this function. Please help.

Google AJAX Image Search: "This API is no longer available"

Looks like Google may have finally killed the API:

$ curl https://ajax.googleapis.com/ajax/services/search/images\?v\=1.0\&q\=testing
{"responseData": null, "responseDetails": "This API is no longer available.", "responseStatus": 403}%

how to pass through a proxy

I'm running my hubot behind a proxy. How should I modify the scripts or use another solution to pass through the proxy? Please advise, thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.