Skip to content

Commit f5ae6a4

Browse files
committed
Initial commit
0 parents  commit f5ae6a4

File tree

4 files changed

+560
-0
lines changed

4 files changed

+560
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

database.sql

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 5.0.4
3+
-- https://www.phpmyadmin.net/
4+
--
5+
-- Host: 127.0.0.1
6+
-- Generation Time: Feb 04, 2021 at 08:26 PM
7+
-- Server version: 10.4.17-MariaDB
8+
-- PHP Version: 8.0.1
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
START TRANSACTION;
12+
SET time_zone = "+00:00";
13+
14+
15+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
16+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
17+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
18+
/*!40101 SET NAMES utf8mb4 */;
19+
20+
--
21+
-- Database: `mangadex`
22+
--
23+
24+
-- --------------------------------------------------------
25+
26+
--
27+
-- Table structure for table `announced`
28+
--
29+
30+
CREATE TABLE `announced` (
31+
`title` varchar(512) NOT NULL
32+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
33+
34+
--
35+
-- Indexes for dumped tables
36+
--
37+
38+
--
39+
-- Indexes for table `announced`
40+
--
41+
ALTER TABLE `announced`
42+
ADD PRIMARY KEY (`title`);
43+
COMMIT;
44+
45+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
46+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
47+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

index.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//Settings
2+
var mangadex_token = "YOUR_MANGADEX_TOKEN";
3+
var discord_webhook = "YOUR_DISCORD_WEBOOK_URL";
4+
var discord_thumbnail = "IMAGE_URL_FOR_THUMBNAIL";
5+
var prefix_filter = "Ijiranaide, Nagatoro-san - "; // example prefix filter
6+
var timeout = 60;
7+
var mysql_host = "localhost";
8+
var mysql_user = "";
9+
var mysql_pass = "";
10+
var mysql_db = "mangadex";
11+
12+
//Imports
13+
const feed = require('feed-read');
14+
const mysql = require('mysql');
15+
const { Webhook, MessageBuilder } = require("discord-webhook-node");
16+
const hook = new Webhook(discord_webhook);
17+
18+
var con = mysql.createConnection({host: mysql_host, user: mysql_user, database: mysql_db });
19+
20+
function requestFeed() {
21+
feed("https://mangadex.org/rss/follows/" + mangadex_token, onRssFetched);
22+
}
23+
24+
function onRssFetched(err, articles) {
25+
26+
if(err) throw err;
27+
28+
con.query("SELECT * FROM announced", function (err, result) {
29+
if(err) throw err;
30+
31+
var list = [];
32+
33+
34+
for (i = 0; i < result.length; i++) {
35+
if(!list.includes(result[i].title)) list.push(result[i].title);
36+
}
37+
38+
for (i = 0; i < articles.length; i++) {
39+
if(!list.includes(articles[i].title)){
40+
41+
list.push(articles[i].title);
42+
43+
con.query("INSERT INTO announced (title) VALUES ('" + articles[i].title + "')");
44+
45+
var filterd = articles[i].title;
46+
filterd = filterd.replace(prefix_filter, "");
47+
console.log("Manga " + filterd + " Has been added.");
48+
49+
const embed = new MessageBuilder()
50+
.setTitle(filterd)
51+
.setColor("#aabbcc")
52+
.setDescription("New chapter just released!\nCheck it out in the link below:\n\n" + articles[i].link)
53+
.setURL(articles[i].link)
54+
.setFooter("Announcer developed by MVDW-Java on Github.")
55+
.setThumbnail(discord_thumbnail)
56+
.setTimestamp();
57+
58+
hook.send(embed);
59+
}
60+
}
61+
});
62+
}
63+
64+
setInterval(requestFeed, timeout * 1000);
65+
requestFeed();

0 commit comments

Comments
 (0)