0
0
This commit is contained in:
syuilo 2017-10-07 19:29:32 +09:00
parent b1990bc847
commit a931bcbf8d

View File

@ -50,6 +50,8 @@ class LineBot extends BotCore {
public async react(ev: any): Promise<void> {
this.replyToken = ev.replyToken;
// メッセージ
if (ev.type == 'message') {
// テキスト
if (ev.message.type == 'text') {
const res = await this.q(ev.message.text);
@ -69,6 +71,7 @@ class LineBot extends BotCore {
packageId: '4',
stickerId: stickers[Math.floor(Math.random() * stickers.length)]
}]);
}
// postback
} else if (ev.message.type == 'postback') {
const data = ev.message.postback.data;
@ -136,7 +139,7 @@ module.exports = async (app: express.Application) => {
const handler = new EventEmitter();
handler.on('message', async (ev) => {
handler.on('event', async (ev) => {
const sourceId = ev.source.userId;
const sessionId = `line-bot-sessions:${sourceId}`;
@ -198,7 +201,7 @@ module.exports = async (app: express.Application) => {
// シグネチャ比較
if (sig1 === sig2) {
req.body.events.forEach(ev => {
handler.emit(ev.type, ev);
handler.emit('event', ev);
});
res.sendStatus(200);