Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이준성
/
khuwitch
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
김대연
2020-12-08 22:49:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f66ddf03b44f775ead3bae7473593201cada93e4
f66ddf03
1 parent
3151102f
Update channel list API
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
13 deletions
server/env example
server/package-lock.json
server/package.json
server/socket_server.js
server/env example
View file @
f66ddf0
FRONT_URI =
FRONT_PORT =
HOST_URI = [twitch end point url]
SOCKET_PORT= [backend socket server port]
TWITCH_CLIENT= [twitch dev client id]
...
...
server/package-lock.json
View file @
f66ddf0
This diff is collapsed. Click to expand it.
server/package.json
View file @
f66ddf0
...
...
@@ -10,11 +10,12 @@
"author"
:
"Daeyeonkim97"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"cors"
:
"^2.8.5"
,
"axios"
:
"^0.21.0"
,
"cors"
:
"^2.8.5"
,
"dotenv"
:
"^8.2.0"
,
"ejs"
:
"^3.1.5"
,
"express"
:
"^4.17.1"
,
"pkg.json"
:
"^2.0.8"
,
"request"
:
"^2.88.2"
,
"socket.io"
:
"^3.0.3"
,
"tmi.js"
:
"^1.5.0"
...
...
server/socket_server.js
View file @
f66ddf0
...
...
@@ -19,7 +19,7 @@ var opts = {
username
:
process
.
env
.
BOT_USERNAME
,
password
:
process
.
env
.
OAUTH_TOKEN
},
channels
:
[
"tmwardo"
]
channels
:
[]
};
// Create a client with our options
var
client
=
new
tmi
.
client
(
opts
);
//twitch chatbot client
...
...
@@ -31,20 +31,15 @@ app.use(bodyParser.json());
app
.
set
(
'view engine'
,
'ejs'
);
app
.
set
(
'views'
,
'./testviews'
);
// client.opts.channels;
let
a
=
0
;
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
res
.
render
(
'chat'
);
});
app
.
get
(
'/list'
,(
req
,
res
)
=>
{
var
result
=
[]
for
(
var
i
=
0
;
i
<
client
.
channels
.
length
;
i
++
){
result
.
push
(
client
.
channels
[
i
].
slice
(
1
))
}
res
.
send
(
result
)
app
.
get
(
'/channels'
,(
req
,
res
)
=>
{
//console.log(channels)
res
.
send
(
channels
)
});
app
.
post
(
'/jointest'
,
async
(
req
,
res
)
=>
{
...
...
@@ -52,8 +47,10 @@ app.post('/jointest',async (req,res)=>{
JoinChannel
(
req
.
body
.
streamer
);
res
.
send
(
req
.
body
.
streamer
)
});
console
.
log
(
`https://id.twitch.tv/oauth2/authorize?response_type=code&approval_prompt=auto&redirect_uri=
${
process
.
env
.
HOST_URI
+
':'
+
process
.
env
.
SOCKET_PORT
}
/join&client_id=
${
process
.
env
.
TWITCH_CLIENT
}
`
)
////////////////////////oauth////////////////////////
var
channels
=
[]
const
axios
=
require
(
'axios'
)
app
.
get
(
'/oauth'
,(
req
,
res
)
=>
{
let
codeAddr
=
`https://id.twitch.tv/oauth2/authorize?response_type=code&approval_prompt=auto&redirect_uri=
${
process
.
env
.
HOST_URI
+
':'
+
process
.
env
.
SOCKET_PORT
}
/join&client_id=
${
process
.
env
.
TWITCH_CLIENT
}
`
...
...
@@ -72,7 +69,17 @@ app.get('/join', async (req,res)=>{
}
).
then
(
resp2
=>
{
JoinChannel
(
resp2
.
data
.
login
)
res
.
redirect
(
"http://localhost:8000?authenticated=true"
)
// 이거 프론트 유알엘임
axios
.
get
(
`https://api.twitch.tv/kraken/channels/
${
resp2
.
data
.
user_id
}
`
,
{
headers
:{
'Accept'
:
'application/vnd.twitchtv.v5+json'
,
'Client-ID'
:
process
.
env
.
TWITCH_CLIENT
}
}
).
then
(
resp3
=>
{
channels
.
push
(
resp3
.
data
);
})
res
.
redirect
(
`
${
process
.
env
.
FRONT_URI
}
:
${
process
.
env
.
FRONT_PORT
}
/?authenticated=true`
)
// 이거 프론트 유알엘임
})
})
...
...
Please
register
or
login
to post a comment