Giter Site home page Giter Site logo

telegramftp's Introduction

Telegram-FTP

Use telegram as ftp storage.

Based on aioftp server and pyrogram.

Enviroment variables you need to set:

API_ID: Go to my.telegram.org to obtain this.

API_HASH: Go to my.telegram.org to obtain this.

BOT_TOKEN: Get the bot token from BotFather.

MONGODB: MongoDB connect string.

CHAT_ID: Chat id to send files to.

HOST: FTP server host (default: 0.0.0.0).

PORT: FTP server port (default: 9021).

Setup:
  1. Create bot in BotFather.
  2. Obtain API_ID and API_HASH on my.telegram.org.
  3. Create mongodb database on MongoDB Cloud (or use your server) and copy connect string.
  4. Insert all variables into .env
  5. Add bot to your channel with admin rights.
  6. Run get_channel_id.py, send /id command in your channel.
  7. Copy id to .env
  8. Create mongodb database named ftp.
  9. Run setup_database.py.
  10. Run accounts_manager.py to create accounts.
  11. Disable your ftp client timeout.
  12. Run main.py.

telegramftp's People

Contributors

ruslanuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

bellyfat aiwabr

telegramftp's Issues

FileZilla upload failed

Hi, thank you for your software. I really love the concept, and your setup documentation is easy to follow.

Unfortunately, I run into following issue.
I tried to upload a dummy file using FileZilla, 50MiB in size. The upload seems to be working at first, saying it is 100% uploaded.
But after a while it stuck at 100% and did not move to Successful transfer tab.
I notice in the Telegram channel, some files named "file" showed up with size 16+16+16+2 MiB respectively, and those files shows up 3 times, so 12 files in total, 150 MiB in size.
After sometimes, the transfer in FileZilla move to Failed transfers tab with reason=timeout.
And after a while, I can see in the terminal following error

root@mush:~/TelegramFTP# python3 ./main.py
FTP server starting...
Task exception was never retrieved
future: <Task finished name='Task-2329' coro=<MongoDBUserManager.notify_logout() done, defined at /root/TelegramFTP/ftp/server.py:113> exception=ValueError('Too many releases')>
Traceback (most recent call last):
  File "/root/TelegramFTP/ftp/server.py", line 114, in notify_logout
    self.available_connections[user].release()
  File "/root/TelegramFTP/ftp/server.py", line 171, in release
    raise ValueError("Too many releases")
ValueError: Too many releases

Please help me to fix the issue. Thanks!

change the size of chunk to 80 and asleep 3s to avoid flood

Hi there!
Thanks for your project!

I met an error while tried to use it which said:

pyrogram.errors.exceptions.flood_420.FloodWait: Telegram says: [420 FLOOD_WAIT_X] - A wait of 20 seconds is required (caused by "messages.SendMedia")

So, I made some changes to the file pathio.py like
line 87:
async for data in stream.iter_by_block(1024102480):
line 94
await asleep(3)
line 112
for _o in range(o, o+80)
line 114
o += 80

then it works!

However, there is still a problem:
the FTP client wouldn't stop automatically after finishing upload; instead, it would restart the same upload(s) again, here are the logs:

Task exception was never retrieved
future: <Task finished name='Task-5205' coro=<MongoDBUserManager.notify_logout() done, defined at /www/bot/TelegramFTP/ftp/server.py:113> exception=ValueError('Too many releases')>
Traceback (most recent call last):
File "/www/bot/TelegramFTP/ftp/server.py", line 114, in notify_logout
self.available_connections[user].release()
File "/www/bot/TelegramFTP/ftp/server.py", line 171, in release
raise ValueError("Too many releases")
ValueError: Too many releases
Task exception was never retrieved
future: <Task finished name='Task-5208' coro=<MongoDBUserManager.notify_logout() done, defined at /www/bot/TelegramFTP/ftp/server.py:113> exception=ValueError('Too many releases')>
Traceback (most recent call last):
File "/www/bot/TelegramFTP/ftp/server.py", line 114, in notify_logout
self.available_connections[user].release()
File "/www/bot/TelegramFTP/ftp/server.py", line 171, in release
raise ValueError("Too many releases")
ValueError: Too many releases

Could you give suggestions on how to make it stop after finishing upload? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.