mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	✌️
This commit is contained in:
		
							parent
							
								
									b1990bc847
								
							
						
					
					
						commit
						a931bcbf8d
					
				
					 1 changed files with 22 additions and 19 deletions
				
			
		| 
						 | 
					@ -50,25 +50,28 @@ class LineBot extends BotCore {
 | 
				
			||||||
	public async react(ev: any): Promise<void> {
 | 
						public async react(ev: any): Promise<void> {
 | 
				
			||||||
		this.replyToken = ev.replyToken;
 | 
							this.replyToken = ev.replyToken;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// テキスト
 | 
							// メッセージ
 | 
				
			||||||
		if (ev.message.type == 'text') {
 | 
							if (ev.type == 'message') {
 | 
				
			||||||
			const res = await this.q(ev.message.text);
 | 
								// テキスト
 | 
				
			||||||
 | 
								if (ev.message.type == 'text') {
 | 
				
			||||||
 | 
									const res = await this.q(ev.message.text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (res == null) return;
 | 
									if (res == null) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// 返信
 | 
									// 返信
 | 
				
			||||||
			this.reply([{
 | 
									this.reply([{
 | 
				
			||||||
				type: 'text',
 | 
										type: 'text',
 | 
				
			||||||
				text: res
 | 
										text: res
 | 
				
			||||||
			}]);
 | 
									}]);
 | 
				
			||||||
		// スタンプ
 | 
								// スタンプ
 | 
				
			||||||
		} else if (ev.message.type == 'sticker') {
 | 
								} else if (ev.message.type == 'sticker') {
 | 
				
			||||||
			// スタンプで返信
 | 
									// スタンプで返信
 | 
				
			||||||
			this.reply([{
 | 
									this.reply([{
 | 
				
			||||||
				type: 'sticker',
 | 
										type: 'sticker',
 | 
				
			||||||
				packageId: '4',
 | 
										packageId: '4',
 | 
				
			||||||
				stickerId: stickers[Math.floor(Math.random() * stickers.length)]
 | 
										stickerId: stickers[Math.floor(Math.random() * stickers.length)]
 | 
				
			||||||
			}]);
 | 
									}]);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		// postback
 | 
							// postback
 | 
				
			||||||
		} else if (ev.message.type == 'postback') {
 | 
							} else if (ev.message.type == 'postback') {
 | 
				
			||||||
			const data = ev.message.postback.data;
 | 
								const data = ev.message.postback.data;
 | 
				
			||||||
| 
						 | 
					@ -136,7 +139,7 @@ module.exports = async (app: express.Application) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const handler = new EventEmitter();
 | 
						const handler = new EventEmitter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handler.on('message', async (ev) => {
 | 
						handler.on('event', async (ev) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const sourceId = ev.source.userId;
 | 
							const sourceId = ev.source.userId;
 | 
				
			||||||
		const sessionId = `line-bot-sessions:${sourceId}`;
 | 
							const sessionId = `line-bot-sessions:${sourceId}`;
 | 
				
			||||||
| 
						 | 
					@ -198,7 +201,7 @@ module.exports = async (app: express.Application) => {
 | 
				
			||||||
		// シグネチャ比較
 | 
							// シグネチャ比較
 | 
				
			||||||
		if (sig1 === sig2) {
 | 
							if (sig1 === sig2) {
 | 
				
			||||||
			req.body.events.forEach(ev => {
 | 
								req.body.events.forEach(ev => {
 | 
				
			||||||
				handler.emit(ev.type, ev);
 | 
									handler.emit('event', ev);
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			res.sendStatus(200);
 | 
								res.sendStatus(200);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue