Showing
4 changed files
with
22 additions
and
13 deletions
This diff is collapsed. Click to expand it.
... | @@ -10,11 +10,12 @@ | ... | @@ -10,11 +10,12 @@ |
10 | "author": "Daeyeonkim97", | 10 | "author": "Daeyeonkim97", |
11 | "license": "ISC", | 11 | "license": "ISC", |
12 | "dependencies": { | 12 | "dependencies": { |
13 | - "cors": "^2.8.5", | ||
14 | "axios": "^0.21.0", | 13 | "axios": "^0.21.0", |
14 | + "cors": "^2.8.5", | ||
15 | "dotenv": "^8.2.0", | 15 | "dotenv": "^8.2.0", |
16 | "ejs": "^3.1.5", | 16 | "ejs": "^3.1.5", |
17 | "express": "^4.17.1", | 17 | "express": "^4.17.1", |
18 | + "pkg.json": "^2.0.8", | ||
18 | "request": "^2.88.2", | 19 | "request": "^2.88.2", |
19 | "socket.io": "^3.0.3", | 20 | "socket.io": "^3.0.3", |
20 | "tmi.js": "^1.5.0" | 21 | "tmi.js": "^1.5.0" | ... | ... |
... | @@ -19,7 +19,7 @@ var opts = { | ... | @@ -19,7 +19,7 @@ var opts = { |
19 | username: process.env.BOT_USERNAME, | 19 | username: process.env.BOT_USERNAME, |
20 | password: process.env.OAUTH_TOKEN | 20 | password: process.env.OAUTH_TOKEN |
21 | }, | 21 | }, |
22 | - channels: ["tmwardo"] | 22 | + channels: [] |
23 | }; | 23 | }; |
24 | // Create a client with our options | 24 | // Create a client with our options |
25 | var client = new tmi.client(opts); //twitch chatbot client | 25 | var client = new tmi.client(opts); //twitch chatbot client |
... | @@ -31,20 +31,15 @@ app.use(bodyParser.json()); | ... | @@ -31,20 +31,15 @@ app.use(bodyParser.json()); |
31 | app.set('view engine', 'ejs'); | 31 | app.set('view engine', 'ejs'); |
32 | app.set('views', './testviews'); | 32 | app.set('views', './testviews'); |
33 | 33 | ||
34 | -// client.opts.channels; | ||
35 | -let a = 0; | ||
36 | 34 | ||
37 | 35 | ||
38 | app.get('/', (req, res) => { | 36 | app.get('/', (req, res) => { |
39 | res.render('chat'); | 37 | res.render('chat'); |
40 | }); | 38 | }); |
41 | 39 | ||
42 | -app.get('/list',(req,res) => { | 40 | +app.get('/channels',(req,res) => { |
43 | - var result = [] | 41 | + //console.log(channels) |
44 | - for (var i = 0; i<client.channels.length; i++){ | 42 | + res.send(channels) |
45 | - result.push(client.channels[i].slice(1)) | ||
46 | - } | ||
47 | - res.send(result) | ||
48 | }); | 43 | }); |
49 | 44 | ||
50 | app.post('/jointest',async (req,res)=>{ | 45 | app.post('/jointest',async (req,res)=>{ |
... | @@ -52,8 +47,10 @@ app.post('/jointest',async (req,res)=>{ | ... | @@ -52,8 +47,10 @@ app.post('/jointest',async (req,res)=>{ |
52 | JoinChannel(req.body.streamer); | 47 | JoinChannel(req.body.streamer); |
53 | res.send(req.body.streamer) | 48 | res.send(req.body.streamer) |
54 | }); | 49 | }); |
55 | -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}`) | ||
56 | ////////////////////////oauth//////////////////////// | 50 | ////////////////////////oauth//////////////////////// |
51 | + | ||
52 | +var channels = [] | ||
53 | + | ||
57 | const axios = require('axios') | 54 | const axios = require('axios') |
58 | app.get('/oauth',(req,res)=>{ | 55 | app.get('/oauth',(req,res)=>{ |
59 | 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}` | 56 | 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)=>{ | ... | @@ -72,7 +69,17 @@ app.get('/join', async (req,res)=>{ |
72 | } | 69 | } |
73 | ).then(resp2=>{ | 70 | ).then(resp2=>{ |
74 | JoinChannel(resp2.data.login) | 71 | JoinChannel(resp2.data.login) |
75 | - res.redirect("http://localhost:8000?authenticated=true") // 이거 프론트 유알엘임 | 72 | + axios.get(`https://api.twitch.tv/kraken/channels/${resp2.data.user_id}`, |
73 | + { | ||
74 | + headers:{ | ||
75 | + 'Accept' : 'application/vnd.twitchtv.v5+json', | ||
76 | + 'Client-ID' : process.env.TWITCH_CLIENT | ||
77 | + } | ||
78 | + } | ||
79 | + ).then(resp3=>{ | ||
80 | + channels.push(resp3.data); | ||
81 | + }) | ||
82 | + res.redirect(`${process.env.FRONT_URI}:${process.env.FRONT_PORT}/?authenticated=true`) // 이거 프론트 유알엘임 | ||
76 | }) | 83 | }) |
77 | }) | 84 | }) |
78 | 85 | ... | ... |
-
Please register or login to post a comment