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-04 23:54:06 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
4f2ee18c128ed8cf1e5410d27f6632c6fb284b8c
4f2ee18c
2 parents
f56e7f50
9608fc6a
Merge branch 'kdysy1130-socket' into 'master'
change README.md See merge request !6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
31 deletions
server/README.md
server/socket_server.js
server/README.md
View file @
4f2ee18
...
...
@@ -9,6 +9,8 @@
## 실행방법
>.env파일을 만듭니다.
```
cd server
npm install pkg.json --save
...
...
server/socket_server.js
View file @
4f2ee18
...
...
@@ -4,19 +4,19 @@ const app = require('express')();
const
http
=
require
(
'http'
).
Server
(
app
);
const
io
=
require
(
'socket.io'
)(
http
);
const
papago
=
require
(
'./openAPIs/papago_api'
)
const
tmi
=
require
(
'tmi.js'
);
// 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
);
//twitch chatbot client
//
const tmi = require('tmi.js');
//
//
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); //twitch chatbot client
app
.
set
(
'view engine'
,
'ejs'
);
app
.
set
(
'views'
,
'./testviews'
);
...
...
@@ -71,28 +71,28 @@ http.listen(process.env.SOCKET_PORT, () => {
/////////////////////Twitch Bot//////////////////////////
// Register our event handlers (defined below)
client
.
on
(
'message'
,
onMessageHandler
);
client
.
on
(
'connected'
,
onConnectedHandler
);
//
//
Register our event handlers (defined below)
//
client.on('message', onMessageHandler);
//
client.on('connected', onConnectedHandler);
// Connect to Twitch:
client
.
connect
();
//
//
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
//
//
Called every time a message comes in
//
function onMessageHandler (target, context, msg, self) {
//
if (self) { return; } // Ignore messages from the bot
io
.
to
(
target
).
emit
(
'chatmessage'
,)
papago
.
detectchat
(
msg
,
client
,
target
);
//
io.to(target).emit('chatmessage',)
//
papago.detectchat(msg, client, target);
if
(
msg
==
'척척학사'
){
client
.
say
(
target
,
`안녕하세요 척척학사의 방송입니다.`
);
}
//
if(msg == '척척학사'){
//
client.say(target, `안녕하세요 척척학사의 방송입니다.`);
//
}
}
//
}
// Called every time the bot connects to Twitch chat
function
onConnectedHandler
(
addr
,
port
)
{
console
.
log
(
`*KwitchBot Connected to
${
addr
}
:
${
port
}
`
);
}
//
//
Called every time the bot connects to Twitch chat
//
function onConnectedHandler (addr, port) {
//
console.log(`*KwitchBot Connected to ${addr}:${port}`);
//
}
...
...
Please
register
or
login
to post a comment