This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
48 lines (38 loc) · 1.25 KB
/
Copy pathapp.js
File metadata and controls
48 lines (38 loc) · 1.25 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
47
48
var _ = require('lodash');
var Sequelize = require('sequelize');
var config = require('./config.json');
var utils = require('./utils');
var Fetcher = require('./fetcher');
var fetch = new Fetcher();
process.on('uncaughtException', function(err) {
console.log('[Error] ' + err);
});
var sequelize = new Sequelize(config.db.uri, {
logging: function(str) {
// console.log(str);
}
});
var Paste = sequelize.import(__dirname + "/models");
console.log('[Status] Synchronizing Database..');
sequelize.sync()
.then(function() {
console.log('[Status] Done Synchronizing Database.');
})
.catch(function(error) {
console.log('[Error] Error Synchronizing Database. ' + error);
});
fetch.on('error', function(data) {
console.log('[Error] ' + data);
});
fetch.on('archive.pasteid', function(data) {
});
fetch.on('new', function(data) {
Paste.create(data);
_.each(config.keywords, function(keyword) {
if(data.content.indexOf(keyword) > -1) {
console.log("[Keyword Found] Keyword '" + keyword + "' found on pastebin content: http://pastebin.com/" + data.pastebin_id);
}
});
});
fetch.start();
setInterval(fetch.start, config.delay);