├── .gitignore
├── .github
└── FUNDING.yml
├── ecosystem.config.js
├── CHANGELOG.md
├── CONTRIBUTING.md
├── package.json
├── LICENSE.md
├── .all-contributorsrc
├── .snyk
├── CODE_OF_CONDUCT
├── README.md
└── server.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: https://liberapay.com/DevCreatives/donate
2 |
--------------------------------------------------------------------------------
/ecosystem.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | apps: [
3 | {
4 | name: "API",
5 | script: "server.js",
6 | instances: "max",
7 | exec_mode: "cluster",
8 | kill_timeout: 1000,
9 | max_memory_restart: "100M",
10 | env: {
11 | NODE_ENV: "development"
12 | },
13 | env_production: {
14 | PORT: process.env.PORT,
15 | NODE_ENV: "production"
16 | }
17 | }
18 | ]
19 | };
20 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to the "Whatsapp Bot" will be documented in this file.
4 |
5 | ## Whatsapp Bot [1.0.0] - 2019-09-01 (Released)
6 | ### Added
7 | - Added Node JS Server added by [@viveksharmaui](https://github.com/viveksharmaui).
8 | - Added Web Scrapping added by [@viveksharmaui](https://github.com/viveksharmaui).
9 | - Added Dialog Flow added by [@viveksharmaui](https://github.com/viveksharmaui).
10 | - Added Twilio added by [@viveksharmaui](https://github.com/viveksharmaui).
11 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribution instructions
2 |
3 | ## Shipping a new functionality
4 |
5 | 1. You can only contribute on master branch.
6 | 2. Fork this repo.
7 | 3. Pull master branch.
8 | 4. Contribute something great.
9 | 5. Don't forget to write unit/integration/e2e/stress test.
10 | 6. Create pull request of your branch to master branch.
11 | 7. Wait for Travis CI test to be passed.
12 | 8. Wait for reviewer to review pull request file changes (This process can take upto few day's so relax).
13 | 9. Wait for admistrator to merge pull request with master branch.
14 | 10. After doing all above steps now wait to see your changes in master and in production (This process can takes upto few weeks or months when we RELEASED new version).
15 |
16 |
17 | **Happy Contributing**
18 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wabot",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "server.js",
6 | "scripts": {
7 | "start": "pm2-runtime start ecosystem.config.js --env production",
8 | "dev": "nodemon server.js",
9 | "snyk-protect": "snyk protect",
10 | "prepublish": "npm run snyk-protect"
11 | },
12 | "author": "vivek",
13 | "license": "ISC",
14 | "dependencies": {
15 | "axios": "^0.18.0",
16 | "body-parser": "^1.18.3",
17 | "cheerio": "^1.0.0-rc.2",
18 | "express": "^4.16.4",
19 | "fs": "0.0.1-security",
20 | "github-search-repos": "^3.0.0",
21 | "google": "^2.1.0",
22 | "image-scraper": "^0.2.1",
23 | "pm2": "^3.2.2",
24 | "yt-search": "^0.2.0",
25 | "snyk": "^1.231.1"
26 | },
27 | "snyk": true
28 | }
29 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Whatsapp Bot
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "files": [
3 | "README.md"
4 | ],
5 | "imageSize": 100,
6 | "commit": false,
7 | "contributors": [
8 | {
9 | "login": "Ramsha196",
10 | "name": "Ramsha196",
11 | "avatar_url": "https://avatars0.githubusercontent.com/u/46401119?v=4",
12 | "profile": "https://github.com/Ramsha196",
13 | "contributions": [
14 | "code",
15 | "doc"
16 | ]
17 | },
18 | {
19 | "login": "viveksharmaui",
20 | "name": "Vivek Anand Sharma",
21 | "avatar_url": "https://avatars1.githubusercontent.com/u/28563357?v=4",
22 | "profile": "https://viveksharmaui.js.org",
23 | "contributions": [
24 | "infra",
25 | "test",
26 | "code",
27 | "doc",
28 | "bug"
29 | ]
30 | },
31 | {
32 | "login": "Mudassar045",
33 | "name": "Mudassar Ali",
34 | "avatar_url": "https://avatars0.githubusercontent.com/u/24487349?v=4",
35 | "profile": "https://github.com/Mudassar045",
36 | "contributions": [
37 | "doc"
38 | ]
39 | }
40 | ],
41 | "contributorsPerLine": 7,
42 | "projectName": "Whatsapp-Bot",
43 | "projectOwner": "Techistan",
44 | "repoType": "github",
45 | "repoHost": "https://github.com"
46 | }
47 |
--------------------------------------------------------------------------------
/.snyk:
--------------------------------------------------------------------------------
1 | # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2 | version: v1.13.5
3 | ignore: {}
4 | # patches apply the minimum changes required to fix a vulnerability
5 | patch:
6 | SNYK-JS-LODASH-450202:
7 | - cheerio > lodash:
8 | patched: '2019-07-05T06:08:25.711Z'
9 | - pm2 > async > lodash:
10 | patched: '2019-07-05T06:08:25.711Z'
11 | - pm2 > @pm2/js-api > async > lodash:
12 | patched: '2019-07-05T06:08:25.711Z'
13 | - pm2 > pm2-deploy > async > lodash:
14 | patched: '2019-07-05T06:08:25.711Z'
15 | - pm2 > vizion > async > lodash:
16 | patched: '2019-07-05T06:08:25.711Z'
17 | SNYK-JS-HTTPSPROXYAGENT-469131:
18 | - snyk > proxy-agent > https-proxy-agent:
19 | patched: '2019-10-05T02:54:55.759Z'
20 | - snyk > proxy-agent > pac-proxy-agent > https-proxy-agent:
21 | patched: '2019-10-05T02:54:55.759Z'
22 | - snyk > proxy-agent > https-proxy-agent:
23 | patched: '2019-10-07T10:51:37.025Z'
24 | - snyk > proxy-agent > pac-proxy-agent > https-proxy-agent:
25 | patched: '2019-10-07T10:51:37.025Z'
26 | - pm2 > @pm2/agent > proxy-agent > https-proxy-agent:
27 | patched: '2019-10-07T10:51:37.025Z'
28 | - pm2 > @pm2/agent > proxy-agent > pac-proxy-agent > https-proxy-agent:
29 | patched: '2019-10-07T10:51:37.025Z'
30 | - pm2 > @pm2/io > @pm2/agent-node > proxy-agent > https-proxy-agent:
31 | patched: '2019-10-07T10:51:37.025Z'
32 | - pm2 > @pm2/io > @pm2/agent-node > proxy-agent > pac-proxy-agent > https-proxy-agent:
33 | patched: '2019-10-07T10:51:37.025Z'
34 | 'npm:lodash:20180130':
35 | - google > cheerio > lodash:
36 | patched: '2019-10-07T10:51:37.025Z'
37 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at sharma_vivek62@yahoo.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Whatsapp Bot
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | ## Introduction
10 |
11 | It is a chatbot built with `Node JS` webhook server, it uses Dialogflow functionality to answer the end user query which it receives from twilio.
12 |
13 | ## How to use it
14 |
15 | Send a WhatsApp message to `+1 415 523 8886` containing code `join cream-buffalo`
16 |
17 | ## What we are achieving to do
18 |
19 | A chatbot can communicate with a real person behaving like a human. You can create chatbots for any business the same as you recruit a person for any department of your company. Similarly this chatbot can do several things for you. Its purpose is to create an advance bot which doesn't require whatsapp user to keep changing the tabs to do things. The bot can download tv serials, songs, movies, books from YouTube or any other website.
20 |
21 | ## Unique Features
22 |
23 | - Direct Download videos/tv serials/books via link
24 | - Can search Github repository for the end user
25 | - Can search YouTube video
26 | - Get celebrities' biography
27 |
28 | ## What is our goal
29 |
30 | Our goal is to create an advance bot which can do things for the whatsapp user. Our future goal is to get this project on advance level, we will add aforementioned features soon. We will add new features for `Github` by using GitHub API and also add the functionality to download YouTube videos to mp3 and in any video format. A user can also be able to download the whole `PDF` file containing biography of that celebrity.
31 |
32 | ## Report a Bug
33 |
34 | If you find any bug, please create an issue in [issues](https://github.com/Techistan/Whatsapp-Bot/issues) section so that our team will fix bug as soon as possible.
35 |
36 | ## How you can contribute
37 |
38 | Any idea or contribution for this project is always welcome. If you have any idea or want to contribute, please first create an issue
39 | then we will assign that issue to you.
40 |
41 | ## Contributors ✨
42 |
43 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
44 |
45 |
46 |
47 |
54 |
55 |
56 |
57 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!
58 |
--------------------------------------------------------------------------------
/server.js:
--------------------------------------------------------------------------------
1 | //Importing Modules
2 | const http = require("http");
3 | const express = require("express");
4 | const bodyParser = require("body-parser");
5 | const axios = require("axios");
6 | const cheerio = require("cheerio");
7 | const gitHub = require("github-search-repos");
8 | const google = require("google");
9 | const ytSearch = require("yt-search");
10 | const Scraper = require("image-scraper");
11 |
12 | //App Container
13 | const app = express();
14 |
15 | //Middleware
16 | app.use(
17 | bodyParser.urlencoded({
18 | extended: true
19 | })
20 | );
21 | app.use(bodyParser.json());
22 |
23 | //Route (API)
24 |
25 | //Perform Different Operations
26 | app.post("/webhook", (req, res) => {
27 | //Request Text from Dialog Flow
28 | let reqText = req.body.queryResult.queryText;
29 |
30 | //Request parameter of Github repo from Dialog Flow
31 | let reqPara = req.body.queryResult.parameters.repo;
32 |
33 | //Request parameter Google Search from Dialog Flow
34 | let reqSearch = req.body.queryResult.parameters.search;
35 |
36 | //Request parameter Youtube Search from Dialog Flow
37 | let reqUtubeSearch = req.body.queryResult.parameters.youtube;
38 |
39 | //Request parameter Britannica from Dialog Flow
40 | let reqBritannica = req.body.queryResult.parameters.britannica;
41 |
42 | //Request parameter image url from Dialog Flow for downloading image from that url
43 | let reqImgURL = req.body.queryResult.parameters.imgurl;
44 |
45 | //Request parameter movie from Dialog Flow for downloading movies from google
46 | let reqMovie = req.body.queryResult.parameters.movie;
47 |
48 | //Request parameter movie from Dialog Flow for downloading tv serial from google
49 | let reqSerial = req.body.queryResult.parameters.serial;
50 |
51 | //Request parameter mp3 from Dialog Flow for downloading mp3 musics
52 | let reqMP3 = req.body.queryResult.parameters.mp3;
53 |
54 | //Request parameter pdf from Dialog Flow for download pdf books
55 | let reqPDF = req.body.queryResult.parameters.pdf;
56 |
57 | //Request parameter pdf from Dialog Flow for download video songs
58 | let reqVideo = req.body.queryResult.parameters.video;
59 |
60 | //If User Ask
61 | if (
62 | reqText === "who are you ?" &&
63 | reqVideo === undefined &&
64 | reqPDF === undefined &&
65 | reqSerial === undefined &&
66 | reqMP3 === undefined &&
67 | reqMovie === undefined &&
68 | reqImgURL === undefined &&
69 | reqPara === undefined &&
70 | reqSearch === undefined &&
71 | reqUtubeSearch === undefined &&
72 | reqBritannica === undefined
73 | ) {
74 | return res.json({
75 | fulfillmentText:
76 | "I am whatsapp bot created by Vivek Anand Sharma. I'm created with Twilio+DialogFlow and Node Js as WebHook Server",
77 | source: "info"
78 | });
79 | }
80 |
81 | if (
82 | reqText === "can you perform google search ?" &&
83 | reqVideo === undefined &&
84 | reqPDF === undefined &&
85 | reqSerial === undefined &&
86 | reqMP3 === undefined &&
87 | reqMovie === undefined &&
88 | reqImgURL === undefined &&
89 | reqPara === undefined &&
90 | reqSearch === undefined &&
91 | reqUtubeSearch === undefined &&
92 | reqBritannica === undefined
93 | ) {
94 | return res.json({
95 | fulfillmentText: "Yes I can with command i.e google search anything",
96 | source: "info"
97 | });
98 | }
99 | if (
100 | reqText === "can you perform github search ?" &&
101 | reqVideo === undefined &&
102 | reqPDF === undefined &&
103 | reqSerial === undefined &&
104 | reqMP3 === undefined &&
105 | reqMovie === undefined &&
106 | reqImgURL === undefined &&
107 | reqPara === undefined &&
108 | reqSearch === undefined &&
109 | reqUtubeSearch === undefined &&
110 | reqBritannica === undefined
111 | ) {
112 | return res.json({
113 | fulfillmentText: "Yes I can with command i.e git search repo-name",
114 | source: "info"
115 | });
116 | }
117 | if (
118 | reqText === "can you perform youtube search ?" &&
119 | reqVideo === undefined &&
120 | reqPDF === undefined &&
121 | reqSerial === undefined &&
122 | reqMP3 === undefined &&
123 | reqMovie === undefined &&
124 | reqImgURL === undefined &&
125 | reqPara === undefined &&
126 | reqSearch === undefined &&
127 | reqUtubeSearch === undefined &&
128 | reqBritannica === undefined
129 | ) {
130 | return res.json({
131 | fulfillmentText: "Yes I can with command i.e youtube search anything",
132 | source: "info"
133 | });
134 | }
135 | if (
136 | reqText === "what happened on this day ?" &&
137 | reqVideo === undefined &&
138 | reqPDF === undefined &&
139 | reqSerial === undefined &&
140 | reqMP3 === undefined &&
141 | reqMovie === undefined &&
142 | reqImgURL === undefined &&
143 | reqPara === undefined &&
144 | reqSearch === undefined &&
145 | reqUtubeSearch === undefined &&
146 | reqBritannica === undefined
147 | ) {
148 | axios.get("https://www.history.com/this-day-in-history").then(response => {
149 | if (response.status === 200) {
150 | const html = response.data;
151 | const $ = cheerio.load(html);
152 | let onThisDay;
153 | $(".m-detail--body").each(function(i, elem) {
154 | onThisDay = {
155 | theory: $(this)
156 | .find("p")
157 | .text()
158 | .trim()
159 | };
160 | });
161 | let bioIndex = onThisDay.theory.indexOf(".");
162 | let bioOnThisDay = onThisDay.theory.slice(0, bioIndex);
163 | return res.json({
164 | fulfillmentText: "ON THIS DAY : " + bioOnThisDay,
165 | source: "info"
166 | });
167 | }
168 | });
169 | }
170 |
171 | //Github Search Validation
172 | if (
173 | reqText !== "git search" ||
174 | (reqPara !== "" &&
175 | reqVideo === undefined &&
176 | reqPDF === undefined &&
177 | reqSerial === undefined &&
178 | reqMP3 === undefined &&
179 | reqMovie === undefined &&
180 | reqImgURL === undefined &&
181 | reqSearch === undefined &&
182 | reqUtubeSearch === undefined &&
183 | reqBritannica === undefined)
184 | ) {
185 | if (reqText.includes("git search")) {
186 | gitHub(reqPara).then(data => {
187 | return res.json({
188 | fulfillmentText:
189 | "URL : " +
190 | data.items[0].html_url +
191 | " Watchers : " +
192 | data.items[0].watchers,
193 | source: "info"
194 | });
195 | });
196 | }
197 | }
198 |
199 | //Google Search Validation
200 | if (
201 | reqText !== "google search" ||
202 | (reqSearch !== "" &&
203 | reqVideo === undefined &&
204 | reqPDF === undefined &&
205 | reqSerial === undefined &&
206 | reqMP3 === undefined &&
207 | reqMovie === undefined &&
208 | reqImgURL === undefined &&
209 | reqPara === undefined &&
210 | reqUtubeSearch === undefined &&
211 | reqBritannica === undefined)
212 | ) {
213 | if (reqText.includes("google search")) {
214 | google(reqSearch, function(err, response) {
215 | if (err) console.error(err);
216 | let link = response.links[0];
217 | return res.json({
218 | fulfillmentText:
219 | "Title : " +
220 | link.title +
221 | " URL : " +
222 | link.href +
223 | " Description : " +
224 | link.description,
225 | source: "info"
226 | });
227 | });
228 | }
229 | }
230 |
231 | //Youtube Search Validation
232 | if (
233 | reqText !== "youtube search" ||
234 | (reqUtubeSearch !== "" &&
235 | reqVideo === undefined &&
236 | reqPDF === undefined &&
237 | reqSerial === undefined &&
238 | reqMP3 === undefined &&
239 | reqMovie === undefined &&
240 | reqImgURL === undefined &&
241 | reqSearch === undefined &&
242 | reqPara === undefined &&
243 | reqBritannica === undefined)
244 | ) {
245 | if (reqText.includes("youtube search")) {
246 | ytSearch(reqUtubeSearch, function(err, r) {
247 | if (err) throw err;
248 | const videos = r.videos;
249 | const firstResult = videos[0];
250 | return res.json({
251 | fulfillmentText:
252 | "Title : " +
253 | firstResult.title +
254 | " URL : https://www.youtube.com" +
255 | firstResult.url +
256 | " Views : " +
257 | firstResult.views,
258 | source: "info"
259 | });
260 | });
261 | }
262 | }
263 |
264 | //Britannica Scrapping
265 | if (reqBritannica !== undefined) {
266 | if (
267 | reqText !== "do you know about" ||
268 | (reqBritannica !== "" &&
269 | reqVideo === undefined &&
270 | reqPDF === undefined &&
271 | reqSerial === undefined &&
272 | reqMP3 === undefined &&
273 | reqMovie === undefined &&
274 | reqImgURL === undefined &&
275 | reqSearch === undefined &&
276 | reqPara === undefined &&
277 | reqUtubeSearch === undefined)
278 | ) {
279 | let TrimmedString = reqBritannica.trim();
280 | let finalString = TrimmedString.replace(/ /g, "-");
281 | if (reqText.includes("do you know about")) {
282 | axios.get("https://www.britannica.com/biography/" + finalString).then(
283 | response => {
284 | if (response.status === 200) {
285 | const html = response.data;
286 | const $ = cheerio.load(html);
287 | let bio;
288 | $("#ref1").each(function(i, elem) {
289 | bio = {
290 | author: $(this)
291 | .find("p")
292 | .text()
293 | .trim()
294 | };
295 | });
296 | let bioIndex = bio.author.indexOf(".");
297 | let biography = bio.author.slice(0, bioIndex);
298 | return res.json({
299 | fulfillmentText: biography,
300 | source: "info"
301 | });
302 | }
303 | },
304 | error =>
305 | google(finalString, function(err, response) {
306 | if (err) console.error(err);
307 | let link = response.links[0];
308 | return res.json({
309 | fulfillmentText:
310 | "Did not find anything on db here is google search result . Title : " +
311 | link.title +
312 | " URL : " +
313 | link.href +
314 | " Description : " +
315 | link.description,
316 | source: "info"
317 | });
318 | })
319 | );
320 | }
321 | }
322 | }
323 |
324 | //Scrapping URL Image's
325 | if (reqImgURL !== undefined) {
326 | if (
327 | reqText !== "download image" ||
328 | (reqImgURL !== "" &&
329 | reqVideo === undefined &&
330 | reqPDF === undefined &&
331 | reqSerial === undefined &&
332 | reqMP3 === undefined &&
333 | reqMovie === undefined &&
334 | reqBritannica === undefined &&
335 | reqSearch === undefined &&
336 | reqPara === undefined &&
337 | reqUtubeSearch === undefined)
338 | ) {
339 | if (reqText.includes("download image")) {
340 | let scraper = new Scraper(reqImgURL);
341 | scraper.scrape(function(image) {
342 | if (image.address !== undefined) {
343 | return res.json({
344 | fulfillmentText: "You can download image here : " + image.address,
345 | source: "info"
346 | });
347 | }
348 | });
349 | }
350 | }
351 | }
352 |
353 | //Scrapping Google Search For Download Movie's
354 | if (reqMovie !== undefined) {
355 | if (
356 | reqText !== "download movie" ||
357 | (reqMovie !== "" &&
358 | reqVideo === undefined &&
359 | reqPDF === undefined &&
360 | reqSerial === undefined &&
361 | reqSearch == undefined &&
362 | reqMP3 === undefined &&
363 | reqImgURL === undefined &&
364 | reqPara === undefined &&
365 | reqUtubeSearch === undefined &&
366 | reqBritannica === undefined)
367 | ) {
368 | if (reqText.includes("download movie")) {
369 | google("intitle:index.of? mkv " + reqMovie, function(err, response) {
370 | if (err) console.error(err);
371 | let link = response.links[0];
372 | return res.json({
373 | fulfillmentText: "You can download this movie from : " + link.href,
374 | source: "info"
375 | });
376 | });
377 | }
378 | }
379 | }
380 |
381 | //Scrapping Google Search For Download TV Serial's
382 | if (reqSerial !== undefined) {
383 | if (
384 | reqText !== "download serial" ||
385 | (reqSerial !== "" &&
386 | reqVideo === undefined &&
387 | reqPDF === undefined &&
388 | reqMovie === undefined &&
389 | reqSearch == undefined &&
390 | reqMP3 === undefined &&
391 | reqImgURL === undefined &&
392 | reqPara === undefined &&
393 | reqUtubeSearch === undefined &&
394 | reqBritannica === undefined)
395 | ) {
396 | if (reqText.includes("download serial")) {
397 | google("intitle:index.of? mkv " + reqSerial, function(err, response) {
398 | if (err) console.error(err);
399 | let link = response.links[0];
400 | return res.json({
401 | fulfillmentText:
402 | "You can download this tv serial from : " + link.href,
403 | source: "info"
404 | });
405 | });
406 | }
407 | }
408 | }
409 |
410 | //Scrapping Google Search For Download MP3
411 | if (reqMP3 !== undefined) {
412 | if (
413 | reqText !== "download mp3" ||
414 | (reqMP3 !== "" &&
415 | reqVideo === undefined &&
416 | reqPDF === undefined &&
417 | reqSerial === undefined &&
418 | reqSearch == undefined &&
419 | reqMovie === undefined &&
420 | reqImgURL === undefined &&
421 | reqPara === undefined &&
422 | reqUtubeSearch === undefined &&
423 | reqBritannica === undefined)
424 | ) {
425 | if (reqText.includes("download mp3")) {
426 | google("intitle:index.of? mp3 " + reqMP3, function(err, response) {
427 | if (err) console.error(err);
428 | let link = response.links[0];
429 | return res.json({
430 | fulfillmentText: "You can download this mp3 from : " + link.href,
431 | source: "info"
432 | });
433 | });
434 | }
435 | }
436 | }
437 |
438 | //Scrapping Google Search For Download PDF
439 | if (reqPDF !== undefined) {
440 | if (
441 | reqText !== "download pdf" ||
442 | (reqPDF !== "" &&
443 | reqVideo === undefined &&
444 | reqMP3 === undefined &&
445 | reqSerial === undefined &&
446 | reqSearch == undefined &&
447 | reqMovie === undefined &&
448 | reqImgURL === undefined &&
449 | reqPara === undefined &&
450 | reqUtubeSearch === undefined &&
451 | reqBritannica === undefined)
452 | ) {
453 | if (reqText.includes("download pdf")) {
454 | google("intitle:index.of? pdf " + reqPDF, function(err, response) {
455 | if (err) console.error(err);
456 | let link = response.links[0];
457 | return res.json({
458 | fulfillmentText: "You can download this pdf from : " + link.href,
459 | source: "info"
460 | });
461 | });
462 | }
463 | }
464 | }
465 |
466 | //Scrapping Google Search For Download Video Song's
467 | if (reqVideo !== undefined) {
468 | if (
469 | reqText !== "download video" ||
470 | (reqVideo !== "" &&
471 | reqPDF === undefined &&
472 | reqMP3 === undefined &&
473 | reqSerial === undefined &&
474 | reqSearch == undefined &&
475 | reqMovie === undefined &&
476 | reqImgURL === undefined &&
477 | reqPara === undefined &&
478 | reqUtubeSearch === undefined &&
479 | reqBritannica === undefined)
480 | ) {
481 | if (reqText.includes("download video")) {
482 | google("intitle:index.of? mp4 " + reqVideo, function(err, response) {
483 | if (err) console.error(err);
484 | let link = response.links[0];
485 | return res.json({
486 | fulfillmentText: "You can download this video from : " + link.href,
487 | source: "info"
488 | });
489 | });
490 | }
491 | }
492 | }
493 | });
494 |
495 | //Server Listen Port
496 | app.listen(process.env.PORT, err => {
497 | if (err) console.log("err");
498 | else console.log("Server is running");
499 | });
500 |
--------------------------------------------------------------------------------