mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add command with basic russian phonetic translation for a given input text
This commit is contained in:
parent
202513ee3e
commit
0d313b7b0a
|
@ -246,6 +246,24 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
|
|||
return
|
||||
}
|
||||
|
||||
case "phonetic":
|
||||
if msgLen < 2 {
|
||||
common.Send(target, "Not enough arguments provided. Usage: ()phonetic <text>. ()help phonetic for more info", app.TwitchClient)
|
||||
return
|
||||
} else {
|
||||
commands.Phonetic(target, message.Message[10:len(message.Message)], app.TwitchClient)
|
||||
return
|
||||
}
|
||||
|
||||
case "ph":
|
||||
if msgLen < 2 {
|
||||
common.Send(target, "Not enough arguments provided. Usage: ()ph <text>. ()help ph for more info", app.TwitchClient)
|
||||
return
|
||||
} else {
|
||||
commands.Phonetic(target, message.Message[4:len(message.Message)], app.TwitchClient)
|
||||
return
|
||||
}
|
||||
|
||||
// ()weather <location>
|
||||
case "weather":
|
||||
if msgLen == 1 {
|
||||
|
@ -492,6 +510,8 @@ var helpText = map[string]string{
|
|||
"help": "Returns more information about a command and its usage. 4Head Example usage: ()help <command name>",
|
||||
"ping": "Hopefully returns a Pong! monkaS",
|
||||
"preview": "Returns a link to an (almost) live screenshot of a live channel. Alias: preview, thumbnail. Example usage: ()preview <channel>",
|
||||
"phonetic": "Translates the input to the text equivalent on a phonetic russian keyboard layout. Layout and general functionality is the same as https://russian.typeit.org/",
|
||||
"ph": "Translates the input to the text equivalent on a phonetic russian keyboard layout. Layout and general functionality is the same as https://russian.typeit.org/",
|
||||
"thumbnail": "Returns a link to an (almost) live screenshot of a live channel. Alias: preview, thumbnail. Example usage: ()thumbnail <channel>",
|
||||
"tweet": "Returns the latest tweet for a provided user. Example usage: ()tweet <username>",
|
||||
"seventv": "Returns the search URL for a given SevenTV emote. Aliases: seventv, 7tv. Example usage: ()seventv FeelsDankMan",
|
||||
|
|
94
internal/commands/phonetic.go
Normal file
94
internal/commands/phonetic.go
Normal file
|
@ -0,0 +1,94 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v3"
|
||||
"github.com/lyx0/nourybot/internal/common"
|
||||
)
|
||||
|
||||
var cm = map[string]string{
|
||||
"`": "ё",
|
||||
"~": "Ё",
|
||||
"=": "ъ",
|
||||
"+": "Ъ",
|
||||
"[": "ю",
|
||||
"]": "щ",
|
||||
`\`: "э",
|
||||
"{": "Ю",
|
||||
"}": "Щ",
|
||||
"|": "Э",
|
||||
";": "ь",
|
||||
":": "Ь",
|
||||
"'": "ж",
|
||||
`"`: "Ж",
|
||||
|
||||
"q": "я",
|
||||
"w": "ш",
|
||||
"e": "е",
|
||||
"r": "р",
|
||||
"t": "т",
|
||||
"y": "ы",
|
||||
"u": "у",
|
||||
"i": "и",
|
||||
"o": "о",
|
||||
"p": "п",
|
||||
"a": "а",
|
||||
"s": "с",
|
||||
"d": "д",
|
||||
"f": "ф",
|
||||
"g": "г",
|
||||
"h": "ч",
|
||||
"j": "й",
|
||||
"k": "к",
|
||||
"l": "л",
|
||||
"z": "з",
|
||||
"x": "х",
|
||||
"c": "ц",
|
||||
"v": "в",
|
||||
"b": "б",
|
||||
"n": "н",
|
||||
"m": "м",
|
||||
"Q": "Я",
|
||||
"W": "Ш",
|
||||
"E": "Е",
|
||||
"R": "Р",
|
||||
"T": "Т",
|
||||
"Y": "Ы",
|
||||
"U": "У",
|
||||
"I": "И",
|
||||
"O": "О",
|
||||
"P": "П",
|
||||
"A": "А",
|
||||
"S": "С",
|
||||
"D": "Д",
|
||||
"F": "Ф",
|
||||
"G": "Г",
|
||||
"H": "Ч",
|
||||
"J": "Й",
|
||||
"K": "К",
|
||||
"L": "Л",
|
||||
"Z": "З",
|
||||
"X": "Х",
|
||||
"C": "Ц",
|
||||
"V": "В",
|
||||
"B": "Б",
|
||||
"N": "Н",
|
||||
"M": "М",
|
||||
}
|
||||
|
||||
func Phonetic(target, message string, tc *twitch.Client) {
|
||||
var ts string
|
||||
|
||||
for _, c := range message {
|
||||
if _, ok := cm[string(c)]; ok {
|
||||
ts = ts + cm[string(c)]
|
||||
} else {
|
||||
ts = ts + string(c)
|
||||
|
||||
}
|
||||
//ts = append(ts, cm[string(c)])
|
||||
}
|
||||
|
||||
common.Send(target, fmt.Sprint(ts), tc)
|
||||
}
|
Loading…
Reference in a new issue