김민욱

change some errors

......@@ -3,13 +3,13 @@ const SlackBot = require('slackbots'); //link : https://github.com/mishk0/slack-
const dbname = 'jokeapi';
const emoji = require('../slack_emoji');
const url = 'mongodb://localhost:27017/';
const fs=require('fs');
const fs = require('fs');
//const userjoke = require('./joke_data/user.json');
exports.startbot = ()=>{
// Get authorization to use the slackbot
const bot = new SlackBot({
token : "xoxb-635297512738-635283536771-A03RoBh4Dv8qG1EiLudMpk1f",
token : "xoxb-651692943605-645515979745-sqycGNiTIOZNxnly4k1BV1HO",
name : "jokebot"
});
......@@ -21,7 +21,7 @@ exports.startbot = ()=>{
channel_length = data.channels.length;
for(i=0; i< channel_length; ++i){
//postMessageToChannel(name, message [, params, callback]) (return: promise) - posts a message to channel by name.
bot.postMessageToChannel(data.channels[i].name, 'Have some fun with @Joker!\nFor commands write @joker --help'
bot.postMessageToChannel(data.channels[i].name, 'Have some fun with @Joker!\nFor commands write @joker -help'
, emoji.emojis('bowtie'));
}
......@@ -116,7 +116,7 @@ function handleMessage(message, current_channel){
}
}
else if(message.includes(' --help')){
else if(message.includes(' -help')){
runHelp(current_channel);
}
else if(message.includes(' what jokes')){
......@@ -202,7 +202,7 @@ randomJoke= (user_channel)=>{
//set the maximum number of api formats and get a random integer
json_max = 376;
random = getRandomInt(json_max);
random = getRandomInt(1,json_max);
//Go to jokes collection inside jokeapi database and find one joke randomly by putting a random number
result = db.collection('jokes').findOne({id: random});
......@@ -319,7 +319,7 @@ Funnystory= (user_channel)=>{
var db = client.db('FunnyStoryapi');
random = getRandomInt(200);
random = getRandomInt(1,200);
result = db.collection('FunnyStory').findOne({id: random});
user = result;
//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)=>{
var db = client.db('redditjoke');
json_max = 70;
random = getRandomInt(json_max);
random = getRandomInt(1,json_max);
result = db.collection('reddit').findOne({id: random});
user = result;
//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)=>{
//Function for giving out information to user to control the bot
runHelp = (user_channel) =>{
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"
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"
current_jokes = "Joke types I have: general , knock-knock , programming , reddit, funny story"
bot.postMessageToChannel(user_channel, comment + current_jokes ,emoji.emojis('question'));
}
......