Skip to content

Instantly share code, notes, and snippets.

@nukisashineko
Created August 23, 2017 21:47
Show Gist options
  • Save nukisashineko/56a97f4e7c611679f9b678d567560a54 to your computer and use it in GitHub Desktop.
Save nukisashineko/56a97f4e7c611679f9b678d567560a54 to your computer and use it in GitHub Desktop.
class Bot {
constructor() {
this.memberVariable = 'aaa';
}
doSomething() {
console.log(this.memberVariable); // => 'aaa'
// do somethings
}
// handle method 一覧
async a() {
this.doSomething();
console.log(this); // => Bot { memberVariable: 'aaa' }
}
b() {
}
async c() {
}
// メイン
async process(text) {
// textによって呼び出す関数を分ける。
const t = this;
switch (text) {
case 'a_func':
await t.a();
break;
case 'b_func':
await t.b();
break;
case 'c_func':
await t.c();
break;
}
}
}
const bot = new Bot();
bot.process('a_func');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment