Skip to content

Commit 4bc9d87

Browse files
committed
fix, cleanup and readme
1 parent bfc0aee commit 4bc9d87

File tree

7 files changed

+127
-649
lines changed

7 files changed

+127
-649
lines changed

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
.idea/
2-
bin/
3-
hikkabot
4-
.vscode/
5-
debug
6-
config.json
7-
config_prod.json
8-
hikkabot.db
2+
bin/

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# hikkabot
2+
3+
A Telegram subscription service for [2ch.hk](https://2ch.hk) and [reddit.com](https://reddit.com).
4+
Available at [@h1kkabot](https://t.me/h1kkabot).
5+
6+
7+
## Features
8+
9+
* Subscribe to a 2ch thread/board or a subreddit.
10+
* Manage group and channel subscriptions.
11+
* Receive alerts to all group/channel administrators about subscription changes.
12+
* Automatic WebM-to-MP4 conversion to leverage Telegram built-in video player.
13+
14+
### Available commands
15+
16+
#### sub
17+
18+
Usage: `/sub ITEM [CHAT_REF] [OPTIONS]`
19+
20+
| Parameter | Description |
21+
|-----------|-------------|
22+
| `ITEM` | See available services and their items description below. |
23+
| `CHAT_REF` | Chat to be subscribed to this item. Should be either empty or `.` for this chat and a username for any channel. |
24+
| `OPTIONS` | Each item has its own options, check below. |
25+
26+
27+
#### suspend & resume
28+
29+
Usage: `/suspend ITEM_ID` OR `/resume ITEM_ID`
30+
31+
Suspend an active subscription OR Resume an inactive subscription.
32+
33+
`ITEM_ID` is a primary subscription item ID and is generally not exposed to an end-user.
34+
As such, manual execution of these commands is not possible.
35+
Instead, under every subscription state change message sent to all chat administrators there is a Suspend or Resume button.
36+
37+
#### status
38+
39+
Usage: `/status`
40+
41+
Simply returns an `OK` string.
42+
43+
### Available services
44+
45+
| Service | Item | Item examples | Options |
46+
|---|---|---|---|
47+
| Dvach/Thread | Thread URL | `https://2ch.hk/b/res/12345678.html` | `m` for streaming only media files. |
48+
| Dvach/Catalog | Board URL or code (end slashes are optional) | `https://2ch.hk/b[/]` <br><br> `/b[/]` | Regexp for filtering threads. Defaults to `.*`. |
49+
| Reddit | Subreddit URL or code with optional sort | `https://reddit.com/r/meirl[/hot]` <br><br> `/r/meirl[/hot]` | Minimum amount of ups. Defaults to -1. |
50+
51+
52+
## Usage
53+
54+
### Prerequisites
55+
56+
An SQL database server should be installed (PostgreSQL recommended).
57+
58+
### Configuration
59+
60+
Hikkabot requires a JSON configuration file. The path must be provided as the first command-line argument.
61+
62+
You can use [this skeleton](https://github.com/jfk9w/hikkabot/blob/master/config.json) to build the configuration upon.
63+
64+
### Installation and execution
65+
66+
Install using Go package manager:
67+
68+
```bash
69+
$ go install github.com/jfk9w/hikkabot
70+
$ hikkabot config.json
71+
```

config.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
// Your telegram user ID
3+
"AdminID": 12345678,
4+
"Storage": {
5+
// SQL driver to be used
6+
"Driver": "postgres",
7+
// Datasource connection string
8+
"Datasource": "postgres://postgres:postgres@postgres/postgres"
9+
},
10+
// How often should subscription update check occur
11+
"UpdateInterval": "10s",
12+
// Aliases allow to map certain CHAT_REFs to telegram chat IDs
13+
// May be useful for managing private channels and aliasing long channel usernames
14+
"Aliases": {
15+
"my_ref": -10000000000000000
16+
},
17+
"Telegram": {
18+
// Telegram Bot API token
19+
"Token": "2352626236:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
20+
},
21+
"Media": {
22+
"Aconvert": {
23+
// Maximum queue size fot aconvert.com client
24+
"QueueSize": 100,
25+
// Times a failed request will be retried
26+
"MaxRetries": 3,
27+
// Test file is used for aconvert.com client initialization
28+
// Should be a path to any media file supported by aconvert.com
29+
"TestFile": "test_media.webm",
30+
// Test format is used for aconvert.com client initialization
31+
// This is a target format for a media file specified above
32+
"TestFormat": "mp4"
33+
},
34+
// Number of maximum simultaneous media downloads
35+
"Workers": 13,
36+
// Temporary directory for media files
37+
"TempDir": "/tmp/hikkabot"
38+
},
39+
"Dvach": {
40+
// 2ch.hk client is updated with a cookie with this usercode
41+
// This may allow to access /e/, /hc/, etc.
42+
"Usercode": "fcdebafcde8642143"
43+
},
44+
"Reddit": {
45+
"ClientID": "iuYGY&b328fd",
46+
"ClientSecret": "a088HUUIHEAFjn9hesg",
47+
"Username": "username",
48+
"Password": "password",
49+
"UserAgent": "Your user agent 5.0",
50+
// Times a failed request will be retried
51+
"MaxRetries": 3
52+
}
53+
}

0 commit comments

Comments
 (0)