diff --git a/cmd/bot/commands.go b/cmd/bot/commands.go index ea563ec..d6166d8 100644 --- a/cmd/bot/commands.go +++ b/cmd/bot/commands.go @@ -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 . ()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 . ()help ph for more info", app.TwitchClient) + return + } else { + commands.Phonetic(target, message.Message[4:len(message.Message)], app.TwitchClient) + return + } + // ()weather 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 ", "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 ", + "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 ", "tweet": "Returns the latest tweet for a provided user. Example usage: ()tweet ", "seventv": "Returns the search URL for a given SevenTV emote. Aliases: seventv, 7tv. Example usage: ()seventv FeelsDankMan", diff --git a/internal/commands/phonetic.go b/internal/commands/phonetic.go new file mode 100644 index 0000000..682619b --- /dev/null +++ b/internal/commands/phonetic.go @@ -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) +}