Created
August 23, 2017 21:47
-
-
Save nukisashineko/56a97f4e7c611679f9b678d567560a54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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