-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (33 loc) · 1.45 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const dotenv = require('dotenv');
const Telegraf = require('telegraf');
const define = require("./define");
dotenv.load({ path: '.env' });
const bot = new Telegraf(process.env.TELEBOT_JINTECH);
const commonText = `Jai Jinendra!\n\nWelcome to JinSwara bot.\n\nMessage in following format to get the definition of any Jainism Terminology.\n\n/define जैन\n\n Type /about for more info.\n\nType /ask to ask a question.\n\nType /contact to connect to the team.`;
bot.start((req) => req.reply(commonText));
bot.command('about', (req) => {
req.reply("I'm JinSwara Bot! Please visit jinswara.com for more details.");
});
bot.command('ask', (req) => {
req.reply("Please visit forum.jinswara.com to ask Jainism related questions.");
});
bot.command('contact', (req) => {
req.reply("Please contact connect@jinswara.com or join us https://t.me/JinSwara");
});
bot.command('define', (req) => {
let term = req.message.text.split(" ")[1];
if (define[term]) {
req.reply(define[term]);
} else {
req.reply(`The term ${term} is not yet defined in our database. Please contact our team at connect@jinswara.com`);
}
});
bot.command('scripture', (req) => {
const remoteFile = 'http://www.atmadharma.com/shastras/mokshmargprakashak_hin_scn.pdf'
return req.telegram.sendDocument(req.message.chat.id, remoteFile);
});
bot.on('message', (req) => {
req.reply(commonText);
});
bot.startPolling();
console.log("@JinSwaraBot Started!");