-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbot.js
More file actions
48 lines (43 loc) · 1.13 KB
/
bot.js
File metadata and controls
48 lines (43 loc) · 1.13 KB
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
46
47
48
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: checkModuleId(match[2]) ? match[1] : 'invalid',
title: match[2]
}
}
return {
type: match[1],
title: match[2]
}
}
}
return {
type: '',
title
}
}
function checkModuleId (moduleId) {
// moduleId must match pattern: ^[a-zA-Z][a-zA-Z0-9._-]+$
if (!moduleId.match(/^[a-zA-Z][a-zA-Z0-9._-]+$/)) return false
// Blacklist check
const blacklist = ['com.android', 'com.google', 'org.lsposed', 'io.github.lsposed', 'org.kernelsu', 'io.github.kernelsu']
for (const item of blacklist) {
if (moduleId.toLowerCase().startsWith(item)) return false
}
// Disallow 'example' in moduleId
if (moduleId.toLowerCase().includes('example')) return false
return true
}
module.exports = {
recognizeTitle
}