|
|
@ -127,8 +127,19 @@ let kara = new Vue({ |
|
|
|
time: Date.now() |
|
|
|
time: Date.now() |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
botMessage(body) { |
|
|
|
addImageMessage(imageObject, bot) { |
|
|
|
this.addMessage(body, true); |
|
|
|
this.lastMessageData = imageObject; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.messages.push({ |
|
|
|
|
|
|
|
body: imageObject.caption, |
|
|
|
|
|
|
|
bot: bot, |
|
|
|
|
|
|
|
src: imageObject.image |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updateStorage(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
botMessage(message) { |
|
|
|
|
|
|
|
this.addMessage(message, true); |
|
|
|
}, |
|
|
|
}, |
|
|
|
userMessage(body) { |
|
|
|
userMessage(body) { |
|
|
|
this.addMessage(body, false); |
|
|
|
this.addMessage(body, false); |
|
|
@ -272,7 +283,7 @@ let kara = new Vue({ |
|
|
|
return answer; |
|
|
|
return answer; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 'I don\'t know what to say..'; |
|
|
|
this.getBackupAnswer(message); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Forms
|
|
|
|
// Forms
|
|
|
@ -298,15 +309,25 @@ let kara = new Vue({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.checkForCommands(message, 'weather')) { |
|
|
|
if (this.checkForCommands(message, 'weather')) { |
|
|
|
this.checkWeather() |
|
|
|
this.checkWeather(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.checkForCommands(message, 'joke')) { |
|
|
|
if (this.checkForCommands(message, 'joke')) { |
|
|
|
this.tellJoke(this.checkForCommands(message, 'joke')) |
|
|
|
this.tellJoke(this.checkForCommands(message, 'joke')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.checkForCommands(message, 'meme')) { |
|
|
|
|
|
|
|
this.getRandomMeme(); |
|
|
|
|
|
|
|
} else if (this.checkForCommands(message, 'me ')) { |
|
|
|
|
|
|
|
this.meMessage(this.checkForCommands(message, 'me ')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.checkForCommands(message, 'me')) { |
|
|
|
if (this.checkForCommands(message, 'cat')) { |
|
|
|
this.meMessage(this.checkForCommands(message, 'me')) |
|
|
|
this.getRandomCat(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.checkForCommands(message, 'birb')) { |
|
|
|
|
|
|
|
this.getRandomBirb(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
checkForCommands(message, commands) { |
|
|
|
checkForCommands(message, commands) { |
|
|
@ -353,6 +374,78 @@ let kara = new Vue({ |
|
|
|
|
|
|
|
|
|
|
|
this.updateStorage(); |
|
|
|
this.updateStorage(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
getBackupAnswer(message) { |
|
|
|
|
|
|
|
let vue = this; |
|
|
|
|
|
|
|
let url = 'https://some-random-api.ml/chatbot?message=' + message; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
axios.get(url) |
|
|
|
|
|
|
|
.then(function (response) { |
|
|
|
|
|
|
|
vue.botMessage(response.data.response); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch(function (error) { |
|
|
|
|
|
|
|
vue.botMessage("I don't know what to say.."); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updateStorage(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
getRandomMeme() { |
|
|
|
|
|
|
|
let vue = this; |
|
|
|
|
|
|
|
let url = 'https://some-random-api.ml/meme'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
axios.get(url) |
|
|
|
|
|
|
|
.then(function (response) { |
|
|
|
|
|
|
|
vue.botMessage(response.data); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch(function (error) { |
|
|
|
|
|
|
|
vue.botMessage("Hmm.. i can't think of any good memes right now, sorry.. 😞"); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updateStorage(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
getRandomCat() { |
|
|
|
|
|
|
|
let vue = this; |
|
|
|
|
|
|
|
let url = 'https://api.thecatapi.com/v1/images/search?apiKey=5666b3cc-a7a3-406f-904d-b13594780d7f'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
axios.get(url) |
|
|
|
|
|
|
|
.then(function (response) { |
|
|
|
|
|
|
|
console.log(response); |
|
|
|
|
|
|
|
console.log(response.data[0].url); |
|
|
|
|
|
|
|
vue.addImageMessage({ |
|
|
|
|
|
|
|
caption: '', |
|
|
|
|
|
|
|
image: response.data[0].url |
|
|
|
|
|
|
|
}, true); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
vue.scrollDown(); |
|
|
|
|
|
|
|
}, 1000) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch(function (error) { |
|
|
|
|
|
|
|
vue.botMessage("I can't find any images at the moment, sorry.. 😿"); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updateStorage(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
getRandomBirb() { |
|
|
|
|
|
|
|
let vue = this; |
|
|
|
|
|
|
|
let url = '//random.birb.pw/tweet.json'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
axios.get(url) |
|
|
|
|
|
|
|
.then(function (response) { |
|
|
|
|
|
|
|
console.log(response); |
|
|
|
|
|
|
|
console.log(response.data[0].url); |
|
|
|
|
|
|
|
vue.addImageMessage({ |
|
|
|
|
|
|
|
caption: '', |
|
|
|
|
|
|
|
image: 'https://random.birb.pw/img/' + response.data.file |
|
|
|
|
|
|
|
}, true); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
vue.scrollDown(); |
|
|
|
|
|
|
|
}, 1000) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch(function (error) { |
|
|
|
|
|
|
|
vue.botMessage("I can't find any images at the moment, sorry.. 🐦"); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updateStorage(); |
|
|
|
|
|
|
|
}, |
|
|
|
tellJoke(category) { |
|
|
|
tellJoke(category) { |
|
|
|
let vue = this; |
|
|
|
let vue = this; |
|
|
|
let categorySet = false; |
|
|
|
let categorySet = false; |
|
|
|