This commit is contained in:
karl.hudgell 2020-06-24 08:03:53 +01:00
parent 49056b195c
commit fd9446db1b

31
app.js
View File

@ -27,7 +27,7 @@ const bot = new TelegramBot(token, {
// Wlecome Message
bot.on('new_chat_members', (msg) => {
const newUserMention = "<a href=\"tg:\/\/user?id=" + msg.new_chat_member.id + "\">@" + 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()