Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
china-dictatorship
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ciro DURAN SANTILLI
china-dictatorship
Commits
13b7c786
Commit
13b7c786
authored
3 years ago
by
Ciro Santilli
Browse files
Options
Downloads
Patches
Plain Diff
OK, comments should work now
parent
ae6d92f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
action.js
+79
-65
79 additions, 65 deletions
action.js
with
79 additions
and
65 deletions
action.js
+
79
−
65
View file @
13b7c786
...
...
@@ -47,13 +47,22 @@ for (const image of images) {
// Prepare reply body.
const
payload
=
github
.
context
.
payload
;
const
titleAndBody
=
payload
.
issue
.
title
+
'
\n\n
'
+
payload
.
issue
.
body
;
const
isComment
=
payload
.
comment
!==
undefined
;
let
titleAndBody
;
let
author
;
if
(
isComment
)
{
titleAndBody
=
payload
.
comment
.
body
;
author
=
payload
.
comment
.
user
.
login
;
}
else
{
titleAndBody
=
payload
.
issue
.
title
+
'
\n\n
'
+
payload
.
issue
.
body
;
author
=
payload
.
issue
.
user
.
login
;
}
const
quoteArray
=
[];
for
(
const
line
of
titleAndBody
.
split
(
'
\n
'
))
{
// Remove some speical chars to remove at mention spam possibilities.
quoteArray
.
push
(
'
>
'
+
line
.
replace
(
/
[
@#
]
/g
,
""
));
}
const
replyBody
=
`Hi
${
payload
.
issue
.
user
.
login
}
,
const
replyBody
=
`Hi
${
author
}
,
${
quoteArray
.
join
(
'
\n
'
).
substring
(
0
,
40000
)}
...
...
@@ -61,67 +70,69 @@ ${full_images.join('\n\n')}
`
;
// Label handling.
const
labels
=
new
Set
(
payload
.
issue
.
labels
.
map
(
label
=>
label
.
name
));
const
newLabels
=
new
Set
();
const
shabiWords
=
[
'
shabi
'
,
'
shadiao
'
,
'
傻
'
,
'
沙雕
'
,
'
智障
'
,
'
啥b
'
,
'
stupid
'
,
];
for
(
const
word
of
shabiWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
))
{
newLabels
.
add
(
'
you-are-stupid-argument
'
);
break
;
if
(
!
isComment
)
{
const
labels
=
new
Set
(
payload
.
issue
.
labels
.
map
(
label
=>
label
.
name
));
const
newLabels
=
new
Set
();
const
shabiWords
=
[
'
shabi
'
,
'
shadiao
'
,
'
傻
'
,
'
沙雕
'
,
'
智障
'
,
'
啥b
'
,
'
stupid
'
,
];
for
(
const
word
of
shabiWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
))
{
newLabels
.
add
(
'
you-are-stupid-argument
'
);
break
;
}
}
}
const
fuckMotherWords
=
[
'
cnm
'
,
'
操你妈
'
,
'
fuck.*
\\
b(mom|mum|mother)
\\
b
'
,
'
尼玛
'
,
'
去你吗
'
,
]
for
(
const
word
of
fuckMotherWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
))
{
newLabels
.
add
(
'
fuck-your-mother-argument
'
)
;
break
;
const
fuckMotherWords
=
[
'
cnm
'
,
'
操你妈
'
,
'
fuck.*
\\
b(mom|mum|mother)
\\
b
'
,
'
尼玛
'
,
'
去你吗
'
,
]
for
(
const
word
of
fuckMotherWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
)
)
{
newLabels
.
add
(
'
fuck-your-mother-argument
'
);
break
;
}
}
}
const
motherDiedWords
=
[
'
nmsl
'
,
'
你妈死
'
,
'
司马
'
,
]
for
(
const
word
of
motherDiedWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
))
{
newLabels
.
add
(
'
your-mother-died-argument
'
)
;
break
;
const
motherDiedWords
=
[
'
nmsl
'
,
'
你妈死
'
,
'
司马
'
,
]
for
(
const
word
of
motherDiedWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
)
)
{
newLabels
.
add
(
'
your-mother-died-argument
'
);
break
;
}
}
}
const
shitpostWords
=
[
'
fuck
'
,
'
shit
'
,
'
bitch
'
,
'
垃圾
'
,
'
婊子
'
,
'
恶心
'
,
'
操你
'
,
];
for
(
const
word
of
shitpostWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
))
{
newLabels
.
add
(
'
shitpost
'
)
;
break
;
const
shitpostWords
=
[
'
fuck
'
,
'
shit
'
,
'
bitch
'
,
'
垃圾
'
,
'
婊子
'
,
'
恶心
'
,
'
操你
'
,
];
for
(
const
word
of
shitpostWords
)
{
if
(
new
RegExp
(
word
,
'
i
'
).
test
(
titleAndBody
)
)
{
newLabels
.
add
(
'
shitpost
'
);
break
;
}
}
}
if
(
newLabels
.
size
>
0
)
{
newLabels
.
add
(
'
shitpost
'
)
;
if
(
labels
.
has
(
'
not-shitpost
'
)
)
{
labels
.
delete
(
'
no
t-shit
post
'
);
newLabels
.
add
(
'
op-does-not-know-what-shit-is
'
);
if
(
newLabels
.
size
>
0
)
{
newLabels
.
add
(
'
shitpost
'
);
if
(
labels
.
has
(
'
not-
shitpost
'
)
)
{
labels
.
delete
(
'
not-shitpost
'
)
;
newLabels
.
add
(
'
op-does-not-know-wha
t-shit
-is
'
);
}
}
}
...
...
@@ -135,12 +146,15 @@ try {
issue_number
:
payload
.
issue
.
number
,
body
:
replyBody
,
});
await
octokit
.
issues
.
update
({
owner
:
'
cirosantilli
'
,
repo
:
payload
.
repository
.
name
,
issue_number
:
payload
.
issue
.
number
,
labels
:
Array
.
from
([...
labels
,
...
newLabels
])
});
if
(
!
isComment
)
{
// Update labels.
await
octokit
.
issues
.
update
({
owner
:
'
cirosantilli
'
,
repo
:
payload
.
repository
.
name
,
issue_number
:
payload
.
issue
.
number
,
labels
:
Array
.
from
([...
labels
,
...
newLabels
])
});
}
}
catch
(
error
)
{
core
.
setFailed
(
error
.
message
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment