提交 af443409 编写于 作者: sinat_25235033's avatar sinat_25235033

complete action

上级 71c30cb5
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
......@@ -22,7 +22,7 @@ async function run(): Promise<void> {
// detect comment body is english
if (detectIsEnglish(issue_origin_comment_body)) {
core.info('the issue comment body is english already, ignore return.')
core.info('Detect the issue comment body is english already, ignore return.')
return
}
......@@ -31,7 +31,6 @@ async function run(): Promise<void> {
let octokit = null;
const issue_user = issueCommentPayload.comment.user.login
let bot_login_name = core.getInput('BOT_LOGIN_NAME')
core.info(`bot_login_name1: ${bot_login_name}`)
if (bot_login_name === null || bot_login_name === undefined || bot_login_name === '') {
octokit = github.getOctokit(myToken)
const botInfo = await octokit.request('GET /user')
......@@ -40,7 +39,7 @@ async function run(): Promise<void> {
core.info(`bot_login_name2: ${bot_login_name}`)
}
if (bot_login_name === issue_user) {
core.info("The issue comment user is bot self, ignore return.")
core.info(`The issue comment user is bot ${bot_login_name} himself, ignore return.`)
return
}
......@@ -72,7 +71,10 @@ async function run(): Promise<void> {
function detectIsEnglish(body: string): boolean | true {
const lngDetector = new LanguageDetect()
const detectResult = lngDetector.detect(body, 1)
core.info(`detect comment body result is: ${detectResult[0][0]}, sorce: ${detectResult[0][1]}`)
if (detectResult === undefined || detectResult === null || detectResult.length !== 1) {
core.setFailed(`Can not detect the comment body: ${body}`)
}
core.info(`Detect comment body language result is: ${detectResult[0][0]}, similar sorce: ${detectResult[0][1]}`)
return detectResult.length === 1 && detectResult[0][0] === 'english'
}
......@@ -80,7 +82,13 @@ async function translateCommentBody(body: string): Promise<string> {
let result = ''
await translate(body, {to: 'en'})
.then(res => {
result = res.text
result = `
> Bot detected the comment body's language is not English, translate it automatically. For the convenience of others, please use English next time.
----
${res.text}
`
})
.catch(err => {
core.error(err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册