Requires plugin: lookup.sheetapi
NOTE: You need a Serviceaccount (explained below) and you need to share the sheet with it.
/bot lookup [<MAX] <keyword>
- Need to enable in config:
spreadsheet_enabled
,spreadsheet_url
andspreadsheet_credentials_file
spreadsheet_worksheet
allows you to optionaly define the worksheet to use by name.- Will look up each row of a spreadsheet and if the keyword is found will return the whole row
- if <MAX is specified, the lookup will return rows up to the MAX integer specified. (Default = 5)
- As of 2.6,
spreadsheet_enabled
andspreadsheet_url
can be defined on a conversation-level config
- Browse to the Gogle Developers Console and login via any Google Account (I recommend using your bot account)
- Add a new Project with a name you want if you have not already created one.
- Go to "API&auth" and activate the Drive API
- Go to Credentials and Choose under "New Credentials" the Option "Service Account Key"
- Upload the automaticly downloaded json file in "~/.local/share/hangoutsbot/creds.json" (or any directory that the bot is able to access)
- Add
"spreadsheet_credentials_file": "~/.local/share/hangoutsbot/creds.json"
to the config file. Remember to change the filename in this path to the filename of your json file.
Note: Due to a missing feature in the here used lib it isn't currently possible to use a public sheet with the bot. This PR can be found here. To use the example you need to manually share the sheet with the bot
Using this test spreadsheet
config.json
fragment:
...,
"spreadsheet_enabled": true,
"spreadsheet_url": "https://docs.google.com/spreadsheets/d/1jMEtvYhTyuso-ZV0tCgOw4oZ9xDwUgWPiymnEmBw02s",
"spreadsheet_credentials_file": "~/.local/share/hangoutsbot/creds.json",
...
Bot output:
User: /bot lookup dc
Bot: Results for keyword "dc":
2 rows found. Only returning first 5.
Row 1: | bdc | I | J | K | L |
Row 2: | dca | M | N | O | P |