forked from cIII1993/LineBotTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myBot.js
67 lines (56 loc) · 1.39 KB
/
myBot.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* jshint esversion:9 */
const Bot = require('./bot');
class myBot extends Bot {
constructor() {
super();
// you can change bot version here
this.version = '0.0.1 myBot';
this.botName = 'myBot';
const botParser = (inputStr) => {
// write your bot parser here.
// maybe you need to preprocess your inputStr.
let msgSplitter = (/\S+/ig);
let mainMsg = inputStr.match(msgSplitter);
let trigger = mainMsg[0];
//
if (trigger.match(/^iWant2Parse$/g) != null) {
return this.runSomeThing();
}
if (trigger.match(/^getGlobal$/g) != null) {
return myBot.someGlobalFunction();
}
// You also can call function from original Bot.
if (trigger.match(/^SWRMER$/) != null) {
return this.swRm();
}
/* ......and so no. */
// default is return "undefined"
return;
};
const botHelper = [
// write your bot help here.
{
title: "iWant2Parse",
description:`Description`,
reg: "iw2p"
},
{
title: "getGlobal",
description: `Description2`,
reg: "gGL"
}
];
/* ......Other things */
// Don't change this return.
return this.parserExtant(this.botName, botParser).helpExtant(this.botName, botHelper);
}
// The function you need to call from instance by this.functionName().
runSomeThing() {
return 'You Got It!';
}
//
static someGlobalFunction() {
return `I come from Global.`;
}
}
module.exports = myBot;