Skip to content

Commit

Permalink
Fix redundant forward slashes in URL + Add documentation in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Coko7 committed Feb 9, 2022
1 parent 77a825a commit 2ac0beb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
# tcb-opus

A discord bot to get the latest manga chapters as soon as they comes out.
## What is it?

`tcb-opus` is a Discord bot you can use to get the latest manga chapters from **TCBScans** as soon as they come out!

To work properly, you first need to configure one of the channels in your Discord server to follow updates from the `#releases` text channel on the official TCB Discord server. This will cause any message posted by the original TCB bot in the `#releases` channel to be forwarded to your own channel on your Discord server.

Once a message is forwarded to your Discord channel, `tcb-opus` will analyse it and determine to what manga it corresponds. Once a valid manga has been recognized, `tcb-opus` will attempt to fetch the URL of the latest chapter for that manga from TCBScans. It will then send a message containing the chapter URL to whatever channel you like on your Discord server.

## Prequisites

Please make sure you have both [npm](https://www.npmjs.com/) and [Node.js](https://nodejs.org/) **v16.6+** installed otherwise this bot will not work.

## Installation

Simply run the following command to install to install the required packages:
Simply run the following command to install to install the required dependencies on your system:

```sh
npm i
```

## Configuration

Before running the bot for the first, you need to modify its configuration in [config.json](config.json). Here is what the default configuration file looks like:
Before running the bot for the first time, you need to modify its configuration in [config.json](config.json). Here is what the default configuration file looks like:

```json
{
Expand All @@ -29,7 +39,9 @@ Before running the bot for the first, you need to modify its configuration in [c
}
}
```

Here is the list of keys you can set:

- token: The token of your discord bot
- opus:
- mangas: The names of the mangas you are interested in
Expand Down
2 changes: 1 addition & 1 deletion data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "One Piece",
"chapter": "1039",
"url": "https://onepiecechapters.com//chapters/391/one-piece-chapter-1039"
"url": "https://onepiecechapters.com/chapters/391/one-piece-chapter-1039"
}
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tcb-opus",
"version": "1.0.0",
"description": "A discord bot to get the latest manga chapters as soon as they comes out.",
"version": "1.0.1",
"description": "A discord bot to get the latest manga chapters from TCBScans as soon as they come out.",
"main": "index.js",
"scripts": {
"start": "node index.js",
Expand Down
5 changes: 3 additions & 2 deletions scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function fetchLatestChapter(manga, website) {
if (chapNumStart === -1) {
return {
// Remove excess slashes from the URL
url: (website + url).replace(/\/+/g, "/"),
url: (website + url).replace(/([^:]\/)\/+/g, "$1"),
};
}

Expand All @@ -45,7 +45,8 @@ async function fetchLatestChapter(manga, website) {

return {
chapter: chapNum,
url: website + url,
// Remove excess slashes from the URL
url: (website + url).replace(/([^:]\/)\/+/g, "$1"),
};
}
}
Expand Down

0 comments on commit 2ac0beb

Please sign in to comment.