Skip to content

Commit

Permalink
fix bug when translate body equal origin
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 committed Dec 4, 2020
1 parent bef15ee commit b5ce985
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function run(): Promise<void> {
try {
if (
(github.context.eventName !== 'issue_comment' || github.context.payload.action !== 'created') &&
(github.context.eventName != 'issues' || github.context.payload.action !== 'opened')
(github.context.eventName !== 'issues' || github.context.payload.action !== 'opened')
) {
core.info(
`The status of the action must be created on issue_comment, no applicable - ${github.context.payload.action} on ${github.context.eventName}, return`
Expand Down Expand Up @@ -105,14 +105,16 @@ async function translateCommentBody(body: string, issueUser: string): Promise<st
let result = ''
await translate(body, {to: 'en'})
.then(res => {
result =
if (res.text !== body) {
result =
`
> @${issueUser}
> Bot detected the issue 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)
Expand Down

0 comments on commit b5ce985

Please sign in to comment.