-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSendResumebot.js
More file actions
46 lines (40 loc) · 1.22 KB
/
SendResumebot.js
File metadata and controls
46 lines (40 loc) · 1.22 KB
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
46
import 'dotenv/config'
import Telegraf from "telegraf";
import axios from "axios";
import validator from "validator";
const SendResumeBot = () => {
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.start((ctx) =>
ctx.reply(
`Hello ${ctx.from.first_name} \n/send <email> \t - to send resume`
)
);
bot.command("send",async (ctx) => {
let mail = null;
mail = ctx.message.text;
mail = mail.split(" ");
mail = mail[1];
//check if email is valid
const valid_email = validator.isEmail(mail);
// if email is valid then start the process
if (valid_email) {
try {
const resp = await axios.get(`http://localhost:${process.env.PORT}/api/sendMail/mail=${mail}`)
if (resp.data.status === 400) {
ctx.reply(`email has been sent to : \n${mail} Sucessfully ✨`);
ctx.reply(
`Don't worry, you'll get a Job soon.\ngood things take time ❤️`
);
}
} catch (error) {
console.log(error);
ctx.reply(`Couldn't send Email ✉️`);
ctx.reply(`Probably API is not wroking 😥`);
}
} else {
ctx.reply("Please enter a valid email");
}
});
bot.launch();
};
export default SendResumeBot;