Toggle navigation
Toggle navigation
This project
Loading...
Sign in
유명현
/
mamuri-bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
유명현
2022-05-14 19:19:29 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
541412fa8fe1fb0bc58227f3f47603cb8d434ef6
541412fa
1 parent
a762484c
Set line-bot sdk, .env
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
server/app.js
server/package-lock.json
server/app.js
View file @
541412f
var
express
=
require
(
"express"
);
var
app
=
express
();
const
express
=
require
(
"express"
);
const
line
=
require
(
"@line/bot-sdk"
);
require
(
"dotenv"
).
config
();
console
.
log
(
process
.
env
.
channelAccessToken
,
process
.
env
.
channelSecret
);
const
config
=
{
channelAccessToken
:
process
.
env
.
channelAccessToken
,
channelSecret
:
process
.
env
.
channelSecret
,
};
app
.
get
(
"/"
,
function
(
req
,
res
)
{
res
.
send
(
"<h1>hello express!</h1>"
);
const
app
=
express
();
app
.
post
(
"/webhook"
,
line
.
middleware
(
config
),
(
req
,
res
)
=>
{
Promise
.
all
(
req
.
body
.
events
.
map
(
handleEvent
)).
then
((
result
)
=>
res
.
json
(
result
)
);
});
const
client
=
new
line
.
Client
(
config
);
function
handleEvent
(
event
)
{
if
(
event
.
type
!==
"message"
||
event
.
message
.
type
!==
"text"
)
{
return
Promise
.
resolve
(
null
);
}
console
.
log
(
event
);
// push
client
.
pushMessage
(
event
.
source
.
userId
,
{
type
:
"text"
,
text
:
"hihihi"
,
});
return
client
.
replyMessage
(
event
.
replyToken
,
{
type
:
"text"
,
text
:
event
.
message
.
text
,
});
}
app
.
listen
(
3000
);
...
...
server/package-lock.json
View file @
541412f
...
...
@@ -7,7 +7,7 @@
""
:
{
"name"
:
"secondhand-noti-bot"
,
"version"
:
"1.0.0"
,
"license"
:
"
ISC
"
,
"license"
:
"
MIT
"
,
"dependencies"
:
{
"express"
:
"^4.18.1"
,
"nodemon"
:
"^2.0.16"
...
...
Please
register
or
login
to post a comment