Merge pull request #2097 from Luis-Fernando-Molina/develop
Contribution: Social-Bots project extracted from Fundations
This commit is contained in:
58 files changed
+807
-122
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ exports.newAlgorithmicTradingBotModulesTradingOrders = function (processIndex) {
|
||||
let sessionParameters
|
||||
|
||||
let exchangeAPIModuleObject = TS.projects.algorithmicTrading.botModules.exchangeAPI.newAlgorithmicTradingBotModulesExchangeAPI(processIndex)
|
||||
let announcementsModuleObject = TS.projects.foundations.botModules.announcements.newFoundationsBotModulesAnnouncements(processIndex)
|
||||
let announcementsModuleObject = TS.projects.socialBots.botModules.announcements.newSocialBotsBotModulesAnnouncements(processIndex)
|
||||
|
||||
return thisObject
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
let tradingStrategyModuleObject = TS.projects.algorithmicTrading.botModules.tradingStrategy.newAlgorithmicTradingBotModulesTradingStrategy(processIndex)
|
||||
let tradingPositionModuleObject = TS.projects.algorithmicTrading.botModules.tradingPosition.newAlgorithmicTradingBotModulesTradingPosition(processIndex)
|
||||
let tradingExecutionModuleObject = TS.projects.algorithmicTrading.botModules.tradingExecution.newAlgorithmicTradingBotModulesTradingExecution(processIndex)
|
||||
let announcementsModuleObject = TS.projects.foundations.botModules.announcements.newFoundationsBotModulesAnnouncements(processIndex)
|
||||
let announcementsModuleObject = TS.projects.socialBots.botModules.announcements.newSocialBotsBotModulesAnnouncements(processIndex)
|
||||
let snapshotsModuleObject = TS.projects.algorithmicTrading.botModules.snapshots.newAlgorithmicTradingBotModulesSnapshots(processIndex)
|
||||
let tradingEpisodeModuleObject = TS.projects.algorithmicTrading.botModules.tradingEpisode.newAlgorithmicTradingBotModulesTradingEpisode(processIndex)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SOCIAL_BOTS_MODULE =
|
||||
TS.projects.foundations.botModules.socialBots.newFoundationsBotModulesSocialBots(processIndex)
|
||||
TS.projects.socialBots.botModules.socialBots.newSocialBotsBotModulesSocialBots(processIndex)
|
||||
|
||||
return thisObject;
|
||||
|
||||
|
||||
@@ -43,6 +43,13 @@
|
||||
"dontShowAtFullscreen": true,
|
||||
"actionFunction": "uiObject.configEditor.activate"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bots",
|
||||
"relatedUiObject": "Social Bots",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Children",
|
||||
"label": "Add Missing Children",
|
||||
@@ -96,7 +103,8 @@
|
||||
{
|
||||
"name": "socialBots",
|
||||
"type": "node",
|
||||
"childType": "Social Bots"
|
||||
"childType": "Social Bots",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "session"
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bots",
|
||||
"relatedUiObject": "Social Bots",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Children",
|
||||
@@ -105,7 +106,8 @@
|
||||
{
|
||||
"name": "socialBots",
|
||||
"type": "node",
|
||||
"childType": "Social Bots"
|
||||
"childType": "Social Bots",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "session"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -38,7 +39,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "cancelOrderEvent"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -38,7 +39,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "closeStageEvent"
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -63,7 +64,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "userDefinedCode",
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -38,7 +39,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "createOrderEvent"
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bots",
|
||||
"relatedUiObject": "Social Bots",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Children",
|
||||
@@ -108,7 +109,8 @@
|
||||
{
|
||||
"name": "socialBots",
|
||||
"type": "node",
|
||||
"childType": "Social Bots"
|
||||
"childType": "Social Bots",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "session"
|
||||
|
||||
@@ -43,6 +43,13 @@
|
||||
"dontShowAtFullscreen": true,
|
||||
"actionFunction": "uiObject.configEditor.activate"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bots",
|
||||
"relatedUiObject": "Social Bots",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Children",
|
||||
"label": "Add Missing Children",
|
||||
@@ -96,7 +103,8 @@
|
||||
{
|
||||
"name": "socialBots",
|
||||
"type": "node",
|
||||
"childType": "Social Bots"
|
||||
"childType": "Social Bots",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "session"
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bots",
|
||||
"relatedUiObject": "Social Bots",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Children",
|
||||
@@ -108,7 +109,8 @@
|
||||
{
|
||||
"name": "socialBots",
|
||||
"type": "node",
|
||||
"childType": "Social Bots"
|
||||
"childType": "Social Bots",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "session"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -44,7 +45,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "userDefinedCode",
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -41,7 +42,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "moveToPhaseEvents"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -38,7 +39,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "nextPhaseEvent"
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -63,7 +64,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "userDefinedCode",
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bots",
|
||||
"relatedUiObject": "Social Bots",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Children",
|
||||
@@ -108,7 +109,8 @@
|
||||
{
|
||||
"name": "socialBots",
|
||||
"type": "node",
|
||||
"childType": "Social Bots"
|
||||
"childType": "Social Bots",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "session"
|
||||
|
||||
@@ -21,13 +21,15 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Move To Phase Event",
|
||||
"relatedUiObject": "Move To Phase Event",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -65,7 +67,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "phases"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -38,7 +39,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "takePosition"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -38,7 +39,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "triggerOff"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -38,7 +39,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "triggerOn"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -50,7 +51,8 @@
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
"childType": "Announcement",
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "userDefinedCode",
|
||||
|
||||
@@ -112,7 +112,7 @@ function newCircularMenuItem() {
|
||||
iconPhysics()
|
||||
|
||||
if (thisObject.icon === undefined) {
|
||||
console.log('[ERROR] newCircularMenuItem -> initialize -> err = Icon not found, Action: "' + thisObject.action + '", relatedUiObject: "' + thisObject.relatedUiObject +'", label: "' + thisObject.label + '"')
|
||||
console.log('[ERROR] newCircularMenuItem -> initialize -> err = Icon not found, Action: "' + thisObject.action + '", relatedUiObject: "' + thisObject.relatedUiObject + '", label: "' + thisObject.label + '"')
|
||||
}
|
||||
|
||||
selfMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
@@ -379,7 +379,21 @@ function newCircularMenuItem() {
|
||||
}
|
||||
|
||||
/* Execute the action and wait for callbacks to update our statuus. */
|
||||
thisObject.actionFunction({ node: thisObject.payload.node, name: thisObject.action, project: thisObject.actionProject, relatedNodeType: thisObject.relatedUiObject, callBackFunction: onPrimaryCallBack })
|
||||
let relatedNodeProject = thisObject.actionProject
|
||||
if (thisObject.relatedUiObjectProject !== undefined) {
|
||||
relatedNodeProject = thisObject.relatedUiObjectProject
|
||||
}
|
||||
|
||||
thisObject.actionFunction(
|
||||
{
|
||||
node: thisObject.payload.node,
|
||||
name: thisObject.action,
|
||||
project: thisObject.actionProject,
|
||||
relatedNodeType: thisObject.relatedUiObject,
|
||||
relatedNodeProject: relatedNodeProject,
|
||||
callBackFunction: onPrimaryCallBack
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
if (temporaryStatus === STATUS_PRIMARY_WORK_DONE && thisObject.secondaryAction !== undefined) {
|
||||
@@ -502,7 +516,7 @@ function newCircularMenuItem() {
|
||||
if (thisObject.icon === undefined) {
|
||||
thisObject.icon = UI.projects.foundations.spaces.designSpace.getIconByProjectAndName('Foundations', 'missing-image')
|
||||
}
|
||||
|
||||
|
||||
if (thisObject.icon !== undefined) {
|
||||
if (thisObject.icon.canDrawIcon === true && thisObject.currentRadius > 1 && thisObject.isDeployed === true) {
|
||||
browserCanvasContext.drawImage(thisObject.icon, menuPosition.x - iconSize, menuPosition.y - iconSize, iconSize * 2, iconSize * 2)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SOCIAL_BOTS_MODULE =
|
||||
TS.projects.foundations.botModules.socialBots.newFoundationsBotModulesSocialBots(processIndex)
|
||||
TS.projects.socialBots.botModules.socialBots.newSocialBotsBotModulesSocialBots(processIndex)
|
||||
|
||||
return thisObject;
|
||||
|
||||
|
||||
@@ -331,11 +331,6 @@
|
||||
"name": "Workspace Functions",
|
||||
"propertyName": "workspaceFunctions",
|
||||
"functionName": "newFoundationsFunctionLibraryWorkspaceFunctions"
|
||||
},
|
||||
{
|
||||
"name": "Social Bots Functions",
|
||||
"propertyName": "socialBotsFunctions",
|
||||
"functionName": "newFoundationsFunctionLibrarySocialBotsFunctions"
|
||||
}
|
||||
],
|
||||
"utilities": [
|
||||
@@ -739,50 +734,7 @@
|
||||
"fileName": "ProcessOutput.js"
|
||||
}
|
||||
],
|
||||
"botModules": [
|
||||
{
|
||||
"name": "Announcements",
|
||||
"propertyName": "announcements",
|
||||
"functionName": "newFoundationsBotModulesAnnouncements",
|
||||
"fileName": "Announcements.js",
|
||||
"folderName": "Trading-Bot/Announcements"
|
||||
},
|
||||
{
|
||||
"name": "Social Bots",
|
||||
"propertyName": "socialBots",
|
||||
"functionName": "newFoundationsBotModulesSocialBots",
|
||||
"fileName": "SocialBots.js",
|
||||
"folderName": "Trading-Bot/Announcements"
|
||||
},
|
||||
{
|
||||
"name": "Telegram Bot",
|
||||
"propertyName": "telegramBot",
|
||||
"functionName": "newFoundationsBotModulesTelegramBot",
|
||||
"fileName": "TelegramBot.js",
|
||||
"folderName": "Trading-Bot/Announcements"
|
||||
},
|
||||
{
|
||||
"name": "Discord Bot",
|
||||
"propertyName": "discordBot",
|
||||
"functionName": "newFoundationsBotModulesDiscordBot",
|
||||
"fileName": "DiscordBot.js",
|
||||
"folderName": "Trading-Bot/Announcements"
|
||||
},
|
||||
{
|
||||
"name": "Slack Bot",
|
||||
"propertyName": "slackBot",
|
||||
"functionName": "newFoundationsBotModulesSlackBot",
|
||||
"fileName": "SlackBot.js",
|
||||
"folderName": "Trading-Bot/Announcements"
|
||||
},
|
||||
{
|
||||
"name": "Twitter Bot",
|
||||
"propertyName": "twitterBot",
|
||||
"functionName": "newFoundationsBotModulesTwitterBot",
|
||||
"fileName": "TwitterBot.js",
|
||||
"folderName": "Trading-Bot/Announcements"
|
||||
}
|
||||
]
|
||||
"botModules": []
|
||||
},
|
||||
"PL": {
|
||||
"utilities": [
|
||||
@@ -1599,5 +1551,76 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Social-Bots",
|
||||
"propertyName": "socialBots",
|
||||
"UI": {
|
||||
"functionLibraries": [
|
||||
{
|
||||
"name": "Social Bots Functions",
|
||||
"propertyName": "socialBotsFunctions",
|
||||
"functionName": "newSocialBotsFunctionLibrarySocialBotsFunctions"
|
||||
}
|
||||
],
|
||||
"utilities": []
|
||||
},
|
||||
"TS": {
|
||||
"botModules": [
|
||||
{
|
||||
"name": "Announcements",
|
||||
"propertyName": "announcements",
|
||||
"functionName": "newSocialBotsBotModulesAnnouncements",
|
||||
"fileName": "Announcements.js",
|
||||
"folderName": ""
|
||||
},
|
||||
{
|
||||
"name": "Social Bots",
|
||||
"propertyName": "socialBots",
|
||||
"functionName": "newSocialBotsBotModulesSocialBots",
|
||||
"fileName": "SocialBots.js",
|
||||
"folderName": ""
|
||||
},
|
||||
{
|
||||
"name": "Telegram Bot",
|
||||
"propertyName": "telegramBot",
|
||||
"functionName": "newSocialBotsBotModulesTelegramBot",
|
||||
"fileName": "TelegramBot.js",
|
||||
"folderName": ""
|
||||
},
|
||||
{
|
||||
"name": "Discord Bot",
|
||||
"propertyName": "discordBot",
|
||||
"functionName": "newSocialBotsBotModulesDiscordBot",
|
||||
"fileName": "DiscordBot.js",
|
||||
"folderName": ""
|
||||
},
|
||||
{
|
||||
"name": "Slack Bot",
|
||||
"propertyName": "slackBot",
|
||||
"functionName": "newSocialBotsBotModulesSlackBot",
|
||||
"fileName": "SlackBot.js",
|
||||
"folderName": ""
|
||||
},
|
||||
{
|
||||
"name": "Twitter Bot",
|
||||
"propertyName": "twitterBot",
|
||||
"functionName": "newSocialBotsBotModulesTwitterBot",
|
||||
"fileName": "TwitterBot.js",
|
||||
"folderName": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Visual-Scripting",
|
||||
"propertyName": "visualScripting",
|
||||
"UI": {
|
||||
"functionLibraries": [],
|
||||
"utilities": []
|
||||
},
|
||||
"TS": {
|
||||
"botModules": []
|
||||
}
|
||||
}
|
||||
]
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
File renamed without changes.
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
File renamed without changes.
File renamed without changes.
+4
-2
@@ -9,7 +9,8 @@
|
||||
"actionFunction": "uiObject.codeEditor.activate",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
"iconPathOff": "configuration",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -18,7 +19,8 @@
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
+4
-2
@@ -7,7 +7,8 @@
|
||||
"iconPathOn": "javascript-code",
|
||||
"iconPathOff": "javascript-code",
|
||||
"dontShowAtFullscreen": true,
|
||||
"actionFunction": "uiObject.formulaEditor.activate"
|
||||
"actionFunction": "uiObject.formulaEditor.activate",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -16,7 +17,8 @@
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"addLeftIcons": true,
|
||||
+14
-6
@@ -9,7 +9,8 @@
|
||||
"actionFunction": "uiObject.configEditor.activate",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
"iconPathOff": "configuration",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
@@ -17,7 +18,9 @@
|
||||
"propertyToCheckFor": "announcementFormula",
|
||||
"label": "Add Announcement Formula",
|
||||
"relatedUiObject": "Announcement Formula",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"relatedUiObjectProject": "Social-Bots",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
@@ -25,7 +28,9 @@
|
||||
"propertyToCheckFor": "announcementCondition",
|
||||
"label": "Add Announcement Condition",
|
||||
"relatedUiObject": "Announcement Condition",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"relatedUiObjectProject": "Social-Bots",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -34,7 +39,8 @@
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
@@ -50,13 +56,15 @@
|
||||
"name": "announcementFormula",
|
||||
"type": "node",
|
||||
"childType": "Announcement Formula",
|
||||
"autoAdd": true
|
||||
"autoAdd": true,
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "announcementCondition",
|
||||
"type": "node",
|
||||
"childType": "Announcement Condition",
|
||||
"autoAdd": true
|
||||
"autoAdd": true,
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "announcements"
|
||||
+6
-3
@@ -9,14 +9,16 @@
|
||||
"actionFunction": "uiObject.configEditor.activate",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
"iconPathOff": "configuration",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Send Discord Test Message",
|
||||
"label": "Send Discord Test Message",
|
||||
"iconPathOn": "test-entity",
|
||||
"iconPathOff": "test-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "SocialBots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -25,7 +27,8 @@
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
+6
-3
@@ -9,14 +9,16 @@
|
||||
"actionFunction": "uiObject.configEditor.activate",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
"iconPathOff": "configuration",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Send Slack Test Message",
|
||||
"label": "Send Slack Test Message",
|
||||
"iconPathOn": "test-entity",
|
||||
"iconPathOff": "test-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "SocialBots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -25,7 +27,8 @@
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
+8
-4
@@ -9,7 +9,8 @@
|
||||
"actionFunction": "uiObject.configEditor.activate",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
"iconPathOff": "configuration",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
@@ -17,7 +18,8 @@
|
||||
"propertyToCheckFor": "formula",
|
||||
"label": "Add Formula",
|
||||
"relatedUiObject": "Formula",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -26,7 +28,8 @@
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
@@ -42,7 +45,8 @@
|
||||
"name": "formula",
|
||||
"type": "node",
|
||||
"childType": "Formula",
|
||||
"autoAdd": true
|
||||
"autoAdd": true,
|
||||
"project": "Foundations"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "socialBotCommand"
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"type": "Social Bots",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Telegram Bot",
|
||||
"relatedUiObject": "Telegram Bot",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Discord Bot",
|
||||
"relatedUiObject": "Discord Bot",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Slack Bot",
|
||||
"relatedUiObject": "Slack Bot",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Twitter Bot",
|
||||
"relatedUiObject": "Twitter Bot",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Delete",
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"addLeftIcons": true,
|
||||
"level": 4,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Backtesting Session->Live Trading Session->Paper Trading Session->Forward Testing Session->Back Learning Session->Live Learning Session->"
|
||||
},
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "telegramBots",
|
||||
"type": "array",
|
||||
"childType": "Telegram Bot",
|
||||
"autoAdd": true,
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "discordBots",
|
||||
"type": "array",
|
||||
"childType": "Discord Bot",
|
||||
"autoAdd": true,
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "slackBots",
|
||||
"type": "array",
|
||||
"childType": "Slack Bot",
|
||||
"autoAdd": true,
|
||||
"project": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"name": "twitterBots",
|
||||
"type": "array",
|
||||
"childType": "Twitter Bot",
|
||||
"autoAdd": true,
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "socialBots"
|
||||
}
|
||||
+11
-5
@@ -9,20 +9,24 @@
|
||||
"actionFunction": "uiObject.configEditor.activate",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
"iconPathOff": "configuration",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bot Command",
|
||||
"relatedUiObject": "Social Bot Command",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Send Telegram Test Message",
|
||||
"label": "Send Telegram Test Message",
|
||||
"iconPathOn": "test-entity",
|
||||
"iconPathOff": "test-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "SocialBots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -31,7 +35,8 @@
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
@@ -47,7 +52,8 @@
|
||||
"name": "socialBotCommand",
|
||||
"type": "array",
|
||||
"childType": "Social Bot Command",
|
||||
"autoAdd": false
|
||||
"autoAdd": false,
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "telegramBots"
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"type": "Twitter Bot",
|
||||
"editors": {
|
||||
"config": true
|
||||
},
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Configure",
|
||||
"actionFunction": "uiObject.configEditor.activate",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration",
|
||||
"actionProject": "Foundations"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Social Bot Command",
|
||||
"relatedUiObject": "Social Bot Command",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations",
|
||||
"relatedUiObjectProject": "Social-Bots"
|
||||
},
|
||||
{
|
||||
"action": "Send Twitter Test Message",
|
||||
"label": "Send Twitter Test Message",
|
||||
"iconPathOn": "test-entity",
|
||||
"iconPathOff": "test-entity",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "SocialBots"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Delete",
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"actionProject": "Foundations"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
"config": "{ \n\"botToken\": \"Paste the bot token obtained from Twitter \",\n}"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 3,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Social Bots->"
|
||||
},
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "socialBotCommand",
|
||||
"type": "array",
|
||||
"childType": "Social Bot Command",
|
||||
"autoAdd": false,
|
||||
"project": "Social-Bots"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "twitterBots"
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
exports.newFoundationsBotModulesAnnouncements = function (processIndex) {
|
||||
exports.newSocialBotsBotModulesAnnouncements = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = 'Announcements'
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
exports.newFoundationsBotModulesDiscordBot = function (processIndex) {
|
||||
exports.newSocialBotsBotModulesDiscordBot = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = 'Discord Bot'
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
exports.newFoundationsBotModulesSlackBot = function (processIndex) {
|
||||
exports.newSocialBotsBotModulesSlackBot = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = 'Slack Bot'
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
exports.newSocialBotsBotModulesSocialBots = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = 'Social Bots'
|
||||
|
||||
let thisObject = {
|
||||
sendMessage: sendMessage,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots !== undefined) {
|
||||
for (let prop in TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots) {
|
||||
if (prop.toLowerCase().includes("Bots".toLowerCase())) {
|
||||
for (let i = 0; i < TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop][i]
|
||||
let config = socialBot.config
|
||||
let commands = socialBot.socialBotCommand
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
socialBot.botInstance = TS.projects.socialBots.botModules.telegramBot.newSocialBotsBotModulesTelegramBot(processIndex)
|
||||
socialBot.botInstance.initialize(config, commands)
|
||||
} else if (socialBot.type === "Discord Bot") {
|
||||
socialBot.botInstance = TS.projects.socialBots.botModules.discordBot.newSocialBotsBotModulesDiscordBot(processIndex)
|
||||
socialBot.botInstance.initialize(config)
|
||||
} else if (socialBot.type === "Slack Bot") {
|
||||
socialBot.botInstance = TS.projects.socialBots.botModules.slackBot.newSocialBotsBotModulesSlackBot(processIndex)
|
||||
socialBot.botInstance.initialize(config)
|
||||
} else if (socialBot.type === "Twitter Bot") {
|
||||
socialBot.botInstance = TS.projects.socialBots.botModules.slackBot.newSocialBotsBotModulesTwitterBot(processIndex)
|
||||
socialBot.botInstance.initialize(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function announce(text) {
|
||||
for (let prop in TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots) {
|
||||
if (prop.toLowerCase().includes("Bots".toLowerCase())) {
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop] !== undefined) {
|
||||
for (let i = 0; i < TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop][i]
|
||||
try {
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, text).catch(err => TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> initializeSocialBots -> announce -> Telegram API error -> err = " + err))
|
||||
} else if (socialBot.type === "Discord Bot" || socialBot.type === "Slack Bot") {
|
||||
socialBot.botInstance.sendMessage(text).catch(err => TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> initializeSocialBots -> announce -> Discord Bot error -> err = " + err))
|
||||
}
|
||||
} catch (err) {
|
||||
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> announce -> err = " + err.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.announce = announce
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots === undefined) { return }
|
||||
for (let prop in TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots) {
|
||||
if (prop.includes("Bots")) {
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop] !== undefined) {
|
||||
for (let i = 0; i < TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop][i]
|
||||
if (socialBot.type === "Telegram Bot" || socialBot.type === "Discord Bot" || socialBot.type === "Slack Bot") {
|
||||
socialBot.botInstance.finalize()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendMessage(message) {
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots !== undefined) {
|
||||
for (let prop in TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots) {
|
||||
if (prop.includes("Bots")) {
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop] !== undefined) {
|
||||
for (let i = 0; i < TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop][i]
|
||||
if (socialBot.type === "Telegram Bot" || socialBot.type === "Discord Bot" || socialBot.type === "Slack Bot") {
|
||||
socialBot.botInstance.sendMessage(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
exports.newFoundationsBotModulesTelegramBot = function (processIndex) {
|
||||
exports.newSocialBotsBotModulesTelegramBot = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = 'Telegram Bot'
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
exports.newSocialBotsBotModulesTwitterBot = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = 'Twitter Bot'
|
||||
|
||||
let thisObject = {
|
||||
taskParameters: undefined,
|
||||
format: undefined,
|
||||
twitterclient: undefined,
|
||||
sendMessage: sendMessage,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize(config) {
|
||||
/* Twitter Bot Initialization */
|
||||
var Twitter = SA.nodeModules.twitter
|
||||
|
||||
let consumer_key = config.consumer_key
|
||||
let consumer_secret = config.consumer_secret
|
||||
let access_token_key = config.access_token_key
|
||||
let access_token_secret = config.access_token_secret
|
||||
|
||||
if (process.env.TWITTER_CONSUMER_KEY) {
|
||||
consumer_key = process.env.TWITTER_CONSUMER_KEY
|
||||
}
|
||||
if (process.env.TWITTER_CONSUMER_SECRET) {
|
||||
consumer_secret = process.env.TWITTER_CONSUMER_SECRET
|
||||
}
|
||||
if (process.env.TWITTER_ACCESS_TOKEN_KEY) {
|
||||
access_token_key = process.env.TWITTER_ACCESS_TOKEN_KEY
|
||||
}
|
||||
if (process.env.TWITTER_ACCESS_TOKEN_SECRET) {
|
||||
access_token_secret = process.env.TWITTER_ACCESS_TOKEN_SECRET
|
||||
}
|
||||
|
||||
var twitterclient = new Twitter({
|
||||
consumer_key: consumer_key,
|
||||
consumer_secret: consumer_secret,
|
||||
access_token_key: access_token_key,
|
||||
access_token_secret: access_token_secret
|
||||
});
|
||||
thisObject.twitterclient = twitterclient
|
||||
|
||||
try {
|
||||
thisObject.taskParameters = {
|
||||
exchange: TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name,
|
||||
market: TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName +
|
||||
'/' +
|
||||
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
}
|
||||
if (config.format === undefined) {
|
||||
thisObject.format = "%{MESSAGE}"
|
||||
} else {
|
||||
thisObject.format = config.format
|
||||
}
|
||||
} catch (err) {
|
||||
logError("initialize -> err = " + err.stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function finalize() {}
|
||||
|
||||
function sendMessage(message) {
|
||||
try {
|
||||
message = formatMessage(message)
|
||||
message = JSON.stringify({status: message})
|
||||
} catch (err) {
|
||||
logError("announce -> Twitter JSON message error -> err = " + err)
|
||||
}
|
||||
|
||||
thisObject.twitterclient.post('statuses/update', message, function(error, tweet, response) {
|
||||
if(error) throw error;
|
||||
console.log(tweet); // Tweet body.
|
||||
console.log(response); // Raw response object.
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function formatMessage(message) {
|
||||
formattedMessage = thisObject.format
|
||||
formattedMessage = formattedMessage.replace('%{EXCHANGE}', thisObject.taskParameters.exchange)
|
||||
formattedMessage = formattedMessage.replace('%{MARKET}', thisObject.taskParameters.market)
|
||||
formattedMessage = formattedMessage.replace('%{MESSAGE}', message)
|
||||
return formattedMessage
|
||||
}
|
||||
|
||||
function logWarn(message) {
|
||||
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[WARN] ' + message)
|
||||
}
|
||||
|
||||
function logError(message) {
|
||||
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] ' + message)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
function newSocialBotsActionSwitch() {
|
||||
|
||||
let thisObject = {
|
||||
executeAction: executeAction,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
/* Nothing to initialize since a Function Library does not hold any state. */
|
||||
}
|
||||
|
||||
async function executeAction(action) {
|
||||
switch (action.name) {
|
||||
case 'Send Telegram Test Message':
|
||||
{
|
||||
UI.projects.socialBots.functionLibraries.socialBotsFunctions.sendTelegramTestMessage(action.node, action.callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Send Discord Test Message':
|
||||
{
|
||||
UI.projects.socialBots.functionLibraries.socialBotsFunctions.sendDiscordTestMessage(action.node, action.callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Send Slack Test Message':
|
||||
{
|
||||
UI.projects.socialBots.functionLibraries.socialBotsFunctions.sendSlackTestMessage(action.node, action.callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Send Twitter Test Message':
|
||||
{
|
||||
UI.projects.socialBots.functionLibraries.socialBotsFunctions.sendTwitterTestMessage(action.node, action.callBackFunction)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
function newSocialBotsFunctionLibrarySocialBotsFunctions() {
|
||||
let thisObject = {
|
||||
sendTelegramTestMessage: sendTelegramTestMessage,
|
||||
sendDiscordTestMessage: sendDiscordTestMessage,
|
||||
sendSlackTestMessage: sendSlackTestMessage,
|
||||
sendTwitterTestMessage: sendTwitterTestMessage
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function sendTelegramTestMessage(node, callBackFunction) {
|
||||
|
||||
let botToken = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'botToken')
|
||||
let chatId = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'chatId')
|
||||
|
||||
if (botToken === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('botToken parameter not defined.')
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
if (chatId === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('chatId parameter not defined.')
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
let params = {
|
||||
text: "Test Message from Superalgos",
|
||||
chat_id: chatId
|
||||
}
|
||||
|
||||
httpRequestJSON(JSON.stringify(params),"https://api.telegram.org/bot" + botToken + "/sendMessage", onResponse)
|
||||
|
||||
function onResponse(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setInfoMessage('Telegram message sent.')
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage('Could not send Telegram message. Error Response: ' + err.message)
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
function httpRequestJSON(pContentToSend, pPath, callBackFunction) {
|
||||
let xmlHttpRequest = new XMLHttpRequest();
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, xmlHttpRequest.responseText);
|
||||
return;
|
||||
} else if (this.readyState === 4 && (this.status === 404 || this.status === 401 || this.status === 400)) {
|
||||
callBackFunction({
|
||||
result: "Fail",
|
||||
message: JSON.parse(xmlHttpRequest.responseText).description,
|
||||
code: JSON.parse(xmlHttpRequest.responseText).error_code
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if (pContentToSend === undefined) {
|
||||
xmlHttpRequest.open("GET", pPath, true);
|
||||
xmlHttpRequest.send();
|
||||
} else {
|
||||
try {
|
||||
let blob = new Blob([pContentToSend], { type: 'application/json' });
|
||||
xmlHttpRequest.open("POST", pPath, true);
|
||||
xmlHttpRequest.send(blob);
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] callServer -> err.message = " & err.message); }
|
||||
callBackFunction({ result: "Fail", message: err.message })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendDiscordTestMessage(node, callBackFunction) {
|
||||
|
||||
let webhookURL = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'webhookURL')
|
||||
|
||||
if (webhookURL === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('webhookURL parameter not defined.')
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
let message = "Test message from Superalgos!"
|
||||
|
||||
httpRequestJSON(JSON.stringify({content: message}), webhookURL, onResponse)
|
||||
|
||||
function onResponse(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setInfoMessage('Discord message sent.')
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage('Could not send Discord message. Error Response: ' + err.message)
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
function httpRequestJSON(pContentToSend, pPath, callBackFunction) {
|
||||
let xmlHttpRequest = new XMLHttpRequest();
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, xmlHttpRequest.responseText);
|
||||
return;
|
||||
} else if (this.readyState === 4 && (this.status === 404 || this.status === 401 || this.status === 400)) {
|
||||
callBackFunction({
|
||||
result: "Fail",
|
||||
message: JSON.parse(xmlHttpRequest.responseText).description,
|
||||
code: JSON.parse(xmlHttpRequest.responseText).error_code
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if (pContentToSend === undefined) {
|
||||
xmlHttpRequest.open("GET", pPath, true);
|
||||
xmlHttpRequest.send();
|
||||
} else {
|
||||
try {
|
||||
let blob = new Blob([pContentToSend], { type: 'application/json' });
|
||||
xmlHttpRequest.open("POST", pPath, true);
|
||||
xmlHttpRequest.send(blob);
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] callServer -> err.message = " & err.message); }
|
||||
callBackFunction({ result: "Fail", message: err.message })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendSlackTestMessage(node, callBackFunction) {
|
||||
|
||||
let webhookURL = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'webhookURL')
|
||||
|
||||
if (webhookURL === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('webhookURL parameter not defined.')
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
let message = "Test message from Superalgos!"
|
||||
|
||||
httpRequestJSON(JSON.stringify({text: message}), webhookURL, onResponse)
|
||||
|
||||
function onResponse(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setInfoMessage('Slack message sent.')
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage('Could not send Slack message. Error Response: ' + err.message)
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
function httpRequestJSON(pContentToSend, pPath, callBackFunction) {
|
||||
let xmlHttpRequest = new XMLHttpRequest();
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, xmlHttpRequest.responseText);
|
||||
return;
|
||||
} else if (this.readyState === 4 && (this.status === 404 || this.status === 401 || this.status === 400)) {
|
||||
callBackFunction({
|
||||
result: "Fail",
|
||||
message: xmlHttpRequest.responseText
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if (pContentToSend === undefined) {
|
||||
xmlHttpRequest.open("GET", pPath, true);
|
||||
xmlHttpRequest.send();
|
||||
} else {
|
||||
try {
|
||||
let blob = new Blob([pContentToSend]);
|
||||
xmlHttpRequest.open("POST", pPath, true);
|
||||
xmlHttpRequest.send(blob);
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] callServer -> err.message = " & err.message); }
|
||||
callBackFunction({ result: "Fail", message: err.message })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendTwitterTestMessage(node, callBackFunction) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user