使用telegram的机器人下载文件到谷歌网盘

项目地址 https://github.com/lzzy12/python-aria-mirror-bot

https://github.com/magneto261290/magneto-python-aria

编辑环境变量文件

生成telegraph的token

python3 generate_telegraph_token.py

d73ae03dd0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXebaf2e161 填写到TELEGRAPH_TOKEN

API_KEY 输入api_id API_HASH 输入 api_hash bot token输入BotFather获取到的bot的token

获得USER_SESSION_STRING AQCUOk4LsAukvKVZ9k1JK5H2Oo4EtWEJF4sQQ9RkG2fCkLWsZdk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXpy_gPZI42i70rerTWeWLD70a_cd_eHswSU1_IbFjTMexTiA2BgE

https://my.telegram.org/ 申请api TELEGRAM_API 填写App api_id TELEGRAM_HASH 填写App api_hash OWNER_ID 到 https://t.me/userinfobot 获取自己的Id

开启谷歌网盘授权

开启drive api https://developers.google.com/drive/api/v3/quickstart/python

gc1gc2

安装依赖

pip3 install google-api-python-client google-auth-httplib2 google-auth-oauthlib

下载credentials.json并上传到服务器

生成token

python3 generate_drive_token.py
[email protected]:~/test/m2g/mirror-bot# python3 generate_drive_token.py
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Enter the authorization code: 4/5AHj9dOAl1h2Kih7zWkCCdY8VtZDrP4TxhYgQ0D4guA4CMnWXJELCD0

gc3

gc4

gc5

gct

docker build . -t  mirror-bot
docker run -idt mirror-bot


在当前目录新建config.env文件来保存环境变量
docker run --env-file ./config.env  mirror-bot

config.env文件

BOT_TOKEN=131nnnnnnn:AAEP5OZUNr5MXXXXXXXXXXXXXXXXXXXXXXX
GDRIVE_FOLDER_ID=1vaM8VJXXXXXXXXXXXXXXXXXXXXXXXXXX
TELEGRAPH_TOKEN=d73ae03XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXebaf2e161
OWNER_ID=73nnnnnn6
DOWNLOAD_DIR=/home/username/mirror-bot/downloads
DOWNLOAD_STATUS_UPDATE_INTERVAL=5
AUTO_DELETE_MESSAGE_DURATION=20
IS_TEAM_DRIVE=
USER_SESSION_STRING=AQCUOk4LsAukvKVZ9k1JK5H2Oo4EtWEJF4sQQ9RkG2fCkLWsZdkXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-I8BmhbR12KBl0UhA02sH6g9URtlLsTyEEyNMsO_eAlY_0j72XiuxWbiHM5M6MdW6-wpbuXA2BgE
TELEGRAM_API=1nnnn70
TELEGRAM_HASH=395cxxxxxxxxxxxxxxxxxxxxxxxxxxc6