A Telegram Bot to transfer files to OneDrive.
- Please read Preparation carefully and don't omit any steps.
- Please read Usage - Before Start, or the bot may not work.
- Based on gramme.rs.
- Works only in Group.
- Transfer files you send or forward.
- Transfer restricted content.
- Transfer files from url.
- No file size limitation.
- Doesn't occupy local space, works entirely on memory through multipart transfer.
- Support multiple OneDrive accounts.
- Support OneDrive directory changing.
- Support multitasking in parallel.
- Persoanl account.
- All types of business accounts, details.
- All types of educational accounts if domain administrator exists.
- All types of educational accounts if domain administrator doesn't exist.
- Microsoft 365 operated by 21Vianet(世纪互联).
- Open
docker-compose.ymland edit the environment configuration. server_uriis your domain, likehttps://example.com, orhttps://127.0.0.1:xxxxif you don't have a web server. Protocol must be "https", not "http".- Some web browsers may prevent you from visiting this url because of ssl mismatch. Try using Chromium.
- If you want to specify your own ssl keys, especially if you have your own site, you can import your ssl keys like this:
services: telegram-onedrive: ... volumes: - /path/to/*.crt:/ssl/server.crt - /path/to/*.key:/ssl/server.key ...
- Reflect the port:
services: telegram-onedrive: ... ports: - xxxx:8080 ...
- Optional, if you're using reverse proxy, you need to set
reverse_proxytotrue. Default tofalse. Make sure your reverse proxy use ssl, real server protocol ishttp. For example, inNginx:listen 443 ssl; listen [::]:443 ssl; server_name example.com; ssl_certificate path/to/public.pem; ssl_certificate_key path/to/private.key; location / { proxy_pass http://127.0.0.1:xxxx/; }
- Create a Telegram bot through BotFather. Record
tokenastg_bot_token. - Create a Telegram application on my.telegram.org. See details. Record
api_idastg_api_id,api_hashastg_api_hash. tg_user_phoneis the phone number you just used to login to my.telegram.org. It's in international format, like+xxyyyyyyyyyyy.- Optional, if you have two-step verification enabled, set
tg_user_passwordas your 2FA password. tg_user_nameis your telegram user name. Check your profile, find your user name, it should be like@user, then recorduserastg_user_name. If you need multiple users, use,to split, likeuser1,user2. Optional, default to void. If you don't set this parameter, everyone can control your bot.- Create a OneDrive application on portal.azure.com App registrations.
- Press
New registrations. - Fill
Name. - In
Supported account typeschooseAccounts in any organizational directory and personal Microsoft accounts. - In
Redirect URI,platformselectWeb, uri domain should be the same withserver_uri, route must be/auth, likehttps://example.com/auth.- Explain: The authorization code will be sent through the uri you offer, like
https://example.com/auth?code=xxxxxxx.
- Explain: The authorization code will be sent through the uri you offer, like
- Press
Register. - In application's
Overview, recordApplication (client) IDasod_client_id. - Go to application's
Certificates & secrets, pressClient secrets, and pressNew client secret. Then fillDescription, and choose anExpires. Finnaly, pressAdd. RecordValueasod_client_secret.
- Press
od_root_pathis a directory on OneDrive. Like/Videos/from-telegram. Default to/.auto_deletedecides whether bot can auto delete message. Passtrueorfalse. Optional, default tofalse.
You don't have to read this section if you don't want to debug.
portis the port of the authorization server, default to8080.trace_leveldefines the tracing level of the log, default toinfo.worker_numcontrols the the maximum number of parallel tasks, default to5.
- Create a group.
- In bot's profile, press
Add to Group or Channel. - Add this bot to your group.
- Set this bot as Admin, and give it all rights like this

If you don't follow these steps, the bot may not work.
- Send
/auth. - Wait and you'll receive the login code from telegram.
- Visit the uri the bot sends, and submit the code.
- After submission, it will send the authorization uri for OneDrive. Visit, login and authorize.
- If the bot says
Onedrive authorization successful!, everything is done.
- In the group, forward or upload files (or videos, photos, gifs, stickers, voices).
- If you want to transfer restricted content from a group or channel, right click the content, copy the message link, and send the link.
- Wait until the transfer completes. You can check the progress status on the latest message from the bot.
- Use
/helpfor more information about other command.
/startto start with bot./authto authorize telegram and onedrive./clearto clear history./autoDeleteto toggle whether bot should auto delete message./driveto list all OneDrive accounts./drive addto add a OneDrive account./drive $indexto change the OneDrive account./drive logoutto logout current OneDrive account./drive logout $indexto logout specified OneDrive account./links $message_link $rangeto transfer sequential restricted content./url $file_urlto upload the file through url./logsto send log file./logs clearto clear logs./dirto show current OneDrive directory./dir $pathto set OneDrive directory./dir temp $pathto set temporary OneDrive directory./dir temp cancelto restore OneDrive directory to the previous one./dir resetto reset OneDrive directory to default./versionto show the version./helpfor help.
- The bot support files with extension
.t2oas batch scripts. You can use them to automate the bot. - To cancel a job, delete the responded message.
- To cancel batch or links tasks, delete the message you sent.
/links https://t.me/c/xxxxxxx/100 2will transferhttps://t.me/c/xxxxxxx/100andhttps://t.me/c/xxxxxxx/101./url https://example.com/file.txtwill uploadfile.txt. The headers of the file response must includesContent-Length.- In a file named
example.t2o, write these lines for example:https://t.me/xxxx/100 /links https://t.me/yyyy/200 2 /autoDelete /dir temp /files /url https://example.com/file.txt
Launch
sudo docker compose up -d

