-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbot.js
45 lines (43 loc) · 1.07 KB
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function recognizeTitle (title) {
const match = title.match(/^\[([^\]]+)]\s*(.*?)\s*$/)
if (match) {
match[1] = match[1].toLowerCase()
if ([
'submission',
'transfer',
'appeal',
'issue',
'suggestion'
].indexOf(match[1]) !== -1) {
if (match[1] === 'submission' || match[1] === 'transfer') {
return {
type: checkPackageName(match[2]) ? match[1] : 'invalid',
title: match[2]
}
}
return {
type: match[1],
title: match[2]
}
}
}
return {
type: '',
title
}
}
function checkPackageName (packageName) {
if (!packageName.match(/\./)) return false
const groups = packageName.split('.')
for (const group of groups) {
if (!group.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/) || group.toLowerCase() === 'example') return false
}
const blacklist = ['com.android', 'com.google', 'org.lsposed', 'io.github.lsposed']
for (const item of blacklist) {
if (packageName.toLowerCase().startsWith(item)) return false
}
return true
}
module.exports = {
recognizeTitle
}