一个依靠telegram bot的下载机器人,功能包括上传telegram的文件到google drive, 下载文件到google drive(链接以及使用yt-dlp下载视频)
修改自https://github.com/viperadnan-git/google-drive-telegram-bot;
修改点:
- 更新
Pyrogram版本以适配大文件下载 - 将
ytdl更新为yt-dlp - 修改为
sqlite模式而非postgresql本来最开始想改成本地json,但懒得改sql请求就算了 - 修改为
async异步,理论提升性能 -
Telegram下载文件名修改为时间+文件名,以解决同名文件下载的问题。 - 更新认证方式,从
urn:ietf:wg:oauth:2.0:oob更新为localhost模式
BOT_TOKEN- 与 BotFather 聊天获得(APP_ID- 请在 my.telegram.org 上创建APP获得API_HASH- 同上SUDO_USERS- 具有SUDO USER权限的Telegram ID, 若有多个则用空格分开.SUPPORT_CHAT_LINK-Telegram invite link.DATABASE_URL- SQLite的文件位置(相对绝对路径皆可,以sqlite:开头).DOWNLOAD_DIRECTORY- 下载文件的位置,相对绝对路径皆可. 必须以/结尾. (默认为./downloads/)MAX_TASKS- 最大同时下载Telegram文件的数量,默认为4,不建议大于4
/auth : 进行Googled Drive的验证,需要在填入ClientID和ClientSecret之后运行,访问auth url之后将http://localhost/?code=的认证url直接发送给Bot即可完成验证;
/revoke: 取消Google Drive认证
/setfolder: 设置Google Drive上传文件夹目录,直接发送例如:/setfolder https://drive.google.com/drive/folders/*即可;
/ytdl: 使用yt-dlp进行视频等下载,发送如:/ytdl https://www.youtube.com/****即可;
/emptytrash:清空google drive垃圾箱
直接转发文件给Bot即可, 同时下载参数为MAX_TASKS, 不建议大于4, 可能会触发Flood_wait.
直接发送链接即可.
There are two Ways for configuring this bot.
- Add values to Environment Variables. And add a
ENVvar to Anything to enable it. - Add values in config.py. And make sure that no
ENVenvironment variables existing.
-
BOT_TOKEN- Get it by contacting to BotFather -
APP_ID- Get it by creating app on my.telegram.org -
API_HASH- Get it by creating app on my.telegram.org -
SUDO_USERS- List of Telegram User ID of sudo users, seperated by space. -
SUPPORT_CHAT_LINK- Telegram invite link of support chat. -
DATABASE_URL- Postgres database url. -
DOWNLOAD_DIRECTORY- Custom path for downloads. Must end with a forward/slash. (Default to./downloads/) -
Install required modules.
apt install -y git python3 ffmpeg libpq-dev python3-pip- Clone this git repository.
git clone https://github.com/Xiefengshang/tgtogd- Change Directory
cd tgtogd- Install requirements with pip3
pip3 install -r requirements.txtAfter modifying your config
python3 -m bot- Dan for creating PyroGram
- Spechide for gDriveDB.py
- Shivam Jha for Clone Feature from python-aria-mirror-bot