Showing
10 changed files
with
144 additions
and
37 deletions
1 | const translatte = require('translatte'); | 1 | const translatte = require('translatte'); |
2 | 2 | ||
3 | -global.trans_var ='en'; | 3 | +global.trans_var = 'en'; |
4 | 4 | ||
5 | exports.run = async (client, msg, args, prefix) => { | 5 | exports.run = async (client, msg, args, prefix) => { |
6 | if (args[0]) { // 명령어 뒤에 입력값이 있을 경우 (ex. !<명령어> <채팅>) | 6 | if (args[0]) { // 명령어 뒤에 입력값이 있을 경우 (ex. !<명령어> <채팅>) |
7 | const word = args.join(' '); | 7 | const word = args.join(' '); |
8 | 8 | ||
9 | - if(trans_var=='en'){ | 9 | + if (trans_var == 'en') { |
10 | - en_translate(word).then(transed_text=> {msg.reply(transed_text)}) | 10 | + en_translate(word).then(transed_text => { msg.reply(transed_text); }); |
11 | } | 11 | } |
12 | 12 | ||
13 | - else if(trans_var=='jp'){ | 13 | + else if (trans_var == 'jp') { |
14 | - jp_translate(word).then(transed_text=> {msg.reply(transed_text)}) | 14 | + jp_translate(word).then(transed_text => { msg.reply(transed_text); }); |
15 | } | 15 | } |
16 | 16 | ||
17 | - else if(trans_var=="ko"){ | 17 | + else if (trans_var == "ko") { |
18 | - ko_translate(word).then(transed_text=> {msg.reply(transed_text)}) | 18 | + ko_translate(word).then(transed_text => { msg.reply(transed_text); }); |
19 | } | 19 | } |
20 | - } | 20 | + } |
21 | else { | 21 | else { |
22 | msg.reply("메세지를 다시 확인해주세요."); | 22 | msg.reply("메세지를 다시 확인해주세요."); |
23 | } | 23 | } |
24 | }; | 24 | }; |
25 | 25 | ||
26 | 26 | ||
27 | -function en_translate(distext){ | 27 | +function en_translate(distext) { |
28 | - return translatte(String(distext), {to: 'en'}) | 28 | + return translatte(String(distext), { to: 'en' }) |
29 | - .then(res => { | 29 | + .then(res => { |
30 | - return res.text; | 30 | + return res.text; |
31 | - }).catch(err => { | 31 | + }).catch(err => { |
32 | - console.error(err); | 32 | + console.error(err); |
33 | - throw err; | 33 | + throw err; |
34 | - }); | 34 | + }); |
35 | } | 35 | } |
36 | 36 | ||
37 | -function jp_translate(distext){ | 37 | +function jp_translate(distext) { |
38 | - return translatte(String(distext), {to: 'ja'}) | 38 | + return translatte(String(distext), { to: 'ja' }) |
39 | - .then(res => { | 39 | + .then(res => { |
40 | - return res.text; | 40 | + return res.text; |
41 | - }).catch(err => { | 41 | + }).catch(err => { |
42 | - console.error(err); | 42 | + console.error(err); |
43 | - throw err; | 43 | + throw err; |
44 | - }); | 44 | + }); |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
48 | -function ko_translate(distext){ | 48 | +function ko_translate(distext) { |
49 | - return translatte(String(distext), {to: 'ko'}) | 49 | + return translatte(String(distext), { to: 'ko' }) |
50 | - .then(res => { | 50 | + .then(res => { |
51 | - return res.text; | 51 | + return res.text; |
52 | - }).catch(err => { | 52 | + }).catch(err => { |
53 | - console.error(err); | 53 | + console.error(err); |
54 | - throw err; | 54 | + throw err; |
55 | - }); | 55 | + }); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
... | @@ -63,4 +63,6 @@ exports.config = { | ... | @@ -63,4 +63,6 @@ exports.config = { |
63 | category: ['Translate'], | 63 | category: ['Translate'], |
64 | des: ['채팅 내용에 대한 검색결과를 보여줍니다.'], | 64 | des: ['채팅 내용에 대한 검색결과를 보여줍니다.'], |
65 | use: ['!번역 <채팅>'] | 65 | use: ['!번역 <채팅>'] |
66 | + | ||
66 | }; | 67 | }; |
68 | + | ... | ... |
LICENSE.txt
0 → 100644
1 | +MIT LicenseCopyright (c) 2022 gunhee park and other contributors | ||
2 | + | ||
3 | +Permission is hereby granted, free of charge, to any person | ||
4 | +obtaining a copy of this software and associated documentation | ||
5 | +files (the "Software"), to deal in the Software without | ||
6 | +restriction, including without limitation the rights to use, | ||
7 | +copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
8 | +copies of the Software, and to permit persons to whom the | ||
9 | +Software is furnished to do so, subject to the following | ||
10 | +conditions: | ||
11 | + | ||
12 | +The above copyright notice and this permission notice shall be | ||
13 | +included in all copies or substantial portions of the Software. | ||
14 | + | ||
15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
16 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
17 | +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
18 | +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
19 | +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
20 | +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
21 | +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
22 | +OTHER DEALINGS IN THE SOFTWARE. | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | # Emon_Bot | 1 | # Emon_Bot |
2 | + | ||
3 | +## About The Project | ||
4 | + | ||
5 | +* 도라에몽처럼 각종 편의기능을 통합적(All-in-One)으로 서비스할 수 있는 디스코드 챗봇입니다. | ||
6 | + | ||
7 | +* 현재 제공하고 있는 기능으로는 아래 세 가지가 있습니다. | ||
8 | +- 이미지 텍스트 인식 (OCR) | ||
9 | +- 언어번역 | ||
10 | +- 필기구 가격비교 | ||
11 | + | ||
12 | +## Built With | ||
13 | + | ||
14 | +* [Node.js](https://nodejs.org/ko/) | ||
15 | +* [discord.js](https://discord.js.org) | ||
16 | +* [puppeteer](https://pptr.dev/) | ||
17 | +* [tesseract.js](https://tesseract.projectnaptha.com/) | ||
18 | +* [translatte](https://www.npmjs.com/package/translatte) | ||
19 | + | ||
20 | +## Getting Started | ||
21 | + | ||
22 | +* [봇 초대 링크](https://discord.com/api/oauth2/authorize?client_id=974262592388337695&permissions=8&scope=bot) | ||
23 | + | ||
24 | +* aws EC2 사용해서 배포 | ||
25 | + | ||
26 | +## Installation | ||
27 | + | ||
28 | +1. Clone the repo | ||
29 | + ``` | ||
30 | + git clone http://khuhub.khu.ac.kr/2017103984/emon_bot.git | ||
31 | + ``` | ||
32 | +2. Install NPM packages | ||
33 | + ``` | ||
34 | + npm install | ||
35 | + ``` | ||
36 | +3. 디스코드 회원가입 | ||
37 | +4. [Discord Developer Portal](https://discord.com/developers/applications)에 들어가서 New Application을 생성 | ||
38 | +5. Application 생성 후 왼쪽에 보이는 사이드바에서 Bot을 눌러서 디스코드 봇 생성 | ||
39 | +6. 디스코드 봇 생성 후 토큰 복사 (외부 유출 주의) | ||
40 | + | ||
41 | +7. 다시 왼쪽 사이드바에서 OAuth2를 눌러 들어간 후 SCOPES에서 bot을 체크 | ||
42 | +8. 생성되는 주소로 이동해서 디스코드 봇을 본인의 서버로 초대 | ||
43 | + | ||
44 | +## Usage | ||
45 | + | ||
46 | +* Command List | ||
47 | +**!도움말** - 봇에 대한 명령어 리스트들을 불러옵니다. | ||
48 | +**!도움말** <명령어> - <명령어>에 해당하는 명령어의 사용방법을 조회합니다. | ||
49 | +**!ocr** <사용 언어> - 이미지를 첨부하고 <사용 언어>를 입력하면, 이미지에 있는 텍스트를 추출합니다. | ||
50 | +**!번역** <채팅> - <채팅>에 대한 번역결과를 보여줍니다. | ||
51 | +**!나라** - 봇이 띄워주는 버튼을 눌러서 번역할 언어(나라)를 선택합니다. | ||
52 | +**!문구** <채팅> - <채팅>에 대한 검색결과를 보여줍니다. | ||
53 | + | ||
54 | +* 사용 예시 | ||
55 | +**도움말 명령어 실행화면** | ||
56 | + | ||
57 | +**ocr 명령어 실행화면** | ||
58 | + | ||
59 | +**번역, 나라 명령어 실행화면** | ||
60 | + | ||
61 | +**문구 명령어 실행화면** | ||
62 | + | ||
63 | + | ||
64 | +## Contributing | ||
65 | + | ||
66 | +프로젝트에 기여하고 싶으신 분들은 아래 절차를 따라주시기 바랍니다. | ||
67 | + | ||
68 | +1. 프로젝트 fork | ||
69 | +2. feature branch 생성 (git checkout -b feature/name) | ||
70 | +3. commit (git commit -m "Add feature") | ||
71 | +4. push (git push origin feature/name) | ||
72 | +5. pull request 생성 | ||
73 | + | ||
74 | +## License | ||
75 | + | ||
76 | +MIT 라이센스 아래 사용 가능합니다. LICENSE.txt를 통해 자세한 정보를 확인하세요. | ||
77 | + | ||
78 | +## Contact | ||
79 | + | ||
80 | +* 김연수: deathcat@khu.ac.kr | ||
81 | +* 노영우: dndn1544@khu.ac.kr | ||
82 | +* 박건희: wm5256@khu.ac.kr | ||
83 | + | ||
84 | +* Project Link: http://khuhub.khu.ac.kr/2017103984/emon_bot.git | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
eng.traineddata
deleted
100644 → 0
This file is too large to display.
... | @@ -43,4 +43,4 @@ client.on('messageCreate', msg => { | ... | @@ -43,4 +43,4 @@ client.on('messageCreate', msg => { |
43 | } | 43 | } |
44 | }); | 44 | }); |
45 | 45 | ||
46 | -client.login(token); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
46 | +client.login(token); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
jpn.traineddata
deleted
100644 → 0
This file is too large to display.
kor.traineddata
deleted
100644 → 0
This file is too large to display.
This diff is collapsed. Click to expand it.
1 | { | 1 | { |
2 | "dependencies": { | 2 | "dependencies": { |
3 | - "discord.js": "^13.6.0", | 3 | + "discord.js": "^13.8.0", |
4 | - "puppeteer": "^14.1.1", | 4 | + "puppeteer": "^14.3.0", |
5 | - "puppeteer-core": "^14.1.1", | ||
6 | "tesseract.js": "^2.1.5", | 5 | "tesseract.js": "^2.1.5", |
7 | "translatte": "^3.0.1" | 6 | "translatte": "^3.0.1" |
8 | } | 7 | } | ... | ... |
-
Please register or login to post a comment