Showing
1 changed file
with
8 additions
and
8 deletions
... | @@ -3,13 +3,13 @@ const SlackBot = require('slackbots'); //link : https://github.com/mishk0/slack- | ... | @@ -3,13 +3,13 @@ const SlackBot = require('slackbots'); //link : https://github.com/mishk0/slack- |
3 | const dbname = 'jokeapi'; | 3 | const dbname = 'jokeapi'; |
4 | const emoji = require('../slack_emoji'); | 4 | const emoji = require('../slack_emoji'); |
5 | const url = 'mongodb://localhost:27017/'; | 5 | const url = 'mongodb://localhost:27017/'; |
6 | -const fs=require('fs'); | 6 | +const fs = require('fs'); |
7 | //const userjoke = require('./joke_data/user.json'); | 7 | //const userjoke = require('./joke_data/user.json'); |
8 | 8 | ||
9 | exports.startbot = ()=>{ | 9 | exports.startbot = ()=>{ |
10 | // Get authorization to use the slackbot | 10 | // Get authorization to use the slackbot |
11 | const bot = new SlackBot({ | 11 | const bot = new SlackBot({ |
12 | - token : "xoxb-635297512738-635283536771-A03RoBh4Dv8qG1EiLudMpk1f", | 12 | + token : "xoxb-651692943605-645515979745-sqycGNiTIOZNxnly4k1BV1HO", |
13 | name : "jokebot" | 13 | name : "jokebot" |
14 | }); | 14 | }); |
15 | 15 | ||
... | @@ -21,7 +21,7 @@ exports.startbot = ()=>{ | ... | @@ -21,7 +21,7 @@ exports.startbot = ()=>{ |
21 | channel_length = data.channels.length; | 21 | channel_length = data.channels.length; |
22 | for(i=0; i< channel_length; ++i){ | 22 | for(i=0; i< channel_length; ++i){ |
23 | //postMessageToChannel(name, message [, params, callback]) (return: promise) - posts a message to channel by name. | 23 | //postMessageToChannel(name, message [, params, callback]) (return: promise) - posts a message to channel by name. |
24 | - bot.postMessageToChannel(data.channels[i].name, 'Have some fun with @Joker!\nFor commands write @joker --help' | 24 | + bot.postMessageToChannel(data.channels[i].name, 'Have some fun with @Joker!\nFor commands write @joker -help' |
25 | 25 | ||
26 | , emoji.emojis('bowtie')); | 26 | , emoji.emojis('bowtie')); |
27 | } | 27 | } |
... | @@ -116,7 +116,7 @@ function handleMessage(message, current_channel){ | ... | @@ -116,7 +116,7 @@ function handleMessage(message, current_channel){ |
116 | } | 116 | } |
117 | 117 | ||
118 | } | 118 | } |
119 | - else if(message.includes(' --help')){ | 119 | + else if(message.includes(' -help')){ |
120 | runHelp(current_channel); | 120 | runHelp(current_channel); |
121 | } | 121 | } |
122 | else if(message.includes(' what jokes')){ | 122 | else if(message.includes(' what jokes')){ |
... | @@ -202,7 +202,7 @@ randomJoke= (user_channel)=>{ | ... | @@ -202,7 +202,7 @@ randomJoke= (user_channel)=>{ |
202 | 202 | ||
203 | //set the maximum number of api formats and get a random integer | 203 | //set the maximum number of api formats and get a random integer |
204 | json_max = 376; | 204 | json_max = 376; |
205 | - random = getRandomInt(json_max); | 205 | + random = getRandomInt(1,json_max); |
206 | //Go to jokes collection inside jokeapi database and find one joke randomly by putting a random number | 206 | //Go to jokes collection inside jokeapi database and find one joke randomly by putting a random number |
207 | result = db.collection('jokes').findOne({id: random}); | 207 | result = db.collection('jokes').findOne({id: random}); |
208 | 208 | ||
... | @@ -319,7 +319,7 @@ Funnystory= (user_channel)=>{ | ... | @@ -319,7 +319,7 @@ Funnystory= (user_channel)=>{ |
319 | var db = client.db('FunnyStoryapi'); | 319 | var db = client.db('FunnyStoryapi'); |
320 | 320 | ||
321 | 321 | ||
322 | - random = getRandomInt(200); | 322 | + random = getRandomInt(1,200); |
323 | result = db.collection('FunnyStory').findOne({id: random}); | 323 | result = db.collection('FunnyStory').findOne({id: random}); |
324 | user = result; | 324 | user = result; |
325 | //if the random picked api type is not general execute the function from the start to get another format for general type | 325 | //if the random picked api type is not general execute the function from the start to get another format for general type |
... | @@ -347,7 +347,7 @@ redditJoke= (user_channel)=>{ | ... | @@ -347,7 +347,7 @@ redditJoke= (user_channel)=>{ |
347 | var db = client.db('redditjoke'); | 347 | var db = client.db('redditjoke'); |
348 | 348 | ||
349 | json_max = 70; | 349 | json_max = 70; |
350 | - random = getRandomInt(json_max); | 350 | + random = getRandomInt(1,json_max); |
351 | result = db.collection('reddit').findOne({id: random}); | 351 | result = db.collection('reddit').findOne({id: random}); |
352 | user = result; | 352 | user = result; |
353 | //if the random picked api type is not general execute the function from the start to get another format for general type | 353 | //if the random picked api type is not general execute the function from the start to get another format for general type |
... | @@ -400,7 +400,7 @@ knockknockJoke= (user_channel)=>{ | ... | @@ -400,7 +400,7 @@ knockknockJoke= (user_channel)=>{ |
400 | //Function for giving out information to user to control the bot | 400 | //Function for giving out information to user to control the bot |
401 | runHelp = (user_channel) =>{ | 401 | runHelp = (user_channel) =>{ |
402 | 402 | ||
403 | - comment = "Thanks for using Joker bot!:ghost::ghost:laugh:\nBot info: type '@joker --help' for infos\nBot functions: '@joker tell me [something] joke' will send related jokes, if I don't have what you mentioned, I will tell you I don't have that joke:smile:\n" | 403 | + comment = "Thanks for using Joker bot!:ghost::ghost:laugh:\nBot info: type '@joker -help' for infos\nBot functions: '@joker tell me [something] joke' will send related jokes, if I don't have what you mentioned, I will tell you I don't have that joke:smile:\n" |
404 | current_jokes = "Joke types I have: general , knock-knock , programming , reddit, funny story" | 404 | current_jokes = "Joke types I have: general , knock-knock , programming , reddit, funny story" |
405 | bot.postMessageToChannel(user_channel, comment + current_jokes ,emoji.emojis('question')); | 405 | bot.postMessageToChannel(user_channel, comment + current_jokes ,emoji.emojis('question')); |
406 | } | 406 | } | ... | ... |
-
Please register or login to post a comment