summaryrefslogtreecommitdiff
path: root/src/api/bot/interfaces
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-10-07 19:29:32 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-10-07 19:29:32 +0900
commita931bcbf8d325a1fb7346954b20b64065052727b (patch)
tree4f5b83d1994ce3bf71d7ec2524decdb0ddaefc2f /src/api/bot/interfaces
parent:v: (diff)
downloadsharkey-a931bcbf8d325a1fb7346954b20b64065052727b.tar.gz
sharkey-a931bcbf8d325a1fb7346954b20b64065052727b.tar.bz2
sharkey-a931bcbf8d325a1fb7346954b20b64065052727b.zip
:v:
Diffstat (limited to 'src/api/bot/interfaces')
-rw-r--r--src/api/bot/interfaces/line.ts41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/api/bot/interfaces/line.ts b/src/api/bot/interfaces/line.ts
index 91240a325f..06b46c953b 100644
--- a/src/api/bot/interfaces/line.ts
+++ b/src/api/bot/interfaces/line.ts
@@ -50,25 +50,28 @@ class LineBot extends BotCore {
public async react(ev: any): Promise<void> {
this.replyToken = ev.replyToken;
- // テキスト
- if (ev.message.type == 'text') {
- const res = await this.q(ev.message.text);
+ // メッセージ
+ if (ev.type == 'message') {
+ // テキスト
+ if (ev.message.type == 'text') {
+ const res = await this.q(ev.message.text);
- if (res == null) return;
+ if (res == null) return;
- // 返信
- this.reply([{
- type: 'text',
- text: res
- }]);
- // スタンプ
- } else if (ev.message.type == 'sticker') {
- // スタンプで返信
- this.reply([{
- type: 'sticker',
- packageId: '4',
- stickerId: stickers[Math.floor(Math.random() * stickers.length)]
- }]);
+ // 返信
+ this.reply([{
+ type: 'text',
+ text: res
+ }]);
+ // スタンプ
+ } else if (ev.message.type == 'sticker') {
+ // スタンプで返信
+ this.reply([{
+ type: 'sticker',
+ 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);