Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Alexander
/
alex-hunter-sales-dev
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bb01d65b
authored
Nov 01, 2022
by
softwhiskey8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
перенес функции отправки сообщений телеграм в shared
1 parent
4f0a68d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
32 deletions
app/main.dsl
index.js
shared.js
app/main.dsl
View file @
bb01d65
...
...
@@ -38,7 +38,7 @@ external function hours_now(): number;
external function check_mobile_code(phone: string): boolean;
external function countWords(message: string): number;
external function sendTelegram(phone: string, json: unknown): string;
external function sendTelegramChannel(channel_type: string, mail: string): string;
external function sendTelegramChannel(
phone: string,
channel_type: string, mail: string): string;
start node root
{
...
...
@@ -138,7 +138,7 @@ node tg
positive: do
{
set $channel_type = "Telegram";
external sendTelegramChannel($channel_type, ""); //отправка уведомления в канал
external sendTelegramChannel($
phone, $
channel_type, ""); //отправка уведомления в канал
var message = {webinar: "Как продавать на маркетплейсах в 2022",
date: "11 июля",
...
...
@@ -184,7 +184,7 @@ node watsup
positive: do
{
set $channel_type = "WhatsApp";
external sendTelegramChannel($channel_type, "");
external sendTelegramChannel($
phone, $
channel_type, "");
}
}
}
...
...
@@ -213,7 +213,7 @@ node mail
//external sendMail($mail, $promocode);
var mail = "temp@mail.ru";
set $channel_type = "почту";
external sendTelegramChannel($channel_type, mail);
external sendTelegramChannel($
phone, $
channel_type, mail);
}
}
}
...
...
index.js
View file @
bb01d65
...
...
@@ -138,37 +138,12 @@ async function main() {
return
args
.
message
.
split
(
' '
).
length
;
});
app
.
setExternal
(
"sendTelegram"
,
(
args
)
=>
{
var
cmd
=
`cd /servers/constructor/htdocs/api/; php telegram-send.php `
;
var
tmp_json
=
args
[
'json'
];
var
phone_number
=
args
[
'phone'
];
var
find
=
'\"'
;
var
re
=
new
RegExp
(
find
,
'g'
);
tmp_json
=
JSON
.
stringify
(
tmp_json
).
replace
(
re
,
"\\\""
);
tmp_json
=
"\""
+
tmp_json
+
"\""
;
cmd
+=
`
${
events_owner
}
${
preset_template_id
}
${
phone_number
}
empty empty empty
${
tmp_json
}
`
;
exec
(
cmd
);
return
shared
.
sendTelegram
(
events_owner
,
preset_template_id
,
args
);
});
//функция отправки сообщений в канал
app
.
setExternal
(
"sendTelegramChannel"
,
(
args
)
=>
{
//var cmd = `cd E:/work/projects2/telegram-channel-sender/; dotnet telegram-channel-sender.dll 3 79112349232 ${args['channel_type']}`;
//let cmd = String.raw`cd E:/work/projects2/telegram-channel-sender/
//dotnet telegram-channel-sender.dll 3 79112349232 ${args['channel_type']}`;
var
cmd
=
`cd /servers/constructor/htdocs/api/ && php telegram-channel-sender.php
${
events_owner
}
${
process
.
argv
[
2
]}
${
args
[
'channel_type'
]}
`
;
exec
(
cmd
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
console
.
error
(
`error:
${
error
.
message
}
`
);
return
;
}
if
(
stderr
)
{
console
.
error
(
`stderr:
${
stderr
}
`
);
return
;
}
console
.
log
(
`stdout:\n
${
stdout
}
`
);
});
return
shared
.
sendTelegramChannel
(
events_owner
,
args
);
});
await
app
.
start
();
...
...
shared.js
View file @
bb01d65
...
...
@@ -252,7 +252,39 @@ module.exports = exports = {
if
(
pidName
<
10000
)
pidName
=
'0'
+
pidName
;
return
pidName
;
},
sendTelegram
(
events_owner
,
preset_template_id
,
args
)
{
var
cmd
=
`cd /servers/constructor/htdocs/api/; php telegram-send.php `
;
var
tmp_json
=
args
[
'json'
];
var
phone_number
=
args
[
'phone'
];
var
find
=
'\"'
;
var
re
=
new
RegExp
(
find
,
'g'
);
tmp_json
=
JSON
.
stringify
(
tmp_json
).
replace
(
re
,
"\\\""
);
tmp_json
=
"\""
+
tmp_json
+
"\""
;
cmd
+=
`
${
events_owner
}
${
preset_template_id
}
${
phone_number
}
empty empty empty
${
tmp_json
}
`
;
exec
(
cmd
);
return
true
;
},
//функция отправки сообщений в канал
sendTelegramChannel
(
events_owner
,
args
)
{
var
cmd
=
`cd /servers/constructor/htdocs/api/ && php telegram-channel-sender.php
${
events_owner
}
${
args
[
'phone'
]}
${
args
[
'channel_type'
]}
`
;
exec
(
cmd
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
console
.
error
(
`error:
${
error
.
message
}
`
);
return
;
}
if
(
stderr
)
{
console
.
error
(
`stderr:
${
stderr
}
`
);
return
;
}
console
.
log
(
`stdout:\n
${
stdout
}
`
);
});
return
true
;
},
make_unique_app
(
app_suffix
)
{
let
app_suffix_file
=
'./threads/'
+
app_suffix
+
'/app.dashaapp'
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment