Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
720 stars 144 forks source link

Sending a random joke (message) #186

Closed AlexiRJamal closed 6 years ago

AlexiRJamal commented 6 years ago

`'use strict'

const Telegram = require('telegram-node-bot');

var jokesEngArr = []; //If you wanted to get between 1 and 6, you would calculate: //Math.floor(Math.random() 6) + 1 (If between 0 and 6, just remove the +1) var jk1en = 'Doc: You have 10 to live\nPatient: 10 what?\nDoc: 9, 8, 7'; var jk2en = 'What\'s the difference between a snowman and a snowwoman?\n-----snowballs-----'; var jk3en = 'Mom: how\'s school today?\nSon: Great! We also made bombs.\nMom: Wow. And what will you do tomorrow at school?\nSon: What school?'; var jk4en = 'Doc: how often do you do sports?\nPatient: Does sex counts?\nDoc: Yes.\nPatient: Then no'; var jk5en = '"I wansn\'t that drunk"\n- Dude you held the shower head and told it to stop crying.'; var jk6en = '"I wasn\'t that drunk" \n- Dude you were on the roof gonna jump singing "I believe I can fly!"'; var jk7en = 'Sometimes it is very important if a sentence was said by a man or a woman. A good example: "I used a whole pack of tissues during that awesome movie yesterday!"'; var jk8en = 'Doc you have to help me! No one gives a shit about me.\nDoc: Next please.'; var jk9en = 'Two police officers crash their car into a tree.\nAfter a moment of silence, one of them says, "Wow, that\'s got to be the fastest we ever got to the accident site."'; var jk10en = 'About 4,000 years ago:\nGod: I shall create a great plague and every living thing on Earth will die!\nFish: Winks at God and slips him a $20 note\nGod: Correction, I shall create a great flood!'; var i = Math.floor(Math.random()*10); jokesEngArr.push(jk1en, jk2en, jk3en, jk4en, jk5en, jk6en, jk7en, jk8en, jk9en, jk10en);

function getJoke(){ var s = jokesEngArr[i]; return s; }

class JokesController extends Telegram.TelegramBaseController {

jokesEnHandler($){
    $.sendMessage(getJoke());
}
get routes(){
    return{
        'jokesEnCommand': 'jokesEnHandler'
    }
}
_serializeList(jokesList){

}

} module.exports = JokesController;`

So I want to send a random message, I tried at first sending it NOT as a function, but it returned an error.
Can someone please help?
I know the jokes part is long, ignore it.
I would be glad if someone could help.
Thanks in advance :)

AlexiRJamal commented 6 years ago

I'm REALLY sorry about the formatting, it didn't work idk why :/

AlexiRJamal commented 6 years ago

I would have posted the error but I commented the jokes section in index.js file and Heroku is experiencing issues with redeployment from GitHub.