From fd9446db1b73b99634a75e0a74fd0454d8e61c49 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Wed, 24 Jun 2020 08:03:53 +0100 Subject: [PATCH] spaces --- app.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 3148caf..a561495 100644 --- a/app.js +++ b/app.js @@ -27,7 +27,7 @@ const bot = new TelegramBot(token, { // Wlecome Message bot.on('new_chat_members', (msg) => { const newUserMention = "@" + msg.new_chat_member.first_name + "<\/a>" - bot.sendMessage(msg.chat.id,"Hello " + newUserMention + ", Welcome to " + channel + ". \n\nPlease PM me @" + process.env.BOT_USERNAME + " to find out all needed information about our service before asking an admin or posting in here.\n\nIf you do ask questions, and its obvious you have not spoken to me, you will be booted from the room. This is IPTV, admins don't have time for hand holding.!!!", { parse_mode: "HTML" }); + bot.sendMessage(msg.chat.id, "Hello " + newUserMention + ", Welcome to " + channel + ". \n\nPlease PM me @" + process.env.BOT_USERNAME + " to find out all needed information about our service before asking an admin or posting in here.\n\nIf you do ask questions, and its obvious you have not spoken to me, you will be booted from the room. This is IPTV, admins don't have time for hand holding.!!!", { parse_mode: "HTML" }); logger.info("ID - " + msg.new_chat_member.id + " First Name - " + msg.new_chat_member.first_name + " joined the group"); }); @@ -101,6 +101,35 @@ bot.on('message', (msg) => { }) } + const joke = name.toLowerCase() + " tell me a joke"; + if (msg.text && msg.text.toString().toLowerCase().includes(joke)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for a joke"); + + var options = { + method: 'GET', + url: 'https://joke3.p.rapidapi.com/v1/joke', + qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' }, + headers: { + 'x-rapidapi-host': 'joke3.p.rapidapi.com', + 'x-rapidapi-key': process.env.RAPIDAPI_API_KEY, + useQueryString: true + }, + ttl: 18000 //5 hours + }; + + cachedRequest(options, function (error, response, body) { + if (error) throw new Error(error); + let jsonBody = JSON.parse(body) + bot.sendMessage(msg.chat.id, jsonBody.content) + } + ) + } + + const youThere = "you there " + name.toLowerCase() + "?"; + if (msg.text && msg.text.toString().toLowerCase().includes(youThere)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked if im there"); + bot.sendMessage(msg.chat.id, "Always..."); + } const fuuk = "fuck off "; const fuuckPlus = fuuk + name.toLowerCase()