Go to file
2023-07-29 11:49:24 +08:00
.github/workflows Add GitHub actions to do auto testing and upload code coverage (#11) 2023-07-09 23:17:09 +08:00
src WebDAV: login 2023-07-29 11:49:24 +08:00
test WebDAV: get file size and created date 2023-07-29 02:15:08 +08:00
.env.example fix tsconfig to resolve import error 2023-07-25 12:27:52 +08:00
.gitignore added webdav server 2023-07-29 01:03:46 +08:00
.prettierignore Add GitHub actions to do auto testing and upload code coverage (#11) 2023-07-09 23:17:09 +08:00
.prettierrc added unit tests for all existing apis 2023-07-09 22:36:53 +08:00
jest.config.js added webdav server 2023-07-29 01:03:46 +08:00
LICENSE Initial commit 2023-07-04 01:54:16 +08:00
package.json added webdav server 2023-07-29 01:03:46 +08:00
README.md update readme 2023-07-25 20:40:35 +08:00
tsconfig.build.json added unit tests for all existing apis 2023-07-09 22:36:53 +08:00
tsconfig.json fix tsconfig to resolve import error 2023-07-25 12:27:52 +08:00
yarn.lock added webdav server 2023-07-29 01:03:46 +08:00

tgfs

Use telegram as file storage

Test codecov

Tested on Windows, Ubuntu, MacOS

Installation

$ yarn install && yarn build
$ alias tgfs="yarn cmd"

Step by Step Guide to Set up Environment Variables

Create a Telegram app

  1. Go to Here, login with your phone number and create a Telegram app.

Set up api_id and api_hash

  1. Duplicate the .env.example file and name it .env.local
  2. Copy the api_id and api_hash from the Telegram app page to the .env.local file (TELEGRAM_API_ID and TELEGRAM_API_HASH respectively)

Set up the channel to store files

  1. Create a new Telegram private channel (New Channel in the menu on the left)
  2. There should be a message like "Channel created". Right click the message and copy the post link.
  3. The format of the link should be like https://t.me/c/1234567/1, where 1234567 is the channel id. Copy the channel id to the .env.local file (TELEGRAM_PRIVATE_FILE_CHANNEL)

Create a Telegram bot

  1. Go to BotFather, create a new bot and copy the token to the .env.local file (TELEGRAM_BOT_TOKEN)
  2. Add the bot to the channel as an administrator

Choose where to store the session file

  1. You can do this by editing the TELEGRAM_SESSION_FILE variable in the .env.local file. The default value is ~/.tgfs/account.session

usage

  • ls

    $ tgfs ls /
    
  • mkdir

    $ tgfs mkdir /documents
    
  • cp

    $ tgfs cp ~/some-file /
    
  • rm

    $ tgfs rm /some-file