Bug Fix: Defining Each Telegram and Discord Bot Array
This commit is contained in:
1 parent
a647dd6d59
commit
0e8580d376
7 files changed
+55
-41
No files matched your search
@@ -23,7 +23,7 @@
|
||||
"action": "Add UI Object",
|
||||
"disableIfPropertyIsDefined": true,
|
||||
"propertyToCheckFor": "announcementCondition",
|
||||
"label": "Add Condition",
|
||||
"label": "Add Announcement Condition",
|
||||
"relatedUiObject": "Announcement Condition",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
"config": "{\n\"webhookURL\": \"Paste the webhook url obtained from Discord > Channel Settings > Integrations > Webhooks > New Webhook\"\n}"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 4,
|
||||
"level": 3,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Social Bots->"
|
||||
},
|
||||
"childrenNodesProperties": [],
|
||||
"propertyNameAtParent": "bots"
|
||||
"propertyNameAtParent": "discordBots"
|
||||
}
|
||||
@@ -30,13 +30,13 @@
|
||||
},
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "bots",
|
||||
"name": "telegramBots",
|
||||
"type": "array",
|
||||
"childType": "Telegram Bot",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "bots",
|
||||
"name": "discordBots",
|
||||
"type": "array",
|
||||
"childType": "Discord Bot",
|
||||
"autoAdd": true
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
"config": "{ \n\"botToken\": \"Paste the bot token obtained from Telegram Bot Father\",\n\"chatId\": \"Type or paste the chat or group id -a number with no quotes- where announcements are going to be sent to\"\n}"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 4,
|
||||
"level": 3,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Social Bots->"
|
||||
},
|
||||
"childrenNodesProperties": [],
|
||||
"propertyNameAtParent": "bots"
|
||||
"propertyNameAtParent": "telegramBots"
|
||||
}
|
||||
@@ -12,33 +12,39 @@ exports.newSuperalgosBotModulesSocialBots = function (processIndex) {
|
||||
|
||||
function initialize() {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots !== undefined) {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots.length; i++) {
|
||||
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots[i]
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
let config = socialBot.config
|
||||
socialBot.botInstance = TS.projects.superalgos.botModules.telegramBot.newSuperalgosBotModulesTelegramBot(processIndex)
|
||||
socialBot.botInstance.initialize(config.botToken, config.chatId)
|
||||
} else if (socialBot.type === "Discord Bot"){
|
||||
let config = socialBot.config
|
||||
socialBot.botInstance = TS.projects.superalgos.botModules.discordBot.newSuperalgosBotModulesDiscordBot(processIndex)
|
||||
socialBot.botInstance.initialize(config.webhookURL)
|
||||
for (let prop in TS.projects.superalgos.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.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop][i]
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
let config = socialBot.config
|
||||
socialBot.botInstance = TS.projects.superalgos.botModules.telegramBot.newSuperalgosBotModulesTelegramBot(processIndex)
|
||||
socialBot.botInstance.initialize(config.botToken, config.chatId)
|
||||
} else if (socialBot.type === "Discord Bot") {
|
||||
let config = socialBot.config
|
||||
socialBot.botInstance = TS.projects.superalgos.botModules.discordBot.newSuperalgosBotModulesDiscordBot(processIndex)
|
||||
socialBot.botInstance.initialize(config.webhookURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function announce(text) {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots.length; i++) {
|
||||
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots[i]
|
||||
try {
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, text).catch(err => TS.projects.superalgos.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.botInstance.sendMessage(text).catch(err => TS.projects.superalgos.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))
|
||||
for (let prop in TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots) {
|
||||
if (prop.toLowerCase().includes("Bots".toLowerCase())) {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop] !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.superalgos.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.superalgos.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.botInstance.sendMessage(text).catch(err => TS.projects.superalgos.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.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> announce -> err = " + err.stack);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[WARN] initialize -> announce -> err = " + err.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,11 +56,15 @@ exports.newSuperalgosBotModulesSocialBots = function (processIndex) {
|
||||
|
||||
function finalize() {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots === undefined) { return }
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots.length; i++) {
|
||||
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots[i]
|
||||
if (socialBot.type === "Telegram Bot" || socialBot.type === "Discord Bot") {
|
||||
socialBot.botInstance.finalize()
|
||||
for (let prop in TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots) {
|
||||
if (prop.includes("Bots")) {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop] !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop][i]
|
||||
if (socialBot.type === "Telegram Bot" || socialBot.type === "Discord Bot") {
|
||||
socialBot.botInstance.finalize()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,11 +72,15 @@ exports.newSuperalgosBotModulesSocialBots = function (processIndex) {
|
||||
|
||||
function sendMessage(message) {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots !== undefined) {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots.length; i++) {
|
||||
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.bots[i]
|
||||
if (socialBot.type === "Telegram Bot" || socialBot.type === "Discord Bot") {
|
||||
socialBot.botInstance.sendMessage(message)
|
||||
for (let prop in TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots) {
|
||||
if (prop.includes("Bots")) {
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop] !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop].length; i++) {
|
||||
let socialBot = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots[prop][i]
|
||||
if (socialBot.type === "Telegram Bot" || socialBot.type === "Discord Bot") {
|
||||
socialBot.botInstance.sendMessage(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ function newSuperalgosFunctionLibraryLearningSessionFunctions() {
|
||||
'Back Learning Session->Live Learning Session->' +
|
||||
'Learning Parameters->' +
|
||||
'Learning Algorithm->Time Range->Time Frame->Heartbeats->User Defined Parameters->' +
|
||||
'Social Bots->Telegram Bot->'
|
||||
'Social Bots->Telegram Bot->Discord Bot->'
|
||||
|
||||
let session = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
|
||||
|
||||
|
||||
@@ -153,8 +153,8 @@ function newSuperalgosFunctionLibraryTradingSessionFunctions() {
|
||||
'Backtesting Session->Paper Trading Session->Forward Testing Session->Live Trading Session->' +
|
||||
'Trading Parameters->' +
|
||||
'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Snapshots->Heartbeats->User Defined Parameters->' +
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Social Bots->Telegram Bot->'
|
||||
'Social Bots->Telegram Bot->Discord Bot->' +
|
||||
'Exchange Account Asset->Asset->'
|
||||
|
||||
let session = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
|
||||
|
||||
|
||||
Reference in new issue
Block a user