hubot-googledrive-search
v3.0.2
Published
Google drive search for hubot!
Downloads
4
Maintainers
Readme
hubot-googledrive-search
Search your google drive with hubot! Authentication handeled by hubot-google-auth.
Installation
- In your project repo run:
npm install hubot-googledrive-search --save
- Then add the follwing to your external-scripts.json:
[
'hubot-googledrive-search'
]
Configuration
This script requires you to generate oauth2 credentials for the drive account that you want hubot to be able to access. Currently this scipt is configured to give hubot access to all of drive (the specific scope used is: 'https://www.googleapis.com/auth/drive').
- Generate a client secret.json file by following step 1 here
- Set these required environemnt variables (found in your client secret.json file):
- HUBOT_DRIVE_CLIENT_ID**="your_client_id"
- HUBOT_DRIVE_CLIENT_SECRET**="your_client_secret"
- HUBOT_DRIVE_REDIRECT_URL**="the_first_uri_in_the_list"
- Load the script and attempt to interact with hubot. You will have to authorize the app to get your inital token and refresh token. The script will then store the refresh token in the hubot brain for future use, so this process should only need to be done once. Here's a sample initial interaction:
user>> @hubot drive search title= My Cool File
hubot>> Authorize this app by visiting: https://google.com/some_thing_with_your_client_info
Then use @hubot drive set code <code>
user>> @hubot drive set code 123412351235
hubot>> Hubot drive code successfully set!
user>> @hubot search title= Cool File
hubot>> 1.) This is a Cool File
https://google.drive/1234h123h4123h
2.) Some Cool File
https://google.drive/qwer1353451asfds
Features
This script can be used to search your drive in a variety of ways:
- Use a google query string to search drive. Find information on query strings here: https://developers.google.com/drive/v2/web/search-parameters
user>> @hubot drive search query= fullText contains 'important' and trashed = true
- Use either a title and/or a contains parameter. Equivalent query string shown below each example.
user>> @hubot drive search title= My Cool File
#equivalent to:
user>> @hubot drive search query= title contains 'My Cool File'
user>> @hubot drive search contains= This is the coolest file ever
#equivalent to:
user>> @hubot drive search query= fullText contains 'This is the coolest file ever'
user>> @hubot drive search title= My Cool File contains= This is the coolest file ever
#equivalent to:
user>> @hubot drive search query= title contains 'My Cool File' and fullText contains 'This is the coolest file ever'
Notes
Since hubot needs to use the redis brain to store the drive tokens and expiration time make sure that the following keys don't conflict with any other keys being used in the brain:
'HUBOT_DRIVE_GOOGLE_AUTH_TOKEN'
'HUBOT_DRIVE_GOOGLE_AUTH_REFRESH_TOKEN'
'HUBOT_DRIVE_GOOGLE_AUTH_EXPIRE_TIME'