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
ijunseong
2020-12-08 22:59:14 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
bd01a3cb766ec88c9df19d6c9006ad3c2ca78922
bd01a3cb
2 parents
8570beb1
f66ddf03
Merge remote-tracking branch 'upstream/master' into channel
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
12 deletions
server/env example
server/package-lock.json
server/package.json
server/socket_server.js
server/env example
View file @
bd01a3c
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 @
bd01a3c
This diff is collapsed. Click to expand it.
server/package.json
View file @
bd01a3c
...
...
@@ -15,6 +15,7 @@
"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 @
bd01a3c
...
...
@@ -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