hubot-datacircle 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Datacircle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,84 @@
1
- # Temporary Holding Version
1
+ # hubot-datacircle
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website.
4
+
5
+ Our website: https://datacircle.dev
6
+
7
+ This [Hubot](https://hubot.github.com) script gives your bot four chat commands. The commands call Datacircle's open API, https://api.datacircle.dev/v1. You need no key and no account. The script works with any adapter: Slack, Microsoft Teams, Discord and the shell.
8
+
9
+ | Command | Gives | Call |
10
+ | --- | --- | --- |
11
+ | `hubot datacircle apis [words]` | The GTM APIs on Datacircle, or the APIs with your words in the name. Each API comes with a slug and the best plan | `GET /apis` |
12
+ | `hubot datacircle best <api>` | The best plans for one API, by score out of 100. Each plan shows a price per 1,000 and the call of the provider's API | `GET /apis/{slug}/best` |
13
+ | `hubot datacircle plans <words>` | Plans with your words in the plan name or provider name. Search one API or every API | `GET /plans` |
14
+ | `hubot datacircle provider <name>` | The provider's rank on each API, the best rank first | `GET /providers/{slug}` |
15
+
16
+ ## Install
17
+
18
+ In your bot's folder:
19
+
20
+ ```bash
21
+ npm install hubot-datacircle
22
+ ```
23
+
24
+ Then add `hubot-datacircle` to `external-scripts.json`:
25
+
26
+ ```json
27
+ [
28
+ "hubot-help",
29
+ "hubot-datacircle"
30
+ ]
31
+ ```
32
+
33
+ The script needs Hubot 11 or later and Node.js 18 or later.
34
+
35
+ ## Use
36
+
37
+ Send a command to your bot:
38
+
39
+ ```text
40
+ hubot datacircle best email-finder
41
+ ```
42
+
43
+ The bot answers:
44
+
45
+ ```text
46
+ Who is best for Employee email (email-finder), of 5,456 plans:
47
+ 1. GetProspect, Growth 50k (Email Finder): 84.1/100, $7.98 per 1,000
48
+ 2. GetProspect, Growth 20k (Email Finder): 82.2/100, $9.95 per 1,000
49
+ 3. WizLeads, Cartel (Find Work Email): 78.2/100, $4.49 per 1,000
50
+ 4. DataForB2B, Growth (Enrich Profile, work email): 78.1/100, $0.10 per 1,000
51
+ 5. WizLeads, Kingpin (Find Work Email): 78.1/100, $4.99 per 1,000
52
+ https://datacircle.dev/best-email-finder-api
53
+ ```
54
+
55
+ More examples:
56
+
57
+ - `hubot datacircle apis linkedin` lists the APIs with "linkedin" in the name.
58
+ - `hubot datacircle best Employee email` gives the same answer as `hubot datacircle best email-finder`. The script finds the API by name.
59
+ - `hubot datacircle plans getprospect -a email-finder -s price` gives the GetProspect plans on the email-finder API, cheapest first.
60
+ - `hubot datacircle provider Bright Data` gives the rank of Bright Data on each API.
61
+
62
+ Add `-l <n>` to any command to get n lines. `hubot datacircle` alone shows every command.
63
+
64
+ On Hubot 14, `hubot help` lists the four commands as `datacircle.apis`, `datacircle.best`, `datacircle.plans` and `datacircle.provider`. You can send each command in the dot form, like `hubot datacircle.best email-finder`. On older versions, hubot-help lists the four commands.
65
+
66
+ ## Settings
67
+
68
+ | Variable | Default | Use |
69
+ | --- | --- | --- |
70
+ | `HUBOT_DATACIRCLE_LIMIT` | `5` | Lines per reply without `-l` |
71
+ | `HUBOT_DATACIRCLE_ENDPOINT` | `https://api.datacircle.dev/v1` | The API's address |
72
+
73
+ ## Network
74
+
75
+ Each command makes one or two HTTPS GET requests to https://api.datacircle.dev/v1 with the `fetch` of Node.js. A request holds the words of the command and nothing more. No user, room or message from your chats goes in a request. The API takes up to 60 calls a minute from one IP address. The API can ask the script to wait. For a wait of a few seconds, the script waits and tries once more. For a longer wait, the script tells the user the number of seconds to wait. The script stores nothing.
76
+
77
+ ## Links
78
+
79
+ - Datacircle: https://datacircle.dev
80
+ - The API: https://datacircle.dev/api
81
+ - The spec of the API: https://api.datacircle.dev/v1/openapi.json
82
+ - The meaning of each field: https://datacircle.dev/fields
83
+
84
+ MIT license.
package/index.mjs ADDED
@@ -0,0 +1,17 @@
1
+ // hubot-datacircle: Hubot imports each package of external-scripts.json and calls its default export with the robot.
2
+ // robot.loadFile also reads the script's Commands for hubot-help.
3
+
4
+ import path from 'node:path'
5
+ import { fileURLToPath } from 'node:url'
6
+ import script from './src/datacircle.mjs'
7
+
8
+ const scripts = path.join(path.dirname(fileURLToPath(import.meta.url)), 'src')
9
+
10
+ export default async (robot, names) => {
11
+ // external-scripts.json as an object names the scripts of a package to load: { "hubot-datacircle": ["datacircle.mjs"] }.
12
+ if (Array.isArray(names) && !names.includes('*') && !names.includes('datacircle.mjs')) return
13
+ if (typeof robot.loadFile === 'function') return robot.loadFile(scripts, 'datacircle.mjs')
14
+ return script(robot)
15
+ }
16
+
17
+ export { answer, client, parse, slugify, dollars, DatacircleError, BASE_URL, VERSION } from './src/answer.mjs'
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "hubot-datacircle",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Find the best GTM APIs. A Hubot script for Datacircle's open API. Chat commands list the GTM APIs and show the best plans for each API. Other commands search the plans and show the rank of a provider. You need no key.",
5
+ "keywords": [
6
+ "hubot",
7
+ "hubot-scripts",
8
+ "chatbot",
9
+ "gtm",
10
+ "gtm-apis",
11
+ "api",
12
+ "api-pricing",
13
+ "datacircle"
14
+ ],
15
+ "homepage": "https://datacircle.dev",
16
+ "bugs": {
17
+ "url": "https://github.com/waynehamadi/hubot-datacircle/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/waynehamadi/hubot-datacircle.git"
22
+ },
23
+ "license": "MIT",
24
+ "author": "Datacircle <wayne@datacircle.dev> (https://datacircle.dev)",
25
+ "contributors": [
26
+ "Wayne Hamadi <wayne@datacircle.dev>"
27
+ ],
28
+ "type": "module",
29
+ "main": "./index.mjs",
30
+ "exports": {
31
+ ".": "./index.mjs",
32
+ "./package.json": "./package.json"
33
+ },
34
+ "files": [
35
+ "index.mjs",
36
+ "src"
37
+ ],
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "scripts": {
42
+ "test": "node --test tests/robot.test.mjs"
43
+ },
44
+ "peerDependencies": {
45
+ "hubot": ">=11"
46
+ },
47
+ "devDependencies": {
48
+ "hubot": "14.1.1"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ }
53
+ }
package/src/answer.mjs ADDED
@@ -0,0 +1,253 @@
1
+ // The replies of hubot-datacircle, from Datacircle's open API: find the best GTM APIs. The API needs no key:
2
+ // https://api.datacircle.dev/v1 (its spec: https://api.datacircle.dev/v1/openapi.json). More at https://datacircle.dev
3
+
4
+ /** The API's address. */
5
+ export const BASE_URL = 'https://api.datacircle.dev/v1'
6
+
7
+ /** This package's version, sent in each call's User-Agent. */
8
+ export const VERSION = '0.1.0'
9
+
10
+ /** An answer of 4xx or a network fault: its words are the reply. */
11
+ export class DatacircleError extends Error {
12
+ constructor (status, message, answer = {}) {
13
+ super(message)
14
+ this.name = 'DatacircleError'
15
+ this.status = status
16
+ this.answer = answer
17
+ }
18
+ }
19
+
20
+ /** The API's rule for a slug: the name in lowercase letters and digits, the rest a hyphen. */
21
+ export function slugify (name) {
22
+ return name
23
+ .normalize('NFKD')
24
+ .replace(/\p{Mn}/gu, '')
25
+ .toLowerCase()
26
+ .replace(/[^a-z0-9]+/g, '-')
27
+ .replace(/^-+|-+$/g, '')
28
+ }
29
+
30
+ /** A plan's price of 1,000 items in dollars, as a reply shows it. */
31
+ export function dollars (perThousand) {
32
+ if (typeof perThousand !== 'number') return undefined
33
+ const shown = perThousand === 0 || perThousand >= 0.01
34
+ ? perThousand.toFixed(2).replace(/\.00$/, '')
35
+ : String(Number(perThousand.toPrecision(2)))
36
+ return `$${shown} per 1,000`
37
+ }
38
+
39
+ /** A plan's name and the call of the provider's API the plan prices, as one provider's plans of one API differ by their call. */
40
+ function named (plan) {
41
+ return plan.call ? `${plan.plan} (${plan.call})` : String(plan.plan)
42
+ }
43
+
44
+ /** A plan's score and price, the parts the API gives. */
45
+ function worth (plan) {
46
+ const parts = [typeof plan.score === 'number' ? `${plan.score}/100` : 'no score yet']
47
+ const price = dollars(plan.perThousand)
48
+ if (price) parts.push(price)
49
+ return parts.join(', ')
50
+ }
51
+
52
+ /** A count as a reply shows it, like 4,556. */
53
+ const count = (n) => (typeof n === 'number' ? n.toLocaleString('en-US') : String(n))
54
+
55
+ function words (text) {
56
+ return text.toLowerCase().replace(/-/g, ' ').split(/\s+/).filter(Boolean)
57
+ }
58
+
59
+ /** A command's words and its options: -a or --api, -s or --sort, -l or --limit, each with the word after it. */
60
+ export function parse (rest) {
61
+ const tokens = rest.split(/\s+/).filter(Boolean)
62
+ const kept = []
63
+ const found = {}
64
+ for (let i = 0; i < tokens.length; i++) {
65
+ const option = { '-a': 'api', '--api': 'api', '-s': 'sort', '--sort': 'sort', '-l': 'limit', '--limit': 'limit' }[tokens[i].toLowerCase()]
66
+ if (option && i + 1 < tokens.length) {
67
+ const value = tokens[++i]
68
+ if (option === 'limit') {
69
+ const n = Number.parseInt(value, 10)
70
+ if (n > 0) found.limit = n
71
+ } else {
72
+ found[option] = value
73
+ }
74
+ } else {
75
+ kept.push(tokens[i])
76
+ }
77
+ }
78
+ return { text: kept.join(' '), ...found }
79
+ }
80
+
81
+ /** Calls the API. Each call is one HTTPS GET. A 429 of a few seconds is waited for once. */
82
+ export function client (endpoint = BASE_URL) {
83
+ const base = endpoint.replace(/\/+$/, '')
84
+
85
+ async function get (path, query = {}) {
86
+ const url = new URL(base + path)
87
+ for (const [key, value] of Object.entries(query)) {
88
+ if (value !== undefined && value !== '') url.searchParams.set(key, String(value))
89
+ }
90
+ for (let attempt = 0; ; attempt++) {
91
+ let response
92
+ try {
93
+ response = await fetch(url, {
94
+ headers: { Accept: 'application/json', 'User-Agent': `hubot-datacircle/${VERSION}` },
95
+ signal: AbortSignal.timeout(20_000)
96
+ })
97
+ } catch (error) {
98
+ throw new DatacircleError(0, `Datacircle's API did not answer: ${error.message}`)
99
+ }
100
+ if (response.status === 429) {
101
+ const wait = Number.parseInt(response.headers.get('Retry-After') ?? '', 10) || 60
102
+ if (attempt === 0 && wait <= 10) {
103
+ await new Promise((resolve) => setTimeout(resolve, wait * 1000))
104
+ continue
105
+ }
106
+ throw new DatacircleError(429, `Datacircle's API takes 60 calls a minute from one address. Try again in ${wait} ${wait === 1 ? 'second' : 'seconds'}.`)
107
+ }
108
+ let answer
109
+ try {
110
+ answer = JSON.parse(await response.text())
111
+ } catch {
112
+ answer = undefined
113
+ }
114
+ if (response.status >= 400) {
115
+ const message = typeof answer?.error === 'string' && answer.error ? answer.error : `${response.status} ${response.statusText}`.trim()
116
+ throw new DatacircleError(response.status, message, answer ?? {})
117
+ }
118
+ if (answer === undefined) throw new DatacircleError(response.status, "Datacircle's API gave no JSON.")
119
+ return answer
120
+ }
121
+ }
122
+
123
+ return { get }
124
+ }
125
+
126
+ /**
127
+ * The reply to one command, its words after "datacircle", like "best email-finder".
128
+ * config.prefix: the words before each command in the replies' examples. config.limit: lines per reply. config.endpoint: the API's address.
129
+ */
130
+ export async function answer (command, config = {}) {
131
+ const prefix = config.prefix || 'datacircle'
132
+ const lines = config.limit ?? 5
133
+ const { get } = client(config.endpoint || BASE_URL)
134
+ const [verb = '', ...rest] = command.trim().split(/\s+/)
135
+ const { text, api, sort, limit } = parse(rest.join(' '))
136
+
137
+ /** The APIs whose name or slug holds the most of the words, the sheet's order within each. */
138
+ async function findApis (text) {
139
+ const apis = await get('/apis')
140
+ const wanted = words(text)
141
+ const found = apis
142
+ .map((api, order) => {
143
+ const named = `${api.api ?? ''} ${String(api.slug ?? '').replace(/-/g, ' ')}`.toLowerCase()
144
+ return { api, order, matched: wanted.filter((word) => named.includes(word)).length }
145
+ })
146
+ .filter(({ matched }) => matched > 0 || wanted.length === 0)
147
+ .sort((a, b) => b.matched - a.matched || a.order - b.order)
148
+ return { apis: found.map(({ api }) => api), all: apis.length, matched: found[0]?.matched ?? 0 }
149
+ }
150
+
151
+ try {
152
+ switch (verb.toLowerCase()) {
153
+ case 'apis': {
154
+ const { apis, all, matched } = await findApis(text)
155
+ const wanted = words(text)
156
+ if (wanted.length > 0 && matched === 0) {
157
+ return `No API's name holds "${text}". To see a provider: ${prefix} provider ${text}`
158
+ }
159
+ const shown = apis.slice(0, limit ?? lines)
160
+ const out = [wanted.length > 0
161
+ ? `${count(apis.length)} of the ${count(all)} GTM APIs on Datacircle match "${text}":`
162
+ : `${count(all)} GTM APIs on Datacircle. The first ${shown.length}:`]
163
+ for (const api of shown) {
164
+ const best = api.best ? `. Best: ${api.best.provider}, ${api.best.plan}, ${worth(api.best)}` : ''
165
+ out.push(`${api.api} (${api.slug}): ${count(api.plans)} plans from ${count(api.providers)} providers${best}`)
166
+ }
167
+ if (shown.length > 0) out.push(`Who is best for one, like: ${prefix} best ${shown[0].slug}`)
168
+ return out.join('\n')
169
+ }
170
+ case 'best': {
171
+ if (!text) return `Give an API's slug, like: ${prefix} best email-finder`
172
+ const n = Math.min(limit ?? lines, 50)
173
+ let found
174
+ try {
175
+ found = await get(`/apis/${slugify(text)}/best`, { limit: n })
176
+ } catch (error) {
177
+ if (!(error instanceof DatacircleError && error.status === 404)) throw error
178
+ // A name or words in place of the slug, like Employee email or email finder: the API whose name holds them all.
179
+ const { apis, matched } = await findApis(text)
180
+ if (apis.length === 0 || matched < words(text).length) {
181
+ return `No API is named "${text}". ${prefix} apis gives each API's slug. To see a provider: ${prefix} provider ${text}`
182
+ }
183
+ found = await get(`/apis/${apis[0].slug}/best`, { limit: n })
184
+ }
185
+ const out = [`Who is best for ${found.api} (${found.slug}), of ${count(found.total)} plans:`]
186
+ for (const plan of found.plans ?? []) {
187
+ out.push(`${plan.rank ?? '-'}. ${plan.provider}, ${named(plan)}: ${worth(plan)}`)
188
+ }
189
+ out.push(found.bestPage ?? found.sheetPage)
190
+ return out.join('\n')
191
+ }
192
+ case 'plans': {
193
+ const n = Math.min(limit ?? lines, 50)
194
+ const found = await get('/plans', { api, query: text, sort, limit: n })
195
+ const plans = found.plans ?? []
196
+ if (plans.length === 0) {
197
+ const where = api ? `of ${api}` : 'on Datacircle'
198
+ return text ? `No plan ${where} matches "${text}".` : `No plan ${where}.`
199
+ }
200
+ const out = [`${count(found.total)} plans match. The first ${plans.length}:`]
201
+ for (const plan of plans) {
202
+ const rank = typeof plan.rank === 'number' ? ` #${plan.rank}` : ''
203
+ out.push(`${plan.provider}, ${named(plan)}, on ${plan.api}${rank}: ${worth(plan)}`)
204
+ }
205
+ out.push('https://datacircle.dev')
206
+ return out.join('\n')
207
+ }
208
+ case 'provider': {
209
+ if (!text) return `Give a provider's name, like: ${prefix} provider Bright Data`
210
+ let found
211
+ try {
212
+ found = await get(`/providers/${slugify(text)}`)
213
+ } catch (error) {
214
+ if (!(error instanceof DatacircleError && error.status === 404)) throw error
215
+ // A name whose slug is not the provider's, like a part of it: the provider of the best plan whose provider's name holds it.
216
+ const plans = await get('/plans', { query: text, limit: 50 })
217
+ const wanted = words(text)
218
+ const provider = (plans.plans ?? [])
219
+ .map((plan) => String(plan.provider ?? ''))
220
+ .find((named) => wanted.every((word) => named.toLowerCase().includes(word)))
221
+ if (!provider) return `No provider on Datacircle is named "${text}".`
222
+ found = await get(`/providers/${slugify(provider)}`)
223
+ }
224
+ const apis = found.apis ?? []
225
+ const rank = (api) => (typeof api.rank === 'number' ? api.rank : Infinity)
226
+ apis.sort((a, b) => rank(a) - rank(b))
227
+ const ranked = apis.filter((api) => typeof api.rank === 'number').length
228
+ const shown = apis.slice(0, limit ?? lines)
229
+ const out = [`${found.provider} has plans on ${apis.length} GTM APIs, a rank on ${ranked} of them. Its best ranks:`]
230
+ for (const api of shown) {
231
+ const plans = api.plans ?? []
232
+ const best = plans.filter((plan) => typeof plan.rank === 'number').sort((a, b) => a.rank - b.rank)[0] ?? plans[0]
233
+ const where = typeof api.rank === 'number' ? `#${api.rank} on ${api.api}` : `On ${api.api}, no rank yet`
234
+ out.push(best ? `${where}: ${named(best)}, ${worth(best)}` : where)
235
+ }
236
+ out.push(`Its plans: ${prefix} plans ${found.provider}`)
237
+ return out.join('\n')
238
+ }
239
+ default:
240
+ return [
241
+ 'Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website.',
242
+ `${prefix} apis email: the GTM APIs with your words in the name`,
243
+ `${prefix} best email-finder: the best plans for one API`,
244
+ `${prefix} plans getprospect: the plans of a provider on every API. Add -a email-finder to see one API. Add -s price to list the cheapest plans first.`,
245
+ `${prefix} provider Bright Data: the rank of a provider on each API`,
246
+ 'Add -l and a number to get more lines. https://datacircle.dev'
247
+ ].join('\n')
248
+ }
249
+ } catch (error) {
250
+ if (error instanceof DatacircleError) return error.message
251
+ throw error
252
+ }
253
+ }
@@ -0,0 +1,69 @@
1
+ // Description:
2
+ // Find the best GTM APIs. The commands call Datacircle's open API, https://api.datacircle.dev/v1, with no key. https://datacircle.dev
3
+ //
4
+ // Configuration:
5
+ // HUBOT_DATACIRCLE_LIMIT - lines per reply when a command has no -l (default 5)
6
+ // HUBOT_DATACIRCLE_ENDPOINT - the address of the API (default https://api.datacircle.dev/v1)
7
+ //
8
+ // Commands:
9
+ // hubot datacircle - shows every command of Datacircle
10
+ // hubot datacircle apis [words] - the GTM APIs on Datacircle, or the APIs with your words in the name
11
+ // hubot datacircle best <api> - the best plans for one API, by score out of 100
12
+ // hubot datacircle plans <words> [-a <api>] [-s price] - the plans with your words in the plan name or provider name
13
+ // hubot datacircle provider <name> - the rank of a provider on each API
14
+ //
15
+ // Notes:
16
+ // Add -l <n> to a command to get n lines. Each command makes one or two HTTPS GET requests to the API.
17
+ //
18
+ // Author:
19
+ // Datacircle <wayne@datacircle.dev>
20
+
21
+ import { answer } from './answer.mjs'
22
+
23
+ /** The commands, as Hubot 14's command bus lists them in its help. */
24
+ const VERBS = {
25
+ apis: ['The GTM APIs on Datacircle, or the APIs with your words in the name', 'apis linkedin'],
26
+ best: ['The best plans for one API, by score out of 100', 'best email-finder'],
27
+ plans: ['The plans with your words in the plan name or provider name. -a <api> for one API, -s price for the cheapest first', 'plans getprospect -a email-finder -s price'],
28
+ provider: ['The rank of a provider on each API', 'provider Bright Data']
29
+ }
30
+
31
+ export default (robot) => {
32
+ const settings = {
33
+ prefix: `${robot.name} datacircle`,
34
+ limit: Number.parseInt(process.env.HUBOT_DATACIRCLE_LIMIT ?? '', 10) > 0 ? Number.parseInt(process.env.HUBOT_DATACIRCLE_LIMIT, 10) : 5,
35
+ endpoint: process.env.HUBOT_DATACIRCLE_ENDPOINT || undefined
36
+ }
37
+
38
+ async function reply (res, command) {
39
+ let text
40
+ try {
41
+ text = await answer(command, settings)
42
+ } catch (error) {
43
+ robot.logger.error(`hubot-datacircle: ${error.stack ?? error}`)
44
+ text = `Datacircle's API failed: ${error.message}`
45
+ }
46
+ await res.send(text)
47
+ }
48
+
49
+ robot.respond(/datacircle(?:\s+([\s\S]*))?$/i, (res) => reply(res, res.match[1] ?? ''))
50
+
51
+ // Hubot 14 lists the commands of its command bus in its help: there each command is also datacircle.<verb>, like datacircle.best email-finder.
52
+ if (typeof robot.commands?.register === 'function') {
53
+ for (const [verb, [description, example]] of Object.entries(VERBS)) {
54
+ const id = `datacircle.${verb}`
55
+ robot.commands.register({
56
+ id,
57
+ description,
58
+ confirm: 'never',
59
+ examples: [`${robot.name} datacircle ${example}`, `${robot.name} ${id} ${example.split(' ').slice(1).join(' ')}`],
60
+ handler: async ({ context }) => {
61
+ // The bus reads only --key value and key:value: the words after the command's id are read from the message itself.
62
+ const text = String(context?.message?.text ?? '')
63
+ const at = text.toLowerCase().indexOf(id)
64
+ return answer(`${verb} ${at < 0 ? '' : text.slice(at + id.length)}`, settings)
65
+ }
66
+ }, { update: true })
67
+ }
68
+ }
69
+ }