forked from RichardMcSorley/korean-dictionary-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b42ae0
commit 1e44974
Showing
15 changed files
with
351 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const kpop = require("kpop"); | ||
const { hasKoreanTXT } = require("../utils/language"); | ||
const numberHandle = require("./number"); | ||
const handle = ({ message, options, bot, prefix }) => { | ||
const usedPrefix = prefix.prefix[prefix.name]; | ||
const prefixIndex = message.content.indexOf(usedPrefix.value); | ||
const msg = message.content.slice(prefixIndex + usedPrefix.value.length); // slice of the prefix on the message | ||
const hasKOTXT = hasKoreanTXT(msg); | ||
let string; | ||
if (hasNumber) { | ||
message.lang = hasKOTXT ? "ko" : "en"; | ||
return numberHandle.handle({ message, options, bot, prefix }); | ||
} | ||
if (hasKOTXT) { | ||
string = `Romanized that's ***${kpop.romanize(msg)}***`; | ||
} else { | ||
string = `Hungulified that's ***${kpop.hangulify(msg)}***`; | ||
} | ||
if (message.channel.type === "youtube") { | ||
return message.channel.send(string); | ||
} | ||
options.setDescription(string); | ||
return message.channel.send(options); | ||
}; | ||
function hasNumber(myString) { | ||
return /\d/.test(myString); | ||
} | ||
|
||
module.exports = { | ||
handle, | ||
prefix: { | ||
"!hangul": { | ||
match: "hangul", | ||
value: "!hangul ", | ||
lang: "en", | ||
display: "lang" | ||
}, | ||
"!hungulify": { | ||
match: "hungulify", | ||
value: "!hungulify ", | ||
lang: "en", | ||
display: "lang" | ||
}, | ||
"!한굴": { | ||
match: "한굴", | ||
value: "!한굴 ", | ||
lang: "ko", | ||
display: "lang" | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const keyboard = require("gksdud"); | ||
const errorTxt = "\nEX: ```!keyboard dkssud```"; | ||
const handle = ({ message, options, bot, prefix }) => { | ||
const usedPrefix = prefix.prefix[prefix.name]; | ||
const prefixIndex = message.content.indexOf(usedPrefix.value); | ||
const msg = message.content.slice(prefixIndex + usedPrefix.value.length); // slice of the prefix on the message | ||
let string = ""; | ||
if (msg === "") { | ||
string = "Sorry you have to type something." + errorTxt; | ||
if (message.channel.type === "youtube") { | ||
return message.channel.send(string); | ||
} | ||
options.setDescription(string); | ||
return message.channel.send(options); | ||
} | ||
if (message.lang === "en") { | ||
string = "Result: " + keyboard(msg); | ||
} else { | ||
string = | ||
"Looks like you are typing in korean already. No need for me ^^" + | ||
errorTxt; | ||
} | ||
|
||
if (message.channel.type === "youtube") { | ||
return message.channel.send(string); | ||
} | ||
options.setDescription(string); | ||
return message.channel.send(options); | ||
}; | ||
|
||
module.exports = { | ||
handle, | ||
prefix: { | ||
"!keyboard": { | ||
match: "keyboard", | ||
value: "!keyboard ", | ||
lang: "en", | ||
display: true | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const namer = require("korean-name-generator"); | ||
const preString = "How about "; | ||
const sufString = " :smiley:"; | ||
const kpop = require("kpop"); | ||
const { titleCase } = require("../utils/format-text"); | ||
const handle = ({ message, options, bot, prefix }) => { | ||
const msg = message.content.toLowerCase(); // dont slice just search whole text | ||
let string = ""; | ||
if (!containsMale(msg) && !containsFemale(msg)) { | ||
return message.channel.send( | ||
"Please let me know your gender so I can give you a Korean name :wink: \nEX:```!name male|female```" | ||
); | ||
} | ||
if (containsMale(msg)) { | ||
const name = namer.generate(false); | ||
const lastname = name.substring(0, 1); | ||
const firstname = name.substring(-2); | ||
const romanized = titleCase(kpop.romanize(firstname + " " + lastname)); | ||
string = `${preString} ${name} - ${romanized}? ${sufString}`; | ||
} else if (containsFemale(msg)) { | ||
const name = namer.generate(false); | ||
const lastname = name.substring(0, 1); | ||
const firstname = name.substring(-2); | ||
const romanized = titleCase(kpop.romanize(firstname + " " + lastname)); | ||
string = `${preString} ${name} - ${romanized}? ${sufString}`; | ||
} | ||
|
||
if (message.channel.type === "youtube") { | ||
return message.channel.send(string); | ||
} | ||
return message.channel.send(string); | ||
}; | ||
const containsMale = msg => { | ||
return ( | ||
msg.includes("male") || | ||
msg.includes("boy") || | ||
msg.includes("guy") || | ||
msg.includes("man") | ||
); | ||
}; | ||
const containsFemale = msg => { | ||
return msg.includes("female") || msg.includes("girl") || msg.includes("gal"); | ||
}; | ||
module.exports = { | ||
handle, | ||
prefix: { | ||
"!name": { | ||
match: "name", | ||
value: "!name ", | ||
lang: "en", | ||
display: true | ||
}, | ||
name_me: { | ||
match: "name", | ||
value: "name me ", | ||
lang: "en", | ||
display: false | ||
}, | ||
korean_name: { | ||
match: "name", | ||
value: "name me ", | ||
lang: "en", | ||
display: false | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { numberToKorean } = require("number-to-korean"); | ||
const kpop = require("kpop"); | ||
const koreanToNumber = require("korean-numbers"); | ||
var numeral = require("numeral"); | ||
const errorTxt = "\nEX: ```!number 3000```"; | ||
const handle = ({ message, options, bot, prefix }) => { | ||
const usedPrefix = prefix.prefix[prefix.name]; | ||
const prefixIndex = message.content.indexOf(usedPrefix.value); | ||
const msg = message.content.slice(prefixIndex + usedPrefix.value.length); // slice of the prefix on the message | ||
let string = ""; | ||
if (msg === "") { | ||
string = "Sorry you have to type something." + errorTxt; | ||
if (message.channel.type === "youtube") { | ||
return message.channel.send(string); | ||
} | ||
options.setDescription(string); | ||
return message.channel.send(options); | ||
} | ||
if (message.lang === "ko") { | ||
const englishNbr = koreanToNumber.parse(msg); | ||
string = `In English **${msg}** - ${kpop.romanize( | ||
msg.replace(/\d/, "") | ||
)} is **${numeral(englishNbr).format("0,0")}**`; | ||
} else { | ||
const koreanNbr = numberToKorean(msg); | ||
string = `In Korean **${msg}** is **${koreanNbr}** - ${kpop.romanize( | ||
koreanNbr.replace(/\d/, "") | ||
)}`; | ||
} | ||
|
||
if (message.channel.type === "youtube") { | ||
return message.channel.send(string); | ||
} | ||
options.setDescription(string); | ||
return message.channel.send(options); | ||
}; | ||
|
||
module.exports = { | ||
handle, | ||
prefix: { | ||
"!number": { | ||
match: "number", | ||
value: "!number ", | ||
lang: "en", | ||
display: true | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.