Skip to content

Commit 93c9399

Browse files
committed
feat(command): add /give_me_id command
1 parent d791bd0 commit 93c9399

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77
- Line Messaging API Channel
88
- Edit and mv `.env.example` to `.env`
99
- RUN `npm install` and `npm run start`
10+
11+
12+
### how to get your `LINE_GROUP_ID` in .env file?
13+
14+
run this project and send `/give_me_id` to your bot.

src/service/linebot.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ bot.on('message', async function (event) {
2020
console.log('profile', await event.source.profile())
2121
console.log('replyMsg', replyMsg)
2222

23+
if (msg === '/give_me_id') {
24+
let groupId = event.source.groupId
25+
let userId = event.source.userId
26+
let replyMsg = `* groupId: ${groupId}\n* userId: ${userId}`
27+
event.reply(replyMsg).then(function (data) {
28+
console.log(replyMsg)
29+
}).catch(function (error) {
30+
if (error) {
31+
console.log('error')
32+
}
33+
})
34+
}
35+
2336
// 先拔掉這個功能避免在群組太吵
2437
// event.reply(replyMsg).then(function (data) {
2538
// console.log(replyMsg)

0 commit comments

Comments
 (0)