forked from baiguke2019/TorrentRaspBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharguments.js
More file actions
27 lines (26 loc) · 672 Bytes
/
Copy patharguments.js
File metadata and controls
27 lines (26 loc) · 672 Bytes
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
const commandArgs = (ctx, next) => {
if (ctx.updateType === 'message' && ctx.update.message.text !== undefined) {
const text = ctx.update.message.text
if (text.startsWith('/')) {
const match = text.match(/^\/([^\s]+)\s?(.+)?/)
let args = []
let command
if (match !== null) {
if (match[1]) {
command = match[1]
}
if (match[2]) {
args = match[2].split(' ')
}
}
ctx.command = {
raw: text,
command,
args,
}
console.log(ctx.command)
}
}
return next()
}
module.exports = commandArgs