diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 723ef36..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea \ No newline at end of file diff --git a/README.md b/README.md index e69de29..01d6dc9 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Kara has been moved to luna-development core repository. +This repository is only for issues. \ No newline at end of file diff --git a/addReactions.html b/addReactions.html deleted file mode 100644 index f299267..0000000 --- a/addReactions.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - Kara - Add reponses - - - - - - - - -
-
- - {{ this.name }} -
- -
-
-
Add Reaction
-
- - -
-
- - -
-
- - (Wildcards: $username$, $botname$) - -
- -
-
-
-
-
-
- - -
-
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/addReponse.js b/addReponse.js deleted file mode 100644 index e924122..0000000 --- a/addReponse.js +++ /dev/null @@ -1,85 +0,0 @@ -let responses = new Vue({ - el: '#kara', - data: { - name: 'Kara', - activeTheme: 'slate', - addModal: { - includeAll: false, - keywords: 'keyword', - responses: [ - 'Answer #1' - ] - }, - defaultAddModal: { - includeAll: false, - keywords: 'keyword', - responses: [ - 'Answer #1' - ] - } - }, - mounted() { - this.addModal = this.defaultAddModal; - }, - methods: { - addMessage(body, bot, me = false) { - this.messages.push({ - body: body, - bot: bot, - command: body.search('/') === 0, - me: me, - time: Date.now() - }) - }, - addResponseToInput() { - this.addModal.responses.push(''); - }, - addNewReaction() { - let includeAll = this.addModal.includeAll; - let keywords = this.addModal.keywords.split(','); - let responses = this.addModal.responses; - - let newReaction = { - includeAll: includeAll, - keywords: keywords, - responses: responses - }; - - axios.post('/reactions/create', { - reaction: newReaction - }).then((response) => { - alertify.notify('Reaction saved!', 'success'); - this.addModal = this.defaultAddModal; - }).catch((error) => { - console.log(error); - alertify.notify(error, 'danger'); - }); - }, - cleanupMessage(message) { - message = message.toLowerCase(); - return message.replace('?', '') - .replace('!', '') - .replace('.', '') - .replace(',', '') - .replace('-', '') - .replace('_', '') - .replace('#', '') - .replace('\'', '') - .replace('"', '') - .replace('+', '') - .replace('*', '') - .replace('ยง', '') - .replace('$', '') - .replace('%', '') - .replace('&', '') - .replace('/', '') - .replace('(', '') - .replace(')', '') - .replace('=', '') - .replace('\\', '') - .replace('@', '') - .replace('~', '') - .replace('โ€ฆ', ''); - } - } -}); diff --git a/app.css b/app.css deleted file mode 100644 index 2d946a7..0000000 --- a/app.css +++ /dev/null @@ -1,119 +0,0 @@ -body { - margin: 15px; - padding: 0; -} - -#kara { - margin: 0; - padding: 0; - width: auto; -} - -@media (min-width: 40em) { - #kara, - #kara-banner, - #chatbox-wrapper { - margin-left: auto; - margin-right: auto; - padding: 0; - width: 40em; - } -} - -.message { - color: black; - padding: 10px; - margin-bottom: 5px; - min-width: 55%; - max-width: 80%; -} - -img.message-image { - max-width: 60%; - border-radius: 0 15px 15px 15px; - - margin-bottom: 5px; - clear: top; -} - -.bot-message { - border-radius: 0 15px 15px 15px; - background-color: lightgreen; -} - -.user-message { - border-radius: 15px 0 15px 15px; - background-color: lightblue; -} - -#chat-box { - margin-top: 4em; - padding-right: 15px; - overflow-y: scroll; - height: 65vh; - padding-bottom: 2em; -} - -#chatbox-wrapper { - position: fixed; - padding: 1em; - bottom: 0; - left: 0; - right: 0; -} - -#kara-banner { - position: fixed; - height: 3.2em; - top: 0; - left: 0; - right: 0; - text-align: center; - padding: 0.7em; -} - -#kara-banner .btn, .add-response-input-button { - margin-top: -0.3em; -} - -.response-input { - margin-bottom: 3px; -} - -.form-button { - width: 100%; -} - -.command-message { - color: grey; -} - -.command-message::before { - content: '$: '; -} - -.header-logo { - max-height: 32px; - max-width: 32px; - width: 32px; - height: 32px; - margin-right: 5px; -} - -.me-message { - background-color: orange; -} - -#addForm { - margin-top: 60px; -} - -.fa-check-circle { - color: green; -} - -.message-container { - overflow-y: auto; - overflow-x: hidden; - max-height: 300px -} diff --git a/app.js b/app.js deleted file mode 100644 index c2a2097..0000000 --- a/app.js +++ /dev/null @@ -1,1044 +0,0 @@ -let kara = new Vue({ - el: '#kara', - data: { - features: { - changeName: false, - themes: false, - setNameAtStart: true - }, - documentation: '', - messages: [], - talk: false, - lastMessage: null, - lastMessageData: {}, - name: 'Kara', - location: null, - chatbox: null, - isTyping: false, - askedForName: false, - awaitTodo: false, - username: '', - themes: null, - activeTheme: 'slate', - addModal: { - includeAll: false, - keywords: '', - responses: [ - 'Answer #1' - ] - }, - settingsModal: { - name: null, - username: null, - location: '' - }, - todos: [], - reactions: [] - }, - mounted() { - this.getSavedData(); - this.getReactions(); - this.getDocumentation(); - - if (this.features.themes) { - this.getBootswatchThemes(); - } - - this.settingsModal = { - name: this.name, - username: this.username, - location: this.location - }; - - if (!this.username || this.username === "null") { - this.initialGreeting(); - - if (this.features.setNameAtStart) { - this.askForName(); - } - - this.stopTyping(); - } else { - this.welcomeBack(); - } - - document.getElementById('chatinput').focus(); - document.title = this.name; - - setInterval(() => { - this.getReactions(); - }, 15000); - - this.scrollDown(); - }, - methods: { - // Initial - initialGreeting() { - this.botMessage( - this.oneOf( - [ - "Hi! I'm " + this.name + ". :)", - "Hi, nice to meet you! My name is " + this.name + ". :)" - ] - ), - false - ); - }, - welcomeBack() { - this.botMessage( - this.oneOf( - [ - "Hi! Haven't heard of you in a while. :)", - "Welcome back! :)", - "Hey :) Good to see you :)", - ] - ), - false - ); - }, - - // Name - askForName() { - this.botMessage( - this.oneOf([ - 'May i ask for your name?', - 'Whats your name? :)', - 'How can i call you?', - 'How did your developers call you? :)' - ]), - false - ); - - this.askedForName = true; - }, - setName(message) { - this.username = message.trim(); - this.settingsModal.username = this.username; - this.askedForName = false; - - this.botMessage( - this.oneOf([ - "That's a beautiful name!", - "Okay, i'll call you " + this.username + " from now on :)", - "Nice to meet you, " + this.username + ". :D" - ]) - ) - }, - - // Messages / Chat - addMessage(body, bot, me = false) { - this.messages.push({ - body: body, - bot: bot, - command: body.search('/') === 0, - me: me, - time: Date.now() - }) - }, - addImageMessage(imageObject, bot) { - this.lastMessageData = imageObject; - - this.messages.push({ - body: imageObject.body, - bot: bot, - src: imageObject.src - - }); - - setTimeout(() => { - this.scrollDown(); - }, 1000); - - this.stopTyping(); - this.updateStorage(); - }, - botMessage(message, save = true) { - this.addMessage(message, true); - - if (this.talk) { - this.say(message); - } - - this.stopTyping(); - - if (save) { - this.updateStorage(); - } - }, - userMessage(body) { - this.addMessage(body, false); - this.lastMessage = body; - - this.updateStorage(); - }, - sendMessage() { - if (this.chatbox.trim() === '') { - return false; - } - - if (this.chatbox.search('/me') !== 0) { - this.userMessage(this.chatbox); - } - this.scrollDown(); - this.react(this.chatbox); - this.chatbox = ''; - }, - meMessage(message) { - this.addMessage(this.username + ' ' + message, false, true); - this.react(message, true); - }, - react(message, recursive = false) { - this.startTyping(); - - if (message.search('/') === 0 && !recursive) { - setTimeout(() => { - this.processCommands(message); - this.scrollDown(); - }, 1000); - } else { - setTimeout(() => { - // Check commands - if (this.askedForName === true) { - this.setName(message); - } else if (this.awaitTodo === true) { - this.saveTodo(message); - } else { - let answer = this.getReaction(message); - if (answer) { - this.botMessage(answer); - } - - this.updateStorage(); - } - - this.scrollDown(); - }, 1800); - } - }, - getReaction(message) { - let preserveLastMessageData = false; - message = this.cleanupMessage(message); - - let keywords = message.split(' '); - let answer = undefined; - - if (this.lastMessageData.joke && this.includesOneOf(keywords, ['another', 'more'])) { - this.tellJoke(this.lastMessageData.category); - return false; - } - - if (this.lastMessageData.meme && this.includesOneOf(keywords, ['another', 'more'])) { - this.getRandomMeme(this.lastMessageData.category); - return false; - } - - if (this.lastMessageData.isJeopardy) { - if (this.includesAllOf(keywords, ['give', 'up'])) { - this.lastMessageData = {}; - return 'The right question would have been: "' + this.lastMessageData.question + '"'; - } - - if (this.isSimilar(message, this.lastMessageData.question)) { - this.lastMessageData = {}; - return this.oneOf([ - 'Wow! This is the right question.', - 'Correct!' - ]); - } else { - return this.oneOf([ - "Sorry, that's not correct.", - "That's not what we're searching for.", - "Nope, sorry. You can always give up by typing \"I give up\" if you wan't to.", - ]); - } - } - - if (this.lastMessageData.isTrivia) { - if (this.includesAllOf(keywords, ['give', 'up'])) { - this.lastMessageData = {}; - return this.oneOf([ - 'The right answer would have been: "' + this.lastMessageData.question + '"' - ]); - } - - if (this.isSimilar(message, this.lastMessageData.answer)) { - this.lastMessageData = {}; - return this.oneOf([ - 'Congratulations! This is the correct answer.', - 'Correct!' - ]); - } else { - return this.oneOf([ - "Sorry, that's not correct.", - "That's not what we're searching for.", - "Nope, sorry. You can always give up by typing \"I give up\" if you wan't to.", - ]); - } - } - - if (!preserveLastMessageData) { - this.lastMessageData = {}; - } - - if (this.includesAllOf(keywords, ['change', 'my', 'name'])) { - this.askedForName = true; - return "Please tell me how i should call you."; - } - - if (this.includesAllOf(keywords, ['new', 'todo']) || - this.includesAllOf(keywords, ['new', 'task']) || - this.includesAllOf(keywords, ['take', 'todo']) || - this.includesAllOf(keywords, ['save', 'to', 'clipboard']) - ) { - this.awaitTodo = true; - return this.oneOf([ - "What do you wan't me to save for you?", - "Tell me what you wan't to save.", - "What is it you wan't to save?", - ]); - } - - if (this.includesAllOf(keywords, ['clear', 'chat'])) { - this.clearChat(); - return false; - } - - if (this.includesAllOf(keywords, ['play']) && - this.includesOneOf(keywords, ['quiz', 'trivia']) - ) { - this.startQuiz(); - return false; - } - - if (this.includesAllOf(keywords, ['play', 'jeopardy'])) { - this.startJeopardy(); - return false; - } - - if (this.includesAllOf(keywords, ['roll', 'dice'])) { - this.rollDice(); - return false; - } - - if (this.includesAllOf(keywords, ['clear', 'chat'])) { - this.clearChat(); - return false; - } - - if (this.includesAllOf(keywords, ['weather']) && - this.includesOneOf(keywords, ['how','hows', 'what', 'whats']) - ) { - this.checkWeather(); - return false; - } - - if (this.includesAllOf(keywords, ['knock', 'joke'])) { - this.tellJoke('knock-knock'); - return false; - } - - if (this.includesAllOf(keywords, ['joke']) && this.includesOneOf(keywords, ['coding', 'programming', 'code', 'it'])) { - this.tellJoke('programming'); - return false; - } - - if (this.includesAllOf(keywords, ['birb', 'meme'])) { - this.getRandomMeme('birbmemes'); - return false; - } - - if (this.includesAllOf(keywords, ['anime', 'meme'])) { - this.getRandomMeme('animememes'); - return false; - } - - if (this.includesAllOf(keywords, ['coding', 'meme'])) { - this.getRandomMeme('codingmemes'); - return false; - } - - if (this.includesAllOf(keywords, ['dank', 'meme'])) { - this.getRandomMeme('dankmemes'); - return false; - } - - if (this.includesAllOf(keywords, ['meme']) && - this.includesOneOf(keywords, ['get', 'send']) - ) { - this.getRandomMeme(); - return false; - } - - if (this.includesAllOf(keywords, ['joke']) && this.includesOneOf(keywords, ['coding', 'programming', 'code', 'it'])) { - this.tellJoke('programming'); - return false; - } - - if (this.includesAllOf(keywords, ['tell', 'joke']) || - this.includesAllOf(keywords, ['something', 'funny']) || - this.includesAllOf(keywords, ['cheer', 'me', 'up']) - ) { - this.tellJoke('general'); - return false; - } - - if (this.includesAllOf(keywords, ['whats', 'the', 'time']) || this.includesAllOf(keywords, ['how', 'late'])) { - return "It's " + moment().format('LT'); - } - - if (this.includesAllOf(keywords, ['what', 'day', 'it'])) { - return "It's " + moment().format('dddd') + "."; - } - - if (this.includesAllOf(keywords, ['what', 'date', 'it']) || this.includesAllOf(keywords, ['whats', 'the', 'date'])) { - return "It's " + moment().format('dddd') + ", " + moment().format('MMMM Do YYYY') + "."; - } - - this.reactions.forEach((reactionOption) => { - if (reactionOption.includeAll === true) { - if (this.includesAllOf(keywords, reactionOption.keywords)) { - answer = this.oneOf(reactionOption.responses); - } - } else { - if (this.includesOneOf(keywords, reactionOption.keywords)) { - answer = this.oneOf(reactionOption.responses); - } - } - }); - - if (answer) { - return answer; - } - - this.rsaBackupAnswer(message); - }, - - // Forms - saveSettings() { - this.name = this.settingsModal.name; - this.username = this.settingsModal.username; - this.location = this.settingsModal.location; - this.updateStorage(); - - this.scrollDown(); - }, - - // Commands - processCommands: function (message) { - let commandExecuted = false; - - if (this.checkForCommands(message, 'todo')) { - let todoToSave = this.checkForCommands(message, 'todo'); - this.saveTodo(todoToSave); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'clear')) { - this.clearChat(); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'weather')) { - this.checkWeather(); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'joke')) { - this.tellJoke(this.checkForCommands(message, 'joke')); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'meme')) { - this.getRandomMeme(this.checkForCommands(message, 'meme')); - commandExecuted = true; - } else if (this.checkForCommands(message, 'me ')) { - this.meMessage(this.checkForCommands(message, 'me ')); - commandExecuted = true; - } - - let animals = [ - {animal: 'birb', emoji: '๐Ÿฆ'}, - {animal: 'dog', emoji: '๐Ÿถ'}, - {animal: 'cat', emoji: '๐Ÿฑ'}, - {animal: 'fox', emoji: '๐ŸฆŠ'}, - {animal: 'panda', emoji: '๐Ÿผ'}, - {animal: 'red_panda', emoji: '๐Ÿคฉ'}, - {animal: 'koala', emoji: '๐Ÿจ'} - ]; - - animals.forEach((animal) => { - if (this.checkForCommands(message, animal.animal + 'Img')) { - this.rsaRandomAnimalImage(animal.animal, animal.emoji); - commandExecuted = true; - } - - if (this.checkForCommands(message, animal.animal + 'Fact')) { - this.rsaRandomAnimalFact(animal.animal, animal.emoji); - commandExecuted = true; - } - }); - - animals.forEach((animal) => { - if (this.checkForCommands(message, animal.animal)) { - this.rsaRandomAnimalImage(animal.animal, animal.emoji); - commandExecuted = true; - } - }); - - if (this.checkForCommands(message, 'lyrics')) { - this.rsaLyrics(this.checkForCommands(message, 'lyrics')); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'quiz')) { - this.startQuiz(); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'jeopardy')) { - this.startJeopardy(); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'dice')) { - this.rollDice(); - commandExecuted = true; - } - - if (this.checkForCommands(message, 'talk')) { - this.talk = !this.talk; - commandExecuted = true; - } - - if (this.checkForCommands(message, 'say')) { - this.botMessage(this.checkForCommands(message, 'say')); - commandExecuted = true; - } - - if (this.checkForCommands(message, '66')) { - this.botMessage("But the children.."); - commandExecuted = true; - } - - if (!commandExecuted) { - this.isTyping = false; - this.botMessage("I can't find that command, sorry. ๐Ÿ˜–"); - } - - this.lastMessage = message; - }, - checkForCommands(message, commands) { - if (!Array.isArray(commands)) { - commands = [commands]; - } - - let commandFound = false; - let parameter = false; - - commands.forEach((command) => { - if (commandFound) { - return; - } - let commandString = '/' + command.toLowerCase(); - - if (message.search(commandString) === 0) { - parameter = message.replace(commandString, '').trim(); - commandFound = true; - } - }); - - return parameter ? parameter : commandFound; - }, - checkWeather() { - let Kara = this; - - if (!Kara.location) { - Kara.botMessage('Please set your location in the settings. โš™'); - return; - } - - let city = this.location.toLowerCase(); - let url = 'https://api.openweathermap.org/data/2.5/weather?q=' + city + '&appid=8a1aa336da8899c1038bf6bd808d8961&units=metric'; - - axios.get(url) - .then(function (response) { - Kara.botMessage('In ' + response.data.name + ' it\'s ' + response.data.main.temp.toFixed() + 'ยฐC with ' + response.data.weather[0].description + '.'); - }) - .catch(function (error) { - alertify.notify(error, 'danger'); - Kara.botMessage('I couldn\'t check the weather for your location. ๐Ÿค”'); - }) - - this.updateStorage(); - }, - getRandomMeme(category = 'memes') { - let Kara = this; - let url = 'https://meme-api.herokuapp.com/gimme/'; - - let categorySet = false; - - if (category !== true && category !== false) { - category = category.trim(); - categorySet = true; - } else { - category = 'memes' - } - - axios.get(url + category) - .then(function (response) { - Kara.addImageMessage({ - body: response.data.title, - src: response.data.url - }, true); - - Kara.lastMessageData = { - meme: true, - category: category - }; - }) - .catch(function (error) { - Kara.botMessage("Hmm.. i can't think of any good memes right now, sorry.. ๐Ÿ˜ž"); - }) - - this.updateStorage(); - }, - tellJoke(category) { - let Kara = this; - let categorySet = false; - - if (category !== true && category !== false) { - category = category.trim(); - categorySet = true; - } else { - category = 'general' - } - - let url = 'https://official-joke-api.appspot.com/jokes/' + category + '/random'; - - axios.get(url) - .then(function (response) { - let joke = response.data[0]; - - Kara.botMessage(joke.setup); - - setTimeout(() => { - Kara.botMessage(joke.punchline); - Kara.scrollDown(); - }, 3500); - - Kara.lastMessageData = { - joke: true, - category: category - }; - }) - .catch(function (error) { - console.log(error); - - if (categorySet) { - Kara.botMessage("Sorry, i don't know any jokes about this topic.. ๐Ÿ™„"); - } else { - Kara.botMessage("I can't remember any jokes right now, sorry. ๐Ÿ˜ข"); - } - }); - - this.updateStorage(); - }, - startQuiz() { - let Kara = this; - let url = 'https://jservice.io/api/random'; - - axios.get(url) - .then(function (response) { - let clue = response.data[0]; - - Kara.botMessage('Okay! Here is your question from the category "' + clue.category.title + '":'); - Kara.botMessage(clue.question); - - Kara.lastMessageData = { - isTrivia: true, - answer: clue.answer - }; - }) - .catch(function (error) { - Kara.botMessage("It's not a good time for a quiz."); - }); - - this.updateStorage(); - }, - startJeopardy() { - let Kara = this; - let url = 'https://jservice.io/api/random'; - - axios.get(url) - .then(function (response) { - let clue = response.data[0]; - - Kara.botMessage('Okay! Here we go. The category is "' + clue.category.title + '":'); - Kara.botMessage(clue.answer); - - Kara.lastMessageData = { - isJeopardy: true, - question: clue.question - }; - }) - .catch(function (error) { - Kara.botMessage("It's not a good time for a quiz."); - }); - - this.updateStorage(); - }, - rollDice() { - let dice = Math.random()*6; - - if (dice < 1) { - dice = 1; - } else { - dice = Math.floor(dice); - } - - this.addImageMessage({ - body: dice + '!', - src: 'img/' + dice + '.png' - }, true); - - this.updateStorage(); - }, - - // Todos - saveTodo(message) { - this.awaitTodo = false; - - this.todos.push({ - time: moment(), - body: message, - checked: false - }); - - this.updateStorage(); - - this.botMessage( - this.oneOf([ - "Saved! :)", - "You can read and check your todos in the clipboard-section. :)" - ]) - ) - }, - clearTodos() { - this.todos = []; - - this.botMessage( - this.oneOf([ - "Todos cleared. ๐Ÿšฎ" - ]) - ); - - this.updateStorage(); - }, - - // Some Random API Commands - rsaRandomAnimalImage(animal, emoji = '๐Ÿ˜„') { - let Kara = this; - - Kara.startTyping(); - - axios.post('/api/curlJson', { - url: 'https://some-random-api.ml/img/' + animal - }) - .catch((error) => { - Kara.botMessage("Sorry, i can't find any good pictures right now ๐Ÿ™" + emoji); - }) - .then((response) => { - Kara.addImageMessage({ - body: emoji, - src: response.data.link - }, true); - }) - }, - rsaRandomAnimalFact(animal, emoji = '๐Ÿ˜„') { - let Kara = this; - - Kara.startTyping(); - - axios.post('/api/curlJson', { - url: 'https://some-random-api.ml/facts/' + animal - }) - .catch((error) => { - Kara.botMessage("Sorry, i can't think of any good facts right now ๐Ÿ™" + emoji); - }) - .then((response) => { - Kara.botMessage(response.data.fact); - }) - }, - rsaLyrics(searchFor) { - let Kara = this; - - Kara.startTyping(); - - axios.post('/api/curlJson', { - url: 'https://some-random-api.ml/lyrics/?title=' + searchFor.replace(' ', '%20') - }) - .catch((error) => { - Kara.botMessage("Hmm.. i just can't remember the lyrics, but i love that song! ๐ŸŽต๐ŸŽง"); - }) - .then((response) => { - Kara.addImageMessage({ - body: "Here you go!
" + - "
" + - response.data.title + ' from ' + response.data.author + '
' + - '
' + - response.data.lyrics, - src: response.data.thumbnail.genius - }, true); - }) - }, - rsaBackupAnswer(message) { - let Kara = this; - - Kara.startTyping(); - - axios.post('/api/curlJson', { - url: 'https://some-random-api.ml/chatbot?message=' + message - }) - .catch((error) => { - Kara.botMessage("I don't know what to say.."); - }) - .then((response) => { - Kara.botMessage(response.data.response); - }); - }, - - // LocalStorage - getSavedData() { - let savedName = localStorage.getItem('name'); - - this.name = savedName ? savedName : this.name; - - let savedUsername = localStorage.getItem('username'); - this.username = savedUsername ? savedUsername : null; - - let savedActiveTheme = localStorage.getItem('activeTheme'); - this.activeTheme = savedActiveTheme ? savedActiveTheme : 'slate'; - - let savedMessages = JSON.parse(localStorage.getItem('messages')); - this.messages = savedMessages ? savedMessages : []; - - let savedTodos = JSON.parse(localStorage.getItem('todos')); - this.todos = savedTodos ? savedTodos : []; - - let savedLastMessage = JSON.parse(localStorage.getItem('lastMessage')); - this.lastMessage = savedLastMessage ? savedLastMessage : null; - - let savedLocation = JSON.parse(localStorage.getItem('location')); - this.location = savedLocation ? savedLocation : null; - - this.scrollDown(); - }, - updateStorage() { - localStorage.setItem('name', this.name); - localStorage.setItem('username', this.username); - localStorage.setItem('activeTheme', this.activeTheme); - localStorage.setItem('messages', JSON.stringify(this.messages)); - localStorage.setItem('answers', JSON.stringify(this.reactions)); - localStorage.setItem('todos', JSON.stringify(this.todos)); - localStorage.setItem('lastMessage', JSON.stringify(this.lastMessage)); - localStorage.setItem('location', JSON.stringify(this.location)); - }, - clearStorage() { - localStorage.clear(); - location.reload(); - }, - - // Utility - scrollDown() { - $('#chat-box').stop().animate({ - scrollTop: ($('#chat-box')[0].scrollHeight * 10) - }, 800); - }, - startTyping() { - this.isTyping = true; - }, - stopTyping() { - this.scrollDown(); - this.isTyping = false; - }, - oneOf(answers) { - let amountOfAnswers = answers.length; - let randomIndex = Math.floor(Math.random() * (amountOfAnswers)); - - return this.convertWildcards(answers[randomIndex]); - }, - convertWildcards(message) { - message = message.replace('$name$', this.username); - message = message.replace('$botname$', this.name); - - return message; - }, - cleanupMessage(message) { - message = message.toLowerCase(); - return message.replace('?', '') - .replace('!', '') - .replace('.', '') - .replace(',', '') - .replace('-', '') - .replace('_', '') - .replace('#', '') - .replace('\'', '') - .replace('"', '') - .replace('+', '') - .replace('*', '') - .replace('ยง', '') - .replace('$', '') - .replace('%', '') - .replace('&', '') - .replace('/', '') - .replace('(', '') - .replace(')', '') - .replace('=', '') - .replace('\\', '') - .replace('@', '') - .replace('~', '') - .replace('โ€ฆ', ''); - }, - clearChat() { - this.messages = []; - this.botMessage(this.oneOf([ - 'Chat cleared.', - 'Evidence destroyed.', - 'Mind cleared.', - 'Uhm.. i think forgot everything we ever talked about.. oops.', - 'A fresh start!', - "You've got something to hide? Nevermind, gotcha fam. Chat is cleared now. ๐Ÿฑโ€๐Ÿ‘ค" - ])); - - this.updateStorage(); - }, - includesOneOf(keywords, wordsToSearch) { - let lowerCasedKeywords = []; - keywords.forEach((keyword) => { - lowerCasedKeywords.push(keyword.toLowerCase()); - }); - let includes = false; - - wordsToSearch.forEach((searchWord) => { - if (lowerCasedKeywords.includes(searchWord)) { - includes = true; - } - }); - - return includes; - }, - includesAllOf(keywords, wordsToSearch) { - let lowerCasedKeywords = []; - keywords.forEach((keyword) => { - lowerCasedKeywords.push(keyword.toLowerCase()); - }); - - let includesAllkeywords = true; - - wordsToSearch.forEach((searchWord) => { - if (!lowerCasedKeywords.includes(searchWord)) { - includesAllkeywords = false; - } - }); - - return includesAllkeywords; - }, - - // Ajax calls for saving/receiving reactions, documentation & themes - getBootswatchThemes() { - let Kara = this; - - axios.get('https://bootswatch.com/api/4.json') - .then(function (response) { - Kara.themes = response.data.themes; - }) - .catch(function (error) { - console.log(error); - }) - }, - getReactions() { - let Kara = this; - - axios.get('/reactions/get').then((response) => { - Kara.reactions = []; - - response.data.forEach((reaction) => { - Kara.reactions.push(JSON.parse(reaction.reaction)); - }); - }).catch((error) => { - console.log(error); - }); - }, - getDocumentation() { - let Kara = this; - - axios.get('/api/kara/documentation').then((response) => { - Kara.documentation = response.data; - }).catch((error) => { - console.log(error); - }); - }, - - // Levenshtein distance - isSimilar(message1, message2) { - let longer = message1; - let shorter = message2; - - if (message1.length < message2.length) { - longer = message2; - shorter = message1; - } - - const longerLength = longer.length; - if (longerLength === 0) { - return 1.0; - } - - let similarity = (longerLength - this.editDistance(longer, shorter)) / parseFloat(longerLength); - - return similarity > 0.65; - }, - - editDistance: function (message1, message2) { - message1 = message1.toLowerCase(); - message2 = message2.toLowerCase(); - - let costs = []; - for (let i = 0; i <= message1.length; i++) { - let lastValue = i; - for (let j = 0; j <= message2.length; j++) { - if (i === 0) - costs[j] = j; - else { - if (j > 0) { - let newValue = costs[j - 1]; - if (message1.charAt(i - 1) !== message2.charAt(j - 1)) - newValue = Math.min(Math.min(newValue, lastValue), - costs[j]) + 1; - costs[j - 1] = lastValue; - lastValue = newValue; - } - } - } - if (i > 0) { - costs[message2.length] = lastValue; - } - } - - return costs[message2.length]; - }, - - // Speech - say(message) { - var speech = new SpeechSynthesisUtterance(); - - // Set the text and voice attributes. - speech.text = message; - speech.volume = 1; - speech.rate = 1; - speech.pitch = 1; - - window.speechSynthesis.speak(speech); - }, - } -}) \ No newline at end of file diff --git a/css/lightbox.min.css b/css/lightbox.min.css deleted file mode 100644 index f0f1d1b..0000000 --- a/css/lightbox.min.css +++ /dev/null @@ -1 +0,0 @@ -.lb-loader,.lightbox{text-align:center;line-height:0;position:absolute;left:0}body.lb-disable-scrolling{overflow:hidden}.lightboxOverlay{position:absolute;top:0;left:0;z-index:9999;background-color:#000;filter:alpha(Opacity=80);opacity:.8;display:none}.lightbox{width:100%;z-index:10000;font-weight:400;outline:0}.lightbox .lb-image{display:block;height:auto;max-width:inherit;max-height:none;border-radius:3px;border:4px solid #fff}.lightbox a img{border:none}.lb-outerContainer{position:relative;width:250px;height:250px;margin:0 auto;border-radius:4px;background-color:#fff}.lb-outerContainer:after{content:"";display:table;clear:both}.lb-loader{top:43%;height:25%;width:100%}.lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background:url(../../../../../Desktop/lightbox2-2.11.3/dist/images/loading.gif) no-repeat}.lb-nav{position:absolute;top:0;left:0;height:100%;width:100%;z-index:10}.lb-container>.nav{left:0}.lb-nav a{outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.lb-next,.lb-prev{height:100%;cursor:pointer;display:block}.lb-nav a.lb-prev{width:34%;left:0;float:left;background:url(../../../../../Desktop/lightbox2-2.11.3/dist/images/prev.png) left 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-prev:hover{filter:alpha(Opacity=100);opacity:1}.lb-nav a.lb-next{width:64%;right:0;float:right;background:url(../../../../../Desktop/lightbox2-2.11.3/dist/images/next.png) right 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-next:hover{filter:alpha(Opacity=100);opacity:1}.lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.lb-dataContainer:after{content:"";display:table;clear:both}.lb-data{padding:0 4px;color:#ccc}.lb-data .lb-details{width:85%;float:left;text-align:left;line-height:1.1em}.lb-data .lb-caption{font-size:13px;font-weight:700;line-height:1em}.lb-data .lb-caption a{color:#4ae}.lb-data .lb-number{display:block;clear:left;padding-bottom:1em;font-size:12px;color:#999}.lb-data .lb-close{display:block;float:right;width:30px;height:30px;background:url(../../../../../Desktop/lightbox2-2.11.3/dist/images/close.png) top right no-repeat;text-align:right;outline:0;filter:alpha(Opacity=70);opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.lb-data .lb-close:hover{cursor:pointer;filter:alpha(Opacity=100);opacity:1} \ No newline at end of file diff --git a/documentation.md b/documentation.md deleted file mode 100644 index 075c794..0000000 --- a/documentation.md +++ /dev/null @@ -1,95 +0,0 @@ -#### Commands - - -##### ```/clear``` -Clears the chat. - -##### ```/say``` -Repeats your message. - -##### ```/todo``` -Adds a new todo to the list. Todos can be viewed, checked and cleared by clicking on the clipboard-icon (only visible once you have a least one todo) in the upper right. - -##### ```/weather``` -Tells you the weather in your location.\ -Your location can be set in the settings.\ -\ -Can be triggered by messages like: -- _How is the weather?_ - -##### ```/joke``` -Tells a joke with an opener and a delayed punchline.\ -Categories are: general (default), knock-knock, programming -\ -Can be triggered by messages like: -- _Tell me a joke_ -- _Tell me a knock knock joke_ -- _Tell me a programming joke_ - -##### ```/meme``` -Sends a random meme from reddit.\ -You can pass a subreddit of your choice (Yes, NSFW too..) -\ -Some predefined meme-categories can be triggerd by: -- _Send me a coding meme_ -- _Send me a dank meme_ -- _Send me a birb meme_ - - -##### ```/me``` -Sends a classical "_User farted_" message. - -##### ```/lyrics``` -Fetch lyrics for songs.\ -Usage: ```/lyrics songname```\ -(you can also search for things like ```songname artist```) - -##### ```/quiz``` -Get a quiz-question and guess the answer.\ -You can always give up by typing "i give up". - -##### ```/jeopardy``` -The opposite of ```/quiz```.\ -Guess the right question to the given answer. - -##### ```/dice``` -Roll the dice! - -##### Animal images & facts -There are a number of commands to receive random animal images & facts. - -Animals:\ -_birb, dog, cat, fox, panda, red_panda & koala_ - -To get a fact or an image, use: -```/youranimalImg``` or ```/youranimalFact``` - - - ---- - -#### Experimental - -##### ```/talk``` -Activate talking. Kara will now talk to you.\ -The voice-language heavily depends on the device used. - ---- - -#### Planned features - -- Timetracking for work with unlimited trackers -- Wikipedia lookup -- News integration -- Multilanguage (English, German) -- More natural conversations -- Chrome Extension (_WIP_) -- YouTube integration -- more fun stuff & games -- maybe some quick image-converting & editing in the future. - ---- - -#### Found a bug? - -Eat it! Or open an [issue](https://git.luna-development.net/neroignis/kara) ๐Ÿž \ No newline at end of file diff --git a/images/close.png b/images/close.png deleted file mode 100644 index 20baa1d..0000000 Binary files a/images/close.png and /dev/null differ diff --git a/images/loading.gif b/images/loading.gif deleted file mode 100644 index 5087c2a..0000000 Binary files a/images/loading.gif and /dev/null differ diff --git a/images/next.png b/images/next.png deleted file mode 100644 index 08365ac..0000000 Binary files a/images/next.png and /dev/null differ diff --git a/images/prev.png b/images/prev.png deleted file mode 100644 index 329fa98..0000000 Binary files a/images/prev.png and /dev/null differ diff --git a/img/1.png b/img/1.png deleted file mode 100644 index bc1fbc3..0000000 Binary files a/img/1.png and /dev/null differ diff --git a/img/2.png b/img/2.png deleted file mode 100644 index 2e2016e..0000000 Binary files a/img/2.png and /dev/null differ diff --git a/img/3.png b/img/3.png deleted file mode 100644 index 1e09959..0000000 Binary files a/img/3.png and /dev/null differ diff --git a/img/4.png b/img/4.png deleted file mode 100644 index b9be3c4..0000000 Binary files a/img/4.png and /dev/null differ diff --git a/img/5.png b/img/5.png deleted file mode 100644 index c25c575..0000000 Binary files a/img/5.png and /dev/null differ diff --git a/img/6.png b/img/6.png deleted file mode 100644 index 3bc4403..0000000 Binary files a/img/6.png and /dev/null differ diff --git a/img/luna.png b/img/luna.png deleted file mode 100644 index 241a332..0000000 Binary files a/img/luna.png and /dev/null differ diff --git a/index.html b/index.html deleted file mode 100644 index ed23831..0000000 --- a/index.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Kara - - - - - - - - - - - - -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- {{ this.name }} -
- -
- -
-
- - Loading... - -
-
- - Loading... - -
-
- - Loading... - -
-
-
- -
- -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - diff --git a/js/lightbox.min.js b/js/lightbox.min.js deleted file mode 100644 index efb7acd..0000000 --- a/js/lightbox.min.js +++ /dev/null @@ -1,15 +0,0 @@ -/*! - * Lightbox v2.11.3 - * by Lokesh Dhakar - * - * More info: - * http://lokeshdhakar.com/projects/lightbox2/ - * - * Copyright Lokesh Dhakar - * Released under the MIT license - * https://github.com/lokesh/lightbox2/blob/master/LICENSE - * - * @preserve - */ -!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b(require("jquery")):a.lightbox=b(a.jQuery)}(this,function(a){function b(b){this.album=[],this.currentImageIndex=void 0,this.init(),this.options=a.extend({},this.constructor.defaults),this.option(b)}return b.defaults={albumLabel:"Image %1 of %2",alwaysShowNavOnTouchDevices:!1,fadeDuration:600,fitImagesInViewport:!0,imageFadeDuration:600,positionFromTop:50,resizeDuration:700,showImageNumberLabel:!0,wrapAround:!1,disableScrolling:!1,sanitizeTitle:!1},b.prototype.option=function(b){a.extend(this.options,b)},b.prototype.imageCountLabel=function(a,b){return this.options.albumLabel.replace(/%1/g,a).replace(/%2/g,b)},b.prototype.init=function(){var b=this;a(document).ready(function(){b.enable(),b.build()})},b.prototype.enable=function(){var b=this;a("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(c){return b.start(a(c.currentTarget)),!1})},b.prototype.build=function(){if(!(a("#lightbox").length>0)){var b=this;a('
').appendTo(a("body")),this.$lightbox=a("#lightbox"),this.$overlay=a("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.$image=this.$lightbox.find(".lb-image"),this.$nav=this.$lightbox.find(".lb-nav"),this.containerPadding={top:parseInt(this.$container.css("padding-top"),10),right:parseInt(this.$container.css("padding-right"),10),bottom:parseInt(this.$container.css("padding-bottom"),10),left:parseInt(this.$container.css("padding-left"),10)},this.imageBorderWidth={top:parseInt(this.$image.css("border-top-width"),10),right:parseInt(this.$image.css("border-right-width"),10),bottom:parseInt(this.$image.css("border-bottom-width"),10),left:parseInt(this.$image.css("border-left-width"),10)},this.$overlay.hide().on("click",function(){return b.end(),!1}),this.$lightbox.hide().on("click",function(c){"lightbox"===a(c.target).attr("id")&&b.end()}),this.$outerContainer.on("click",function(c){return"lightbox"===a(c.target).attr("id")&&b.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return 0===b.currentImageIndex?b.changeImage(b.album.length-1):b.changeImage(b.currentImageIndex-1),!1}),this.$lightbox.find(".lb-next").on("click",function(){return b.currentImageIndex===b.album.length-1?b.changeImage(0):b.changeImage(b.currentImageIndex+1),!1}),this.$nav.on("mousedown",function(a){3===a.which&&(b.$nav.css("pointer-events","none"),b.$lightbox.one("contextmenu",function(){setTimeout(function(){this.$nav.css("pointer-events","auto")}.bind(b),0)}))}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return b.end(),!1})}},b.prototype.start=function(b){function c(a){d.album.push({alt:a.attr("data-alt"),link:a.attr("href"),title:a.attr("data-title")||a.attr("title")})}var d=this,e=a(window);e.on("resize",a.proxy(this.sizeOverlay,this)),this.sizeOverlay(),this.album=[];var f,g=0,h=b.attr("data-lightbox");if(h){f=a(b.prop("tagName")+'[data-lightbox="'+h+'"]');for(var i=0;ik||g.height>j)&&(g.width/k>g.height/j?(i=k,h=parseInt(g.height/(g.width/i),10),f.width(i),f.height(h)):(h=j,i=parseInt(g.width/(g.height/h),10),f.width(i),f.height(h))),c.sizeContainer(f.width(),f.height())},g.src=this.album[b].link,this.currentImageIndex=b},b.prototype.sizeOverlay=function(){var b=this;setTimeout(function(){b.$overlay.width(a(document).width()).height(a(document).height())},0)},b.prototype.sizeContainer=function(a,b){function c(){d.$lightbox.find(".lb-dataContainer").width(g),d.$lightbox.find(".lb-prevLink").height(h),d.$lightbox.find(".lb-nextLink").height(h),d.$overlay.focus(),d.showImage()}var d=this,e=this.$outerContainer.outerWidth(),f=this.$outerContainer.outerHeight(),g=a+this.containerPadding.left+this.containerPadding.right+this.imageBorderWidth.left+this.imageBorderWidth.right,h=b+this.containerPadding.top+this.containerPadding.bottom+this.imageBorderWidth.top+this.imageBorderWidth.bottom;e!==g||f!==h?this.$outerContainer.animate({width:g,height:h},this.options.resizeDuration,"swing",function(){c()}):c()},b.prototype.showImage=function(){this.$lightbox.find(".lb-loader").stop(!0).hide(),this.$lightbox.find(".lb-image").fadeIn(this.options.imageFadeDuration),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},b.prototype.updateNav=function(){var a=!1;try{document.createEvent("TouchEvent"),a=!!this.options.alwaysShowNavOnTouchDevices}catch(a){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(a&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),a&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel){var c=this.imageCountLabel(this.currentImageIndex+1,this.album.length);this.$lightbox.find(".lb-number").text(c).fadeIn("fast")}else this.$lightbox.find(".lb-number").hide();this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return a.sizeOverlay()})},b.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){(new Image).src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){(new Image).src=this.album[this.currentImageIndex-1].link}},b.prototype.enableKeyboardNav=function(){this.$lightbox.on("keyup.keyboard",a.proxy(this.keyboardAction,this)),this.$overlay.on("keyup.keyboard",a.proxy(this.keyboardAction,this))},b.prototype.disableKeyboardNav=function(){this.$lightbox.off(".keyboard"),this.$overlay.off(".keyboard")},b.prototype.keyboardAction=function(a){var b=a.keyCode;27===b?(a.stopPropagation(),this.end()):37===b?0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1):39===b&&(this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0))},b.prototype.end=function(){this.disableKeyboardNav(),a(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),this.options.disableScrolling&&a("body").removeClass("lb-disable-scrolling")},new b}); -//# sourceMappingURL=lightbox.min.map \ No newline at end of file diff --git a/manifest/kara.json b/manifest/kara.json deleted file mode 100644 index 1661553..0000000 --- a/manifest/kara.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "short_name": "Kara", - "name": "Kara", - "icons": [ - { - "src": "/img/logo/luna/256.png", - "type": "image/png", - "sizes": "256x256" - } - ], - "start_url": "/kara/", - "background_color": "#383838", - "display": "standalone", - "scope": "/kara/", - "theme_color": "#383838" -} \ No newline at end of file