Socket
Socket
Sign inDemoInstall

recime-message-responder

Package Overview
Dependencies
251
Maintainers
1
Versions
193
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.2 to 1.4.3

2

dist/code-block.d.ts
export declare class CodeBlock {
private message;
constructor(message: any);
execute(data: any): Promise<{}>;
execute(sender: any): Promise<{}>;
processMessage(message: any): any;
transformCode(code: any): any;
}

@@ -15,3 +15,3 @@ "use strict";

}
execute(data) {
execute(sender) {
return new Promise((resolve, reject) => {

@@ -49,2 +49,5 @@ const r = [];

},
goto: (__, index) => {
return sender.execute(__);
},
__dirname: `${process.env.HOME_DIR}/${process.env.UID}`

@@ -56,2 +59,3 @@ };

const config = this.message.content.config;
const options = sender.options;
if (config) {

@@ -63,7 +67,7 @@ if (config.variable) {

const template = HandleBars.compile(str);
data.config = JSON.parse(template(data.vars.vals));
options.config = JSON.parse(template(options.vars.vals));
}
const message = this.processMessage(this.message);
const handler = vm.runInNewContext(message, sandbox);
handler(data, result => {
handler(options, result => {
if (Array.isArray(result)) {

@@ -70,0 +74,0 @@ r.push(...result);

import { Vars } from './vars';
export interface RequestOptions {
args: any;
res: any;
user: any;
vars: Vars;
break: Function;
execute: Function;
}
export declare class Request {
send(__: any, options: RequestOptions): any;
private options;
constructor(options: RequestOptions);
send(__: any, res: any): any;
break(): string;
execute(__: any, index: any, res: any): any;
}

@@ -5,7 +5,10 @@ "use strict";

class Request {
send(__, options) {
constructor(options) {
this.options = options;
}
send(__, res) {
let next = false;
if (options.res && options.res.length) {
let msgId = options.vars.get('system_message_id');
const response = options.res.map((message, index) => () => {
if (this.options.res && this.options.res.length) {
let msgId = this.options.vars.get('system_message_id');
const response = this.options.res.map((message, index) => () => {
if (msgId && !next) {

@@ -50,3 +53,3 @@ next = msgId === message.id;

const block = new code_block_1.CodeBlock(message);
return block.execute(options).catch(ex => {
return block.execute(this).catch(ex => {
return Promise.resolve(__.text(ex.message));

@@ -61,7 +64,7 @@ });

msgId = message.id;
options.vars.set(message.type, {
this.options.vars.set(message.type, {
index: index,
response: options.res
response: this.options.res
});
return Promise.resolve(options.break());
return Promise.resolve(this.break());
}

@@ -77,3 +80,3 @@ default: {

if (message && !userInput) {
if (message === options.break()) {
if (message === this.break()) {
userInput = true;

@@ -98,3 +101,9 @@ }

}
break() {
return "BREAK";
}
execute(__, index, res) {
return this.send(__, res.slice(index));
}
}
exports.Request = Request;

@@ -62,26 +62,11 @@ "use strict";

return __.profile(this.args).then(user => {
const req = new request_1.Request();
// make it available in plugins as well.
v.vals.nlp = res;
v.vals.args = this.args;
return req.send(__, {
res: res,
const req = new request_1.Request({
vars: v,
args: this.args,
user: user,
break: () => {
return "BREAK";
},
execute: (intentName) => {
return new Responder({
meta: this.args.meta,
sender: this.args.sender,
event: {
name: intentName
}
}).respond().then(result => {
return result;
});
}
}).then(result => {
user: user
});
return req.send(__, res).then(result => {
if (process.env.PLATFORM === 'telegram') {

@@ -88,0 +73,0 @@ if (Array.isArray(result)) {

{
"name": "recime-message-responder",
"version": "1.4.2",
"version": "1.4.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -20,3 +20,3 @@ import fs = require('fs');

execute(data){
execute(sender){
return new Promise((resolve, reject)=>{

@@ -57,2 +57,5 @@ const r = [];

},
goto: (__, index)=>{
return sender.execute(__);
},
__dirname: `${process.env.HOME_DIR}/${process.env.UID}`

@@ -66,2 +69,3 @@ };

const config = this.message.content.config;
const options = sender.options;

@@ -75,3 +79,3 @@ if (config){

data.config = JSON.parse(template(data.vars.vals));
options.config = JSON.parse(template(options.vars.vals));
}

@@ -81,3 +85,3 @@

const handler = vm.runInNewContext(message, sandbox);
handler(data, result => {
handler(options, result => {
if (Array.isArray(result)){

@@ -84,0 +88,0 @@ r.push(...result);

@@ -6,14 +6,17 @@ import { CodeBlock } from './code-block';

args: any;
res: any;
user: any;
vars: Vars;
break: Function;
execute: Function;
}
export class Request {
send(__:any, options: RequestOptions) {
private options: any;
constructor(options: RequestOptions){
this.options = options;
}
send(__:any, res) {
let next = false;
if (options.res && options.res.length) {
let msgId = options.vars.get('system_message_id');
const response = options.res.map((message, index) => () => {
if (this.options.res && this.options.res.length) {
let msgId = this.options.vars.get('system_message_id');
const response = this.options.res.map((message, index) => () => {
if (msgId && !next) {

@@ -61,3 +64,3 @@ next = msgId === message.id;

return block.execute(options).catch(ex => {
return block.execute(this).catch(ex => {
return Promise.resolve(__.text(ex.message));

@@ -71,7 +74,7 @@ });

msgId = message.id;
options.vars.set(message.type,{
this.options.vars.set(message.type,{
index: index,
response: options.res
response: this.options.res
});
return Promise.resolve(options.break());
return Promise.resolve(this.break());
}

@@ -87,3 +90,3 @@ default: {

if (message && !userInput) {
if (message === options.break()) {
if (message === this.break()) {
userInput = true;

@@ -106,2 +109,8 @@ } else {

break() {
return "BREAK"
}
execute (__, index, res) {
return this.send(__, res.slice(index));
}
}

@@ -77,4 +77,2 @@ import HandleBars from 'handlebars';

return __.profile(this.args).then(user => {
const req = new Request();
// make it available in plugins as well.

@@ -84,24 +82,10 @@ v.vals.nlp = res;

return req.send(
__
, {
res: res
, vars: v
, args: this.args
, user: user
, break : ()=>{
return "BREAK";
}
, execute : (intentName)=>{
return new Responder({
meta: this.args.meta
, sender: this.args.sender
, event: {
name: intentName
}
}).respond().then(result => {
return result;
});
}
}).then(result => {
const req = new Request({
vars: v,
args: this.args,
user: user
});
return req.send(__, res).then(result => {
if (process.env.PLATFORM === 'telegram') {

@@ -108,0 +92,0 @@ if (Array.isArray(result)) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc