The telly-bot requires a LTS Node version (v12.0.0+).
Install required dependances.
yarn install
Create .env
file in the project root directory and fill in the project configuration including Telegram bot token and webhook host.
# Telegram bot settings. Must be set
TELEGRAM_BOT_TOKEN="Your Telegram Bot token"
WEBHOOK_HOST="Your server's public address (HTTPS protocol address is required)"
# Due to https://github.com/yagop/node-telegram-bot-api/issues/319
NTBA_FIX_319='any value'
The following are optional environment variables, please fill in as required.
# Optional settings
PORT="Server listenning port (4000 by default)"
GITHUB_PERSONAL_ACCESS_TOKEN="Your Github account personal access token"
# SOCKS5 proxy settings
PROXY_SOCKS5_HOST="Your SOCKS5 host"
PROXY_SOCKS5_PORT="Your SOCKS5 port"
PROXY_SOCKS5_USERNAME="Your SOCKS5 username"
PROXY_SOCKS5_PASSWORD="Your SOCKS5 password"
# HTTP proxy settings (PROXY_SOCKS5 settings above will override these settings)
PROXY_HTTP_PROTOCOL="Your HTTP proxy protocol type"
PROXY_HTTP_HOST="Your HTTP proxy host"
PROXY_HTTP_PORT="Your HTTP proxy port"
PROXY_HTTP_USERNAME="Your HTTP proxy username"
PROXY_HTTP_PASSWORD="Your HTTP proxy password"
Rename config.template.js
to config.js
. Modify the config file config.js
as prompted to connect to the PostgreSQL database:
database: {
postgresql: {
host: 'localhost',
port: 5432,
database: 'telly_bot_db',
user: 'telly_bot_db_user',
password: 'telly_bot_db_pwd',
timezone: '+08:00',
},
},
You can enable Github issue comment forwarding service by configuring config.js
:
github: {
forwardIssueComment: {
enable: true,
// Interval time(s) between execution of the next service
duration: 3600,
task: [
{
owner: 'github_repo_owner',
repo: 'github_repo_name',
issueNumber: 1,
// Only forward the comments of these users, empty means forward all
issueUserId: undefined,
// The ID of the channel to which the comment was forwarded. Example: @lolipop_thoughts
forwardChannelId: '@telegram_channel_id',
// Forward comments from this date
since: '2022-01-01T00:00:00.000Z',
},
],
},
},
This configuration means: the bot will automatically forward the comments of all users in https://github.com/github_repo_owner/github_repo_name/issues/1
to the @telegram_channel_id
channel, and the forwarded comments are last updated no earlier than 2022-01-01T00:00:00.000Z
. The execution interval between two services is 3600
seconds.
Telly-bot remembers the message corresponding to the comment, and when you edit the comment, the message will be updated, too.
You can enable Github issue comment forwarding service by configuring config.js
:
hexo: {
forwardHexoBlog: {
enable: true,
duration: 28800,
task: [
{
// Path of Hexo blog posts directory
path: 'path/to/source/_posts',
baseUrl: 'https://your_username.github.io',
// ':day' in permalink will be as ':day + offsetDay'
offsetDay: 0,
forwardChannelId: '@telegram_channel_id',
// Auto abstract lines
abstractLines: 5,
// Since created date of blog
since: '2022-01-01T00:00:00.000Z',
},
],
},
},
This configuration means: the bot will automatically forward the hexo blogs in path/to/source/_posts
directory to the @telegram_channel_id
channel, and the forwarded blog are created or updated no earlier than 2022-01-01T00:00:00.000Z
. The link jump to the blog will be as https://your_username.github.io/${year}/${month}/${day + offsetDay}/${blog_filename}
. The execution interval between two services is 3600
seconds.
You can enable Github issue comment forwarding service by configuring config.js
:
pixiv: {
generateCollectionIndex: {
enable: true,
duration: 3600,
paths: [
'pixiv_collection_path',
{ path: 'pixiv_collection_path_r18', r18: true },
],
},
},
This configuration means: the server will automatically generate index for your Pivix collections stored in the pixiv_collection_path
and pixiv_collection_path_r18
paths every 3600
seconds. In that case, you can send message /random_pixiv
or /random_pixiv_r18
to the bot and get a random collection each time.
The command /pixiv_count
can get the number of artworks stored in database.
Based on project Rain120/qq-music-api.
You can enable QQ Music related services by configuring config.js
:
qqmusic: {
enable: true,
host: 'http://127.0.0.1',
port: 3200,
musicListId: 'your_music_list_id',
},
This configuration means: Rain120/qq-music-api server is running on http://127.0.0.1:3200
. You can send message /random_music
to the bot and get a random music from the QQ music playlist your_music_list_id
each time.
The command /music_count
can get the number of musics in music list.
yarn start
# Use babel to build source files
yarn build
# Start service
yarn pm2
Or you can just run:
yarn deploy
By default, pm2 service will read strategy in process.json
.
Check more details about pm2 strategy here.