服务器需要回血 先提供代维护服务 30月付 包配置好sa(400个) 提供2g内存(可拷35万+文件的配置) 提供机器人配置 无命令行
一键安装脚本(感谢 脚本制作者 @vitaminx)
如果你没有Linux操作经验或者是新开的vps,可尝试使用此脚本
- 首先准备好以下两个条件:
- 在Telegram上注册好机器人并取得并记录下该机器人TOKEN
- 一个域名在cloudflare解析到该机器人所在VPS的IP
- 准备好以上两个条件后,复制以下内容粘贴到VPS命令行窗口回车即可
bash -c "$(curl -fsSL https://raw.githubusercontent.com/iwestlin/gd-utils/master/gdutilsinstall.sh)"
- 安装过程中需要输入一下四个参数:
- 机器人TOKEN:这个在Telegram里面找“@BotFather”注册即可获得
- 自己的的Telegram username:在Telegram里面直接查看
- web服务名:这是个是很重要的识别标志,请设置为你的域名(格式:abc.34513.com)
- 域名网址全称:你在cloudflare上解析到VPS的域名网址全称(格式:https://abc.34513.com)
- 测试可用完美安装系统:
- Centos 7/8
- debian 9/10
- ubuntu 16.04/18.04/19.10/20.04
本文较长,从nodejs的部署开始,有基础的可以直接跳到机器人的安装
Nodejs
首先到官网选择合适的地址进行下载https://nodejs.org/zh-cn/download/

这里我用的是linux 64-bit二进制文件
cd /home
wget https://nodejs.org/dist/v12.18.1/node-v12.18.1-linux-x64.tar.xz
tar xf node-v12.18.1-linux-x64.tar.xz
cd node-v12.18.1-linux-x64
./bin/node -v
上面指令执行完提示版本之后代表解压正确。cd /home目录是个人习惯你可以随便安装到哪个目录都可以。
创建软连接:
ln -s /home/node-v12.18.1-linux-x64/bin/npm /usr/local/bin/
ln -s /home/node-v12.18.1-linux-x64/bin/node /usr/local/bin/
node -v
输入node -v 指令之后返回版本就代表安装成功
安装pm2模块
npm install pm2
安装之后键入pm2 指令查看是否有返回 如果提示找不到指令则需要进行软链接设置
ln -s /home/node-v12.18.1-linux-64/bin/pm2 /usr/local/bin/
安装rclone
#centos
yum install rclone
#debian
apt install rclone
安装完成之后输入rclone config进行配置
注意:https://rclone.org/drive/#making-your-own-client-id GoogleAPI的创建可以参考这个流程,应用类型选择桌面应用即可 现在没有其他选项了 ,实在有问题我可以在后面出一个视频流程。
[root@cnhb45933ds gd-utils]# rclone config
Current remotes:
Name Type
==== ====
southcat drive
southcat2 drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n
name> yourname
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / A stackable unification remote, which can appear to merge the contents of several remotes
\ "union"
2 / Alias for a existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Hubic
\ "hubic"
14 / JottaCloud
\ "jottacloud"
15 / Koofr
\ "koofr"
16 / Local Disk
\ "local"
17 / Mega
\ "mega"
18 / Microsoft Azure Blob Storage
\ "azureblob"
19 / Microsoft OneDrive
\ "onedrive"
20 / OpenDrive
\ "opendrive"
21 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
22 / Pcloud
\ "pcloud"
23 / QingCloud Object Storage
\ "qingstor"
24 / SSH/SFTP Connection
\ "sftp"
25 / Webdav
\ "webdav"
26 / Yandex Disk
\ "yandex"
27 / http Connection
\ "http"
Storage> 12 #根据具体显示的序号填写 选择Google drive
** See help for drive backend at: https://rclone.org/drive/ **
Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id> 你的地址参考GoogleAPI的创建
Google Application Client Secret
Setting your own is recommended.
Enter a string value. Press Enter for the default ("").
client_secret> 你的密钥参考GoogleAPI的创建
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Full access all files, excluding Application Data Folder.
\ "drive"
2 / Read-only access to file metadata and file contents.
\ "drive.readonly"
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ "drive.file"
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ "drive.appfolder"
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ "drive.metadata.readonly"
scope> 1
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id>
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file>
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=612827121300-2m4tjloth85e5vdlm01g9vs4bbr8ahhj.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=8f4b3ee1557fc8b65566b135a6952744
Log in and authorize rclone for access
Enter verification code> 访问上面返回的地址的验证码
Configure this as a team drive?
y) Yes
n) No
y/n> y
Fetching team drive list...
Choose a number from below, or type in your own value
1 / 暂存
\ "0AALkLuv9eiPlUk9PVA"
2 / hsd
\ "0ANB9ckn8lgbtUk9PVA"
3 / southcat
\ "0AI2_jJXBblQqUk9PVA"
4 / zero
\ "0AHWfLcyGQt7hUk9PVA"
Enter a Team Drive ID> 1
--------------------
[yourname]
type = drive
client_id = 612827121300-2m4tjloth85e5vdlm01g9vs4bbr8ahhj.apps.googleusercontent.com
client_secret = 3z6jxfz8bYVm3c6HwtWlgqzw
scope = drive
token = {"access_token":"123","token_type":"Bearer","123","expiry":"2020-06-28T09:34:12.018897967+08:00"}
team_drive = 0AALkLuv9eiPlUk9PVA
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
southcat drive
southcat2 drive
yourname drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
程序部署
git clone https://github.com/iwestlin/gd-utils && cd gd-utils
sudo npm i
如果提示sudo :npm not found那么需要建立一个新的软链接
ln -s /home/node-v12.18.1-linux-x64/bin/npm /usr/bin/
ln -s /home/node-v12.18.1-linux-x64/bin/node /usr/bin/
执行完之后再次输入sudo npm i安装即可
获取gd配置文件
输入rclone config file 获取rclone配置文件

接下来打开配置文件复制其中的client_id、client_secret、refresh_token这三个的值并依次填入 gd-utils程序目录下的config.js文件中.

注意:一定要遵循标准格式 值放到引号里面
复制保存之后输入node check.js 查看返回值

返回文件信息的时候就代表部署成功,注意这里显示的是你的个人盘的文件信息不显示团队盘

confi.js配置文件的第12行建议修改为团队盘如果没有就填写你的个人盘id
如何获取id:
谷歌硬盘网页端选择你的硬盘打开之后复制网址https://drive.google.com/drive/folders/0AALkLuv9eiPlUk9PVA
0AALkLuv9eiPlUk9PVA这一部分就是你的硬盘id
运行程序
pm2 start server.js
程序会默认运行在23333端口 请提前进行放行,建议小白使用宝塔面板进行操作
访问 YOUR_WEBSITE_URL/api/gdurl/count?fid=124pjM5LggSuwI1n40bcD5tQ13wS0M6wg 查看是否返回文件大小及类型,如果返回则代表部署成功.
扩展部分
反向代理
这里使用宝塔的反代进行演示 ,安装nginx环境
新建一个网站 点击设置 选择反向代理

输入以下信息然后保存即可,然后点击配置文件将下面的代码替换进去
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:23333/;
保存运行即可。
TG机器人配置
需要先配置上面的反代并给域名配置https
tg联系botfather创建一个机器人 https://t.me/BotFather
创建完成之后我们复制返回的token 依旧是打开config.js文件 20行填入你的token
21行填入你的tg的username注意格式
最后服务器curl指令执行下
curl -F "url=反代设置的域名/api/gdurl/tgbot" 'https://api.telegram.org/bot[机器人token]/setWebhook'
然后给机器发一个/help看下有没有返回即可了