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-05 00:12:13 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
b2e5b74d1a16f33f4fa5f91c269d15d40e257046
b2e5b74d
2 parents
4f2ee18c
23219308
Merge branch 'kdysy1130-socket' into 'master'
ejs hotfix See merge request !7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
43 deletions
server/openAPIs/twitch_api.js
server/socket_server.js
server/openAPIs/twitch_api.js
View file @
b2e5b74
const
tmi
=
require
(
'tmi.js'
);
const
papago
=
require
(
'./openAPIs/papago_api'
)
const
ttlserver
=
require
(
'../socket_server'
)
// Define configuration options
var
opts
=
{
identity
:
{
username
:
process
.
env
.
BOT_USERNAME
,
password
:
process
.
env
.
OAUTH_TOKEN
},
channels
:
[
'bachelorchuckchuck'
]
};
// Create a client with our options
const
client
=
new
tmi
.
client
(
opts
);
// Register our event handlers (defined below)
client
.
on
(
'message'
,
onMessageHandler
);
client
.
on
(
'connected'
,
onConnectedHandler
);
// Connect to Twitch:
client
.
connect
();
// Called every time a message comes in
function
onMessageHandler
(
target
,
context
,
msg
,
self
)
{
if
(
self
)
{
return
;
}
// Ignore messages from the bot
//
const tmi = require('tmi.js');
//
const papago = require('./openAPIs/papago_api')
//
const ttlserver = require('../socket_server')
//
//
Define configuration options
//
var opts = {
//
identity: {
//
username: process.env.BOT_USERNAME,
//
password: process.env.OAUTH_TOKEN
//
},
//
channels: [
//
'bachelorchuckchuck'
//
]
//
};
//
//
Create a client with our options
//
const client = new tmi.client(opts);
//
//
Register our event handlers (defined below)
//
client.on('message', onMessageHandler);
//
client.on('connected', onConnectedHandler);
//
//
Connect to Twitch:
//
client.connect();
//
//
Called every time a message comes in
//
function onMessageHandler (target, context, msg, self) {
//
if (self) { return; } // Ignore messages from the bot
client
.
say
(
target
,
`/color `
+
changecolor
());
papago
.
detectchat
(
msg
,
client
,
target
);
//
client.say(target, `/color `+changecolor());
//
papago.detectchat(msg, client, target);
if
(
msg
==
'척척학사'
){
client
.
say
(
target
,
`안녕하세요 척척학사의 방송입니다.`
);
}
//
if(msg == '척척학사'){
//
client.say(target, `안녕하세요 척척학사의 방송입니다.`);
//
}
}
//
}
exports
.
addChannel
=
(
channel
)
=>
{
opts
.
channels
.
append
(
channel
);
}
//
exports.addChannel = (channel) =>{
//
opts.channels.append(channel);
//
}
// Called every time the bot connects to Twitch chat
function
onConnectedHandler
(
addr
,
port
)
{
console
.
log
(
`* Connected to
${
addr
}
:
${
port
}
`
);
}
//
//
Called every time the bot connects to Twitch chat
//
function onConnectedHandler (addr, port) {
//
console.log(`* Connected to ${addr}:${port}`);
//
}
...
...
server/socket_server.js
View file @
b2e5b74
...
...
@@ -3,7 +3,8 @@ const config = require('./config/config')
const
app
=
require
(
'express'
)();
const
http
=
require
(
'http'
).
Server
(
app
);
const
io
=
require
(
'socket.io'
)(
http
);
const
papago
=
require
(
'./openAPIs/papago_api'
)
const
papago
=
require
(
'./openAPIs/papago_api'
);
// const tmi = require('tmi.js');
// // Define configuration options
// var opts = {
...
...
@@ -19,12 +20,13 @@ const papago = require('./openAPIs/papago_api')
// const client = new tmi.client(opts); //twitch chatbot client
app
.
set
(
'view engine'
,
'ejs'
);
app
.
set
(
'views'
,
'./testviews'
);
app
.
set
(
'views'
,
'./
server/
testviews'
);
let
room
=
[
'streamer1'
,
'streamer2'
];
// client.opts.channels;
let
a
=
0
;
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
res
.
render
(
'chat'
);
});
...
...
Please
register
or
login
to post a comment