Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wmvm
ts-api-demo
Commits
4b0a134f
Commit
4b0a134f
authored
Nov 08, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
报警机器人消息相关调整
parent
c7bac0ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
robotUtils.ts
src/utils/robotUtils.ts
+34
-9
No files found.
src/utils/robotUtils.ts
View file @
4b0a134f
let
{
debug
,
logger
}
=
require
(
'@madex/ex-js-public'
);
const
{
larkRobotUtils
:
LarkRobotUtils
,
}
=
require
(
"@madex/ex-js-common"
)
let
config
=
require
(
'../../config'
);
let
axios
=
require
(
'axios'
);
debug
=
config
.
env
===
"development"
;
let
COMMON_KEY
=
"9e06e260-6c2f-49d4-98b4-e08ef096f6f5"
;
//测试
/**
* Lark 地址
*/
let
LARK_URL_PRE
=
"https://open.larksuite.com/open-apis/bot/v2/hook/"
;
/**
* 生产:pro
*/
let
COMMON_KEY
=
"d9f2dc6e-52cf-4933-92f1-dab9c249aa28"
;
/**
* 测试:dev
*/
if
(
debug
)
{
COMMON_KEY
=
"
9e06e260-6c2f-49d4-98b4-e08ef096f6f5
"
;
COMMON_KEY
=
"
d98c9942-ff6f-4e71-a77f-41647ff19ff0
"
;
}
export
const
ROBOT_KEYS
=
{
COMMON_KEY
:
COMMON_KEY
}
...
...
@@ -27,7 +38,9 @@ export const ROBOT_KEYS = {
* @param _func_name_ 报错方法(可选)
*/
export
const
sendRobotMessage
=
async
function
(
url
:
string
,
content
:
any
,
_func_name_
?:
string
)
{
if
(
!
_func_name_
)
{
_func_name_
=
''
;
}
if
(
typeof
content
!=
'string'
)
{
if
(
content
&&
content
.
sql
)
{
content
=
`backend._func_name_
${
_func_name_
}
,
${
content
.
sql
}
`
;
...
...
@@ -55,5 +68,17 @@ export const sendRobotMessage = async function (url: string, content: any, _func
async
function
doSend
(
url
:
string
,
content
:
any
)
{
logger
.
info
(
'robot message'
,
url
,
content
);
await
LarkRobotUtils
.
sendTextSimple
(
url
,
content
).
catch
()
let
URL
=
LARK_URL_PRE
+
url
;
try
{
let
response
=
await
axios
.
post
(
URL
,
{
msg_type
:
"text"
,
content
:
{
text
:
content
}
});
if
(
response
&&
response
.
data
)
{
return
response
.
data
}
}
catch
(
e
)
{
logger
.
error
(
'robot send error'
,
URL
,
content
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment