Merge branch 'main' of https://github.com/GeneralBots/BotServer
This commit is contained in:
commit
4823f02bbc
20 changed files with 148 additions and 99 deletions
|
@ -1,3 +1,8 @@
|
|||
<a href="https://github.com/generalbots/botserver/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=generalbots/botserver" />
|
||||
</a>
|
||||
|
||||
|
||||
| Area | Status |
|
||||
|------------------------------|----------------------------------------------------------------------------------------------------|
|
||||
| Releases | [](https://www.npmjs.com/package/botserver/) [](https://www.npmjs.com/package/botlib/) [](https://github.com/semantic-release/semantic-release)|
|
||||
|
@ -111,6 +116,6 @@ trademark license. Therefore any rights, title and interest in
|
|||
our trademarks remain entirely with us.
|
||||
|
||||
<a href="https://stackoverflow.com/questions/ask?tags=generalbots">:speech_balloon: Ask a question</a> <a href="https://github.com/GeneralBots/BotBook">:book: Read the Docs</a>
|
||||
|
||||
Team pictures made with [contrib.rocks](https://contrib.rocks).
|
||||
General Bots Code Name is [Guaribas](https://en.wikipedia.org/wiki/Guaribas), the name of a city in Brazil, state of Piaui.
|
||||
[Roberto Mangabeira Unger](http://www.robertounger.com/en/): "No one should have to do work that can be done by a machine".
|
||||
|
|
|
@ -60,7 +60,7 @@ import QrScanner from 'qr-scanner';
|
|||
import pkg from 'whatsapp-web.js';
|
||||
import { ActivityTypes } from 'botbuilder';
|
||||
const { List, Buttons } = pkg;
|
||||
import mime from 'mime';
|
||||
import mime from 'mime-types';
|
||||
|
||||
/**
|
||||
* Default check interval for user replay
|
||||
|
|
|
@ -45,26 +45,26 @@ import { Sequelize } from 'sequelize-typescript';
|
|||
export class GBHubSpotPackage implements IGBPackage {
|
||||
public sysPackages: IGBPackage[];
|
||||
|
||||
public async loadBot (min: GBMinInstance): Promise<void> {
|
||||
public async loadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`loadBot called.`);
|
||||
}
|
||||
|
||||
public async getDialogs (min: GBMinInstance) {
|
||||
public async getDialogs(min: GBMinInstance) {
|
||||
GBLog.verbose(`getDialogs called.`);
|
||||
}
|
||||
public async loadPackage (core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
public async loadPackage(core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
GBLog.verbose(`loadPackage called.`);
|
||||
}
|
||||
public async unloadPackage (core: IGBCoreService): Promise<void> {
|
||||
public async unloadPackage(core: IGBCoreService): Promise<void> {
|
||||
GBLog.verbose(`unloadPackage called.`);
|
||||
}
|
||||
public async unloadBot (min: GBMinInstance): Promise<void> {
|
||||
public async unloadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`unloadBot called.`);
|
||||
}
|
||||
public async onNewSession (min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
public async onNewSession(min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
GBLog.verbose(`onNewSession called.`);
|
||||
}
|
||||
public async onExchangeData (min: GBMinInstance, kind: string, data: any) {
|
||||
public async onExchangeData(min: GBMinInstance, kind: string, data: any) {
|
||||
GBLog.verbose(`onExchangeData called.`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,4 @@ import * as hubspot from '@hubspot/api-client';
|
|||
/**
|
||||
* Support for Hub Spot XRM.
|
||||
*/
|
||||
export class HubSpotServices extends GBService {}
|
||||
export class HubSpotServices extends GBService { }
|
||||
|
|
|
@ -106,11 +106,11 @@ export class AskDialog extends IGBDialog {
|
|||
|
||||
if (step.options && step.options.firstTime) {
|
||||
text = Messages[locale].ask_first_time;
|
||||
}
|
||||
else if (step.options && step.options.isReturning && !step.context.activity.group) {
|
||||
text = Messages[locale].anything_else;
|
||||
}
|
||||
else if (step.context.activity.group || (step.options && step.options.emptyPrompt)) {
|
||||
}
|
||||
else if (step.options && step.options.isReturning && !step.context.activity.group) {
|
||||
text = Messages[locale].anything_else;
|
||||
}
|
||||
else if (step.context.activity.group || (step.options && step.options.emptyPrompt)) {
|
||||
text = '';
|
||||
} else if (user.subjects.length > 0) {
|
||||
text = Messages[locale].which_question;
|
||||
|
@ -391,14 +391,14 @@ export class AskDialog extends IGBDialog {
|
|||
async step => {
|
||||
if (GBServer.globals.chatGPT) {
|
||||
let input = `Write a BASIC program that ${step.options.dialog.toLowerCase()}. And does not explain.`;
|
||||
|
||||
|
||||
await min.conversationalService.sendText(min, step, 'Thank you. The dialog is being written right now...');
|
||||
|
||||
const CHATGPT_TIMEOUT = 3 * 60 * 1000;
|
||||
GBLog.info(`ChatGPT Code: ${input}`);
|
||||
let response = await GBServer.globals.chatGPT.sendMessage(input, {
|
||||
timeoutMs: CHATGPT_TIMEOUT
|
||||
});
|
||||
});
|
||||
|
||||
// Removes instructions, just code.
|
||||
|
||||
|
@ -409,17 +409,17 @@ export class AskDialog extends IGBDialog {
|
|||
|
||||
// Gets dialog name and file handling
|
||||
|
||||
let dialogName = step.result.replace('.', '');
|
||||
let dialogName = step.result.replace('.', '');
|
||||
const docx = urlJoin(`${min.botId}.gbdialog`, `${dialogName}.docx`);
|
||||
const sys = new SystemKeywords();
|
||||
const document = await sys.internalCreateDocument(min, docx, response);
|
||||
await service.addQA(min, dialogName, dialogName);
|
||||
await service.addQA(min, dialogName, dialogName);
|
||||
|
||||
let message = `Waiting for publishing...`;
|
||||
await min.conversationalService.sendText(min, step, message);
|
||||
|
||||
await step.replaceDialog('/publish', { confirm: true });
|
||||
|
||||
|
||||
message = `Dialog is ready! Let's run:`;
|
||||
await min.conversationalService.sendText(min, step, message);
|
||||
|
||||
|
@ -439,7 +439,7 @@ export class AskDialog extends IGBDialog {
|
|||
await step.endDialog();
|
||||
|
||||
await GBVMService.callVM(dialogName.toLowerCase(),
|
||||
min, step, user, this.deployer, false);
|
||||
min, step, user, this.deployer, false);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
@ -53,7 +53,7 @@ export class FaqDialog extends IGBDialog {
|
|||
* @param bot The bot adapter.
|
||||
* @param min The minimal bot instance data.
|
||||
*/
|
||||
public static setup (bot: BotAdapter, min: GBMinInstance) {
|
||||
public static setup(bot: BotAdapter, min: GBMinInstance) {
|
||||
const service = new KBService(min.core.sequelize);
|
||||
|
||||
min.dialogs.add(
|
||||
|
|
|
@ -64,13 +64,13 @@ export class MenuDialog extends IGBDialog {
|
|||
* @param bot The bot adapter.
|
||||
* @param min The minimal bot instance data.
|
||||
*/
|
||||
public static setup (bot: BotAdapter, min: GBMinInstance) {
|
||||
public static setup(bot: BotAdapter, min: GBMinInstance) {
|
||||
const service = new KBService(min.core.sequelize);
|
||||
|
||||
min.dialogs.add(new WaterfallDialog('/menu', MenuDialog.getMenuDialog(min, service)));
|
||||
}
|
||||
|
||||
private static getMenuDialog (min: GBMinInstance, service: KBService) {
|
||||
private static getMenuDialog(min: GBMinInstance, service: KBService) {
|
||||
return [
|
||||
async step => {
|
||||
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
|
||||
|
|
|
@ -48,26 +48,26 @@ import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from './models/inde
|
|||
*/
|
||||
export class GBKBPackage implements IGBPackage {
|
||||
public sysPackages: IGBPackage[];
|
||||
public async getDialogs (min: GBMinInstance) {
|
||||
public async getDialogs(min: GBMinInstance) {
|
||||
GBLog.verbose(`getDialogs called.`);
|
||||
}
|
||||
public async unloadPackage (core: IGBCoreService): Promise<void> {
|
||||
public async unloadPackage(core: IGBCoreService): Promise<void> {
|
||||
GBLog.verbose(`unloadPackage called.`);
|
||||
}
|
||||
public async unloadBot (min: GBMinInstance): Promise<void> {
|
||||
public async unloadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`unloadBot called.`);
|
||||
}
|
||||
public async onNewSession (min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
public async onNewSession(min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
GBLog.verbose(`onNewSession called.`);
|
||||
}
|
||||
public async onExchangeData (min: GBMinInstance, kind: string, data: any) {
|
||||
public async onExchangeData(min: GBMinInstance, kind: string, data: any) {
|
||||
GBLog.verbose(`onExchangeData called.`);
|
||||
}
|
||||
|
||||
public async loadPackage (core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
public async loadPackage(core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
core.sequelize.addModels([GuaribasAnswer, GuaribasQuestion, GuaribasSubject]);
|
||||
}
|
||||
public async loadBot (min: GBMinInstance): Promise<void> {
|
||||
public async loadBot(min: GBMinInstance): Promise<void> {
|
||||
AskDialog.setup(min.bot, min);
|
||||
FaqDialog.setup(min.bot, min);
|
||||
MenuDialog.setup(min.bot, min);
|
||||
|
|
|
@ -646,10 +646,10 @@ export class KBService implements IGBKBService {
|
|||
packageId: pkg.packageId,
|
||||
prevId: 0
|
||||
};
|
||||
const a =await GuaribasAnswer.create(answer);
|
||||
const a = await GuaribasAnswer.create(answer);
|
||||
question['answerId'] = a.answerId;
|
||||
const q = await GuaribasQuestion.create(question);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async importKbPackage(
|
||||
|
|
|
@ -44,7 +44,7 @@ import { Messages } from '../strings.js';
|
|||
* Dialogs for handling Menu control.
|
||||
*/
|
||||
export class OAuthDialog extends IGBDialog {
|
||||
public static getOAuthDialog (min: GBMinInstance) {
|
||||
public static getOAuthDialog(min: GBMinInstance) {
|
||||
return {
|
||||
id: '/auth',
|
||||
waterfall: [
|
||||
|
|
|
@ -39,13 +39,13 @@
|
|||
import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
import * as phone from 'google-libphonenumber';
|
||||
import * as phone from 'google-libphonenumber';
|
||||
|
||||
/**
|
||||
* Dialogs for handling Menu control.
|
||||
*/
|
||||
export class ProfileDialog extends IGBDialog {
|
||||
public static getNameDialog (min: GBMinInstance) {
|
||||
public static getNameDialog(min: GBMinInstance) {
|
||||
return {
|
||||
id: '/profile_name',
|
||||
waterfall: [
|
||||
|
@ -83,7 +83,7 @@ export class ProfileDialog extends IGBDialog {
|
|||
};
|
||||
}
|
||||
|
||||
public static getMobileDialog (min: GBMinInstance) {
|
||||
public static getMobileDialog(min: GBMinInstance) {
|
||||
return {
|
||||
id: '/profile_mobile',
|
||||
waterfall: [
|
||||
|
@ -126,7 +126,7 @@ export class ProfileDialog extends IGBDialog {
|
|||
};
|
||||
}
|
||||
|
||||
public static getMobileConfirmDialog (min: GBMinInstance) {
|
||||
public static getMobileConfirmDialog(min: GBMinInstance) {
|
||||
return {
|
||||
id: '/profile_mobile_confirm',
|
||||
waterfall: [
|
||||
|
@ -167,7 +167,7 @@ export class ProfileDialog extends IGBDialog {
|
|||
};
|
||||
}
|
||||
|
||||
public static getEmailDialog (min: GBMinInstance) {
|
||||
public static getEmailDialog(min: GBMinInstance) {
|
||||
return {
|
||||
id: '/profile_email',
|
||||
waterfall: [
|
||||
|
|
|
@ -47,7 +47,7 @@ import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from './models/index.j
|
|||
*/
|
||||
export class GBSecurityPackage implements IGBPackage {
|
||||
public sysPackages: IGBPackage[];
|
||||
public async getDialogs (min: GBMinInstance) {
|
||||
public async getDialogs(min: GBMinInstance) {
|
||||
const out = [
|
||||
ProfileDialog.getNameDialog(min),
|
||||
ProfileDialog.getEmailDialog(min),
|
||||
|
@ -60,23 +60,23 @@ export class GBSecurityPackage implements IGBPackage {
|
|||
}
|
||||
return out;
|
||||
}
|
||||
public async unloadPackage (core: IGBCoreService): Promise<void> {
|
||||
public async unloadPackage(core: IGBCoreService): Promise<void> {
|
||||
GBLog.verbose(`unloadPackage called.`);
|
||||
}
|
||||
public async loadBot (min: GBMinInstance): Promise<void> {
|
||||
public async loadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`loadBot called.`);
|
||||
}
|
||||
public async unloadBot (min: GBMinInstance): Promise<void> {
|
||||
public async unloadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`unloadBot called.`);
|
||||
}
|
||||
public async onNewSession (min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
public async onNewSession(min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
GBLog.verbose(`onNewSession called.`);
|
||||
}
|
||||
public async onExchangeData (min: GBMinInstance, kind: string, data: any) {
|
||||
public async onExchangeData(min: GBMinInstance, kind: string, data: any) {
|
||||
GBLog.verbose(`onExchangeData called.`);
|
||||
}
|
||||
|
||||
public async loadPackage (core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
public async loadPackage(core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
core.sequelize.addModels([GuaribasGroup, GuaribasUser, GuaribasUserGroup]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export class GuaribasUser extends Model<GuaribasUser> {
|
|||
|
||||
@Column(DataType.STRING(255))
|
||||
declare userSystemId: string;
|
||||
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
declare userName: string;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { FindOptions } from 'sequelize';
|
|||
* Security service layer.
|
||||
*/
|
||||
export class SecService extends GBService {
|
||||
public async ensureUser (
|
||||
public async ensureUser(
|
||||
instanceId: number,
|
||||
userSystemId: string,
|
||||
userName: string,
|
||||
|
@ -41,7 +41,7 @@ export class SecService extends GBService {
|
|||
/**
|
||||
* Retrives a conversation reference from contact phone.
|
||||
*/
|
||||
public async getConversationReference (phone: string): Promise<ConversationReference> {
|
||||
public async getConversationReference(phone: string): Promise<ConversationReference> {
|
||||
const options = <FindOptions>{ rejectOnEmpty: true, where: { phone: phone } };
|
||||
const user = await GuaribasUser.findOne(options);
|
||||
|
||||
|
@ -51,7 +51,7 @@ export class SecService extends GBService {
|
|||
/**
|
||||
* Updates a conversation reference from contact phone.
|
||||
*/
|
||||
public async updateConversationReference (phone: string, conversationReference: string) {
|
||||
public async updateConversationReference(phone: string, conversationReference: string) {
|
||||
const options = <FindOptions>{ where: { phone: phone } };
|
||||
const user = await GuaribasUser.findOne(options);
|
||||
|
||||
|
@ -59,7 +59,7 @@ export class SecService extends GBService {
|
|||
await user.save();
|
||||
}
|
||||
|
||||
public async updateConversationReferenceById (userId: number, conversationReference: string) {
|
||||
public async updateConversationReferenceById(userId: number, conversationReference: string) {
|
||||
const options = <FindOptions>{ where: { userId: userId } };
|
||||
const user = await GuaribasUser.findOne(options);
|
||||
|
||||
|
@ -67,7 +67,7 @@ export class SecService extends GBService {
|
|||
await user.save();
|
||||
}
|
||||
|
||||
public async updateUserLocale (userId: number, locale: any): Promise<GuaribasUser> {
|
||||
public async updateUserLocale(userId: number, locale: any): Promise<GuaribasUser> {
|
||||
const user = await GuaribasUser.findOne({
|
||||
where: {
|
||||
userId: userId
|
||||
|
@ -78,7 +78,7 @@ export class SecService extends GBService {
|
|||
return await user.save();
|
||||
}
|
||||
|
||||
public async updateUserHearOnDialog (userId: number, dialogName: string): Promise<GuaribasUser> {
|
||||
public async updateUserHearOnDialog(userId: number, dialogName: string): Promise<GuaribasUser> {
|
||||
const user = await GuaribasUser.findOne({
|
||||
where: {
|
||||
userId: userId
|
||||
|
@ -89,7 +89,7 @@ export class SecService extends GBService {
|
|||
return await user.save();
|
||||
}
|
||||
|
||||
public async updateUserInstance (userSystemId: string, instanceId: number): Promise<GuaribasUser> {
|
||||
public async updateUserInstance(userSystemId: string, instanceId: number): Promise<GuaribasUser> {
|
||||
const user = await GuaribasUser.findOne({
|
||||
where: {
|
||||
userSystemId: userSystemId
|
||||
|
@ -103,7 +103,7 @@ export class SecService extends GBService {
|
|||
/**
|
||||
* Finds and update user agent information to a next available person.
|
||||
*/
|
||||
public async updateHumanAgent (
|
||||
public async updateHumanAgent(
|
||||
userSystemId: string,
|
||||
instanceId: number,
|
||||
agentSystemId: string
|
||||
|
@ -150,7 +150,7 @@ export class SecService extends GBService {
|
|||
return user;
|
||||
}
|
||||
|
||||
public async isAgentSystemId (systemId: string): Promise<Boolean> {
|
||||
public async isAgentSystemId(systemId: string): Promise<Boolean> {
|
||||
const user = await GuaribasUser.findOne({
|
||||
where: {
|
||||
userSystemId: systemId
|
||||
|
@ -164,7 +164,7 @@ export class SecService extends GBService {
|
|||
return user.agentMode === 'self';
|
||||
}
|
||||
|
||||
public async assignHumanAgent (
|
||||
public async assignHumanAgent(
|
||||
min: GBMinInstance,
|
||||
userSystemId: string,
|
||||
agentSystemId: string = null
|
||||
|
@ -194,7 +194,7 @@ export class SecService extends GBService {
|
|||
return agentSystemId;
|
||||
}
|
||||
|
||||
public async getUserFromId (instanceId: number, userId: string): Promise<GuaribasUser> {
|
||||
public async getUserFromId(instanceId: number, userId: string): Promise<GuaribasUser> {
|
||||
return await GuaribasUser.findOne({
|
||||
where: {
|
||||
instanceId: instanceId,
|
||||
|
@ -203,7 +203,7 @@ export class SecService extends GBService {
|
|||
});
|
||||
}
|
||||
|
||||
public async getUserFromSystemId (systemId: string): Promise<GuaribasUser> {
|
||||
public async getUserFromSystemId(systemId: string): Promise<GuaribasUser> {
|
||||
return await GuaribasUser.findOne({
|
||||
where: {
|
||||
userSystemId: systemId
|
||||
|
@ -211,7 +211,7 @@ export class SecService extends GBService {
|
|||
});
|
||||
}
|
||||
|
||||
public async getUserFromAgentSystemId (systemId: string): Promise<GuaribasUser> {
|
||||
public async getUserFromAgentSystemId(systemId: string): Promise<GuaribasUser> {
|
||||
return await GuaribasUser.findOne({
|
||||
where: {
|
||||
agentSystemId: systemId
|
||||
|
@ -219,7 +219,7 @@ export class SecService extends GBService {
|
|||
});
|
||||
}
|
||||
|
||||
public async getAllUsers (instanceId: number): Promise<GuaribasUser[]> {
|
||||
public async getAllUsers(instanceId: number): Promise<GuaribasUser[]> {
|
||||
return await GuaribasUser.findAll({
|
||||
where: {
|
||||
instanceId: instanceId
|
||||
|
@ -235,7 +235,7 @@ export class SecService extends GBService {
|
|||
* @param name Name of param to get from instance.
|
||||
* @param defaultValue Value returned when no param is defined.
|
||||
*/
|
||||
public getParam<T> (user: GuaribasUser, name: string, defaultValue?: T): any {
|
||||
public getParam<T>(user: GuaribasUser, name: string, defaultValue?: T): any {
|
||||
let value = null;
|
||||
if (user.params) {
|
||||
const params = JSON.parse(user.params);
|
||||
|
@ -254,8 +254,7 @@ export class SecService extends GBService {
|
|||
if (user['dataValues'] && !value) {
|
||||
value = user['dataValues'][name];
|
||||
if (value === null) {
|
||||
switch(name)
|
||||
{
|
||||
switch (name) {
|
||||
case 'language':
|
||||
value = 'en';
|
||||
break;
|
||||
|
@ -269,14 +268,13 @@ export class SecService extends GBService {
|
|||
* Saves user instance object to the storage handling
|
||||
* multi-column JSON based store 'params' field.
|
||||
*/
|
||||
public async setParam (userId: number, name: string, value:any) {
|
||||
public async setParam(userId: number, name: string, value: any) {
|
||||
const options = { where: {} };
|
||||
options.where = { userId: userId };
|
||||
let user = await GuaribasUser.findOne(options);
|
||||
// tslint:disable-next-line:prefer-object-spread
|
||||
let obj = JSON.parse(user.params);
|
||||
if (!obj)
|
||||
{
|
||||
let obj = JSON.parse(user.params);
|
||||
if (!obj) {
|
||||
obj = {};
|
||||
}
|
||||
obj[name] = value;
|
||||
|
|
|
@ -44,25 +44,25 @@ import { Sequelize } from 'sequelize-typescript';
|
|||
*/
|
||||
export class GBSharePointPackage implements IGBPackage {
|
||||
public sysPackages: IGBPackage[];
|
||||
public async getDialogs (min: GBMinInstance) {
|
||||
public async getDialogs(min: GBMinInstance) {
|
||||
GBLog.verbose(`getDialogs called.`);
|
||||
}
|
||||
public async loadPackage (core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
public async loadPackage(core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
GBLog.verbose(`loadPackage called.`);
|
||||
}
|
||||
public async unloadPackage (core: IGBCoreService): Promise<void> {
|
||||
public async unloadPackage(core: IGBCoreService): Promise<void> {
|
||||
GBLog.verbose(`unloadPackage called.`);
|
||||
}
|
||||
public async loadBot (min: GBMinInstance): Promise<void> {
|
||||
public async loadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`loadBot called.`);
|
||||
}
|
||||
public async unloadBot (min: GBMinInstance): Promise<void> {
|
||||
public async unloadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`unloadBot called.`);
|
||||
}
|
||||
public async onNewSession (min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
public async onNewSession(min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
GBLog.verbose(`onNewSession called.`);
|
||||
}
|
||||
public async onExchangeData (min: GBMinInstance, kind: string, data: any) {
|
||||
public async onExchangeData(min: GBMinInstance, kind: string, data: any) {
|
||||
GBLog.verbose(`onExchangeData called.`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,4 +39,4 @@
|
|||
/**
|
||||
* Service facade for SharePoint Online.
|
||||
*/
|
||||
export class GBSharePointService {}
|
||||
export class GBSharePointService { }
|
||||
|
|
|
@ -38,7 +38,7 @@ import AdmZip from 'adm-zip';
|
|||
* Support for Whatsapp.
|
||||
*/
|
||||
export class TeamsService extends GBService {
|
||||
public async getAppFile (manifest) {
|
||||
public async getAppFile(manifest) {
|
||||
var zip = new AdmZip();
|
||||
zip.addFile('manifest.json', Buffer.from(manifest, 'utf8'), 'Built with General Bots™.');
|
||||
zip.addLocalFile('teams-color.png', null, 'color.png');
|
||||
|
@ -46,7 +46,7 @@ export class TeamsService extends GBService {
|
|||
return zip.toBuffer();
|
||||
}
|
||||
|
||||
public async getManifest (marketplaceId, botName, botDescription, id, packageName, yourName) {
|
||||
public async getManifest(marketplaceId, botName, botDescription, id, packageName, yourName) {
|
||||
let content = Fs.readFileSync('teams-manifest.json', 'utf8');
|
||||
|
||||
content = content.replace(/\@\@marketplaceId/gi, marketplaceId);
|
||||
|
|
|
@ -46,26 +46,26 @@ import { WhatsappDirectLine } from './services/WhatsappDirectLine.js';
|
|||
export class GBWhatsappPackage implements IGBPackage {
|
||||
public sysPackages: IGBPackage[];
|
||||
|
||||
public async loadBot (min: GBMinInstance): Promise<void> {
|
||||
public async loadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`loadBot called.`);
|
||||
}
|
||||
|
||||
public async getDialogs (min: GBMinInstance) {
|
||||
public async getDialogs(min: GBMinInstance) {
|
||||
GBLog.verbose(`getDialogs called.`);
|
||||
}
|
||||
public async loadPackage (core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
public async loadPackage(core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
GBLog.verbose(`loadPackage called.`);
|
||||
}
|
||||
public async unloadPackage (core: IGBCoreService): Promise<void> {
|
||||
public async unloadPackage(core: IGBCoreService): Promise<void> {
|
||||
GBLog.verbose(`unloadPackage called.`);
|
||||
}
|
||||
public async unloadBot (min: GBMinInstance): Promise<void> {
|
||||
public async unloadBot(min: GBMinInstance): Promise<void> {
|
||||
GBLog.verbose(`unloadBot called.`);
|
||||
}
|
||||
public async onNewSession (min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
public async onNewSession(min: GBMinInstance, step: GBDialogStep): Promise<void> {
|
||||
GBLog.verbose(`onNewSession called.`);
|
||||
}
|
||||
public async onExchangeData (min: GBMinInstance, kind: string, data: any) {
|
||||
public async onExchangeData(min: GBMinInstance, kind: string, data: any) {
|
||||
GBLog.verbose(`onExchangeData called.`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,11 +192,10 @@ export class WhatsappDirectLine extends GBService {
|
|||
});
|
||||
client.initialize();
|
||||
};
|
||||
if (setUrl){
|
||||
if (setUrl) {
|
||||
createClient.bind(this)();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
this.customClient = minBoot.whatsAppDirectLine.customClient;
|
||||
}
|
||||
setUrl = false;
|
||||
|
@ -998,14 +997,14 @@ export class WhatsappDirectLine extends GBService {
|
|||
let urlMin: any = GBServer.globals.minInstances.filter(p => p.instance.botId === botId)[0];
|
||||
|
||||
const botNumber = urlMin ? urlMin.core.getParam(urlMin.instance, 'Bot Number', null) : null;
|
||||
if (botNumber){
|
||||
if (botNumber) {
|
||||
user = await sec.updateUserInstance(user.userSystemId, urlMin.instance.instanceId);
|
||||
}
|
||||
let activeMin;
|
||||
|
||||
// Processes group behaviour.
|
||||
|
||||
text = text.replace(/\@\d+ /gi, '');
|
||||
text = text.replace(/\@\d+ /gi, '');
|
||||
|
||||
let group;
|
||||
if (provider === 'chatapi') {
|
||||
|
|
65
src/app.ts
65
src/app.ts
|
@ -84,7 +84,7 @@ export class GBServer {
|
|||
GBLog.error(`Running TEST_SHELL ERROR: ${error}...`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const server = express();
|
||||
|
||||
GBServer.globals.server = server;
|
||||
|
@ -227,7 +227,7 @@ export class GBServer {
|
|||
await GBServer.globals.chatGPT.init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// let s = new GBVMService();
|
||||
// await s.translateBASIC('work/gptA.vbs', GBServer.globals.minBoot );
|
||||
// await s.translateBASIC('work/gptB.vbs', GBServer.globals.minBoot );
|
||||
|
@ -282,15 +282,62 @@ export class GBServer {
|
|||
};
|
||||
const httpsServer = https.createServer(options1, server).listen(port, mainCallback);
|
||||
GBServer.globals.httpsServer = httpsServer;
|
||||
if (process.env.CERTIFICATE2_PFX) {
|
||||
const options2 = {
|
||||
passphrase: process.env.CERTIFICATE2_PASSPHRASE,
|
||||
pfx: Fs.readFileSync(process.env.CERTIFICATE2_PFX)
|
||||
};
|
||||
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options2);
|
||||
|
||||
for (let i = 2; ; i++) {
|
||||
const certPfxEnv = `CERTIFICATE${i}_PFX`;
|
||||
const certPassphraseEnv = `CERTIFICATE${i}_PASSPHRASE`;
|
||||
const certDomainEnv = `CERTIFICATE${i}_DOMAIN`;
|
||||
|
||||
if (process.env[certPfxEnv] && process.env[certPassphraseEnv] && process.env[certDomainEnv]) {
|
||||
const options = {
|
||||
passphrase: process.env[certPassphraseEnv],
|
||||
pfx: Fs.readFileSync(process.env[certPfxEnv])
|
||||
};
|
||||
httpsServer.addContext(process.env[certDomainEnv], options);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
server.listen(port, mainCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
--------------------------------------------------------------------------------------------
|
||||
if (process.env.CERTIFICATE_PFX) {
|
||||
const options1 = {
|
||||
passphrase: process.env.CERTIFICATE_PASSPHRASE,
|
||||
pfx: Fs.readFileSync(process.env.CERTIFICATE_PFX)
|
||||
};
|
||||
const httpsServer = https.createServer(options1, server).listen(port, mainCallback);
|
||||
GBServer.globals.httpsServer = httpsServer;
|
||||
|
||||
if (process.env.CERTIFICATE2_PFX) {
|
||||
const options2 = {
|
||||
passphrase: process.env.CERTIFICATE2_PASSPHRASE,
|
||||
pfx: Fs.readFileSync(process.env.CERTIFICATE2_PFX)
|
||||
};
|
||||
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options2);
|
||||
}
|
||||
|
||||
if (process.env.CERTIFICATE3_PFX) {
|
||||
const options3 = {
|
||||
passphrase: process.env.CERTIFICATE3_PASSPHRASE,
|
||||
pfx: Fs.readFileSync(process.env.CERTIFICATE3_PFX)
|
||||
};
|
||||
httpsServer.addContext(process.env.CERTIFICATE3_DOMAIN, options3);
|
||||
}
|
||||
|
||||
if (process.env.CERTIFICATE4_PFX) {
|
||||
const options4 = {
|
||||
passphrase: process.env.CERTIFICATE4_PASSPHRASE,
|
||||
pfx: Fs.readFileSync(process.env.CERTIFICATE4_PFX)
|
||||
};
|
||||
httpsServer.addContext(process.env.CERTIFICATE4_DOMAIN, options4);
|
||||
}
|
||||
}
|
||||
------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue