Support installing dev packages, add reply support flag

This commit is contained in:
Evert Prants 2024-03-16 14:09:10 +02:00
parent bed3cba38b
commit c444a03884
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
5 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@squeebot/core", "name": "@squeebot/core",
"version": "3.6.2", "version": "3.6.3",
"description": "Squeebot v3 core for the execution environment", "description": "Squeebot v3 core for the execution environment",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@ -56,8 +56,9 @@ export class NPMExecutor {
/** /**
* Install a npm package (examples: `@squeebot/core`, `@squeebot/core@3.3.3`, `node-ical`) * Install a npm package (examples: `@squeebot/core`, `@squeebot/core@3.3.3`, `node-ical`)
* @param pkg Package name * @param pkg Package name
* @param development Install as devDependency
*/ */
public async installPackage(pkg: string): Promise<void> { public async installPackage(pkg: string, development = false): Promise<void> {
if (!(await fs.pathExists(this.packageFile))) { if (!(await fs.pathExists(this.packageFile))) {
await this.init(); await this.init();
} }
@ -92,7 +93,7 @@ export class NPMExecutor {
const { code, stderr, stdout } = await spawnProcess( const { code, stderr, stdout } = await spawnProcess(
'npm', 'npm',
['install', pkg], development ? ['install', '--save-dev', pkg] : ['install', pkg],
this.environment this.environment
); );
if (code > 0) { if (code > 0) {

View File

@ -98,4 +98,9 @@ export interface IMessage {
* @param target UserTarget to mention (i.e. `msg.sender`) * @param target UserTarget to mention (i.e. `msg.sender`)
*/ */
mention(target: IMessageTarget): string; mention(target: IMessageTarget): string;
/**
* Same as `resolve`, but replies (on supported protocols) instead.
* @param args Message data
*/
reply?(...args: any[]): void;
} }

View File

@ -76,6 +76,11 @@ export enum ProtocolFeatureFlag {
*/ */
MENTION, MENTION,
/**
* Protocol supports replying.
*/
REPLY,
/** /**
* Protocol connection manages multiple "servers" * Protocol connection manages multiple "servers"
*/ */

View File

@ -17,6 +17,7 @@ export class Service {
resolve: () => {}, resolve: () => {},
reject: () => {}, reject: () => {},
mention: () => '', mention: () => '',
reply: () => {},
data: pto, data: pto,
source: pto, source: pto,
text: `Protocol ${pto.fullName} running`, text: `Protocol ${pto.fullName} running`,