diff --git a/README.md b/README.md index 527ff8f..09ef8fe 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ plugins: with: # Define configurable items here and the kernel will pass these to the plugin. configurableResponse: "Hello, is it me you are looking for?" + customStringsUrl: "https://raw.githubusercontent.com/ubiquibot/plugin-template/development/strings.json" ``` ###### At this stage, your plugin will fire on your defined events with the required settings passed in from the kernel. You can now start writing your plugin's logic. diff --git a/src/handlers/hello-world.ts b/src/handlers/hello-world.ts index 4c58ae1..f1f9d35 100644 --- a/src/handlers/hello-world.ts +++ b/src/handlers/hello-world.ts @@ -15,7 +15,7 @@ export async function helloWorld(context: Context) { logger, payload, octokit, - config: { configurableResponse }, + config: { configurableResponse, customStringsUrl }, } = context; const sender = payload.comment.user?.login; @@ -39,6 +39,15 @@ export async function helloWorld(context: Context) { issue_number: payload.issue.number, body: configurableResponse, }); + if (customStringsUrl) { + const response = await fetch(customStringsUrl).then((value) => value.json()); + await octokit.issues.createComment({ + owner: payload.repository.owner.login, + repo: payload.repository.name, + issue_number: payload.issue.number, + body: response.greeting, + }); + } } catch (error) { /** * logger.fatal should not be used in 9/10 cases. Use logger.error instead. diff --git a/src/types/plugin-inputs.ts b/src/types/plugin-inputs.ts index 1c8a30a..0a530f9 100644 --- a/src/types/plugin-inputs.ts +++ b/src/types/plugin-inputs.ts @@ -21,6 +21,7 @@ export interface PluginInputs