Skip to content

Commit

Permalink
chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
dana8123 committed Jul 24, 2021
1 parent 28f8154 commit 3658df6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
13 changes: 12 additions & 1 deletion controllers/chatController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ const { User } = require("../schema/user");

//채팅 리스트
exports.chatList = async (req, res) => {
let targets = [];
const user = res.locals.user;

let targets = [
{
soldBy: user.nickname,
_id: 1,
title: `운영자`,
nickname: `오쿠`,
sellerunique: `60a4f2d3de0f1132fe023a1f`,
soldById: user._id,
},
];
// 낙찰 완료된 상품
const product = await Product.find(
{ onSale: false },
Expand Down Expand Up @@ -46,6 +56,7 @@ exports.chatList = async (req, res) => {
// // 판매자와 구매자에게 메일보내주기
// nodemailer(sellerEmail.email, subject);
// nodemailer(buyerEmail.email, subject);
console.log("TARGET =>", targets);
res.send({ targets });
};

Expand Down
24 changes: 22 additions & 2 deletions socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,29 @@ module.exports = (server) => {
});
if (data.room === `${undefined}-${undefined}-${undefined}`) {
content.msg = "거래 이후 채팅 가능합니다.";
} else {
await content.save();
}
//챗봇
if (data.product === "1") {
if (data.msg.includes("사용법")) {
content.msg =
"오타쿠 굿즈를 판매하고싶다면, \n왼쪽 상단의 물건등록을 눌러주세요.\n 구매하려면 경매물품을 최고가에 입찰해봅시다!";
}
if (data.msg.includes("신고")) {
content.msg =
"현재 신고관련 기능은 준비중입니다. \n경매 물건의 이름과 신고대상의 닉네임을\n itsoku@naver.com 으로 보내주시면 확인 후 블락하고있습니다.";
}
if (data.msg.includes("개발자")) {
content.msg =
"저희에게 관심이 있으시다구요?! https://www.notion.so/90bbb2e5d07941a3a46370e5333c7556";
}
if (data.msg.includes("건의")) {
content.msg =
"어떤점이 불편하셨나요? itsoku@naver.com 으로 보내주시면 귀담아 듣겠습니다.";
}
}
console.log(data);
await content.save();

// 저장한 데이터를 클라이언트에게 receive라는 emit으로 전송
chatSpace.to(room).emit("receive", content);
//접속해제 시 방을 떠나는 코드
Expand Down

0 comments on commit 3658df6

Please sign in to comment.