Giter Club home page Giter Club logo

archivebot's Introduction

Archive-Bot

MIT Licence Paypal Patreon

⚠️ ⚠️ ⚠️ State of the project ⚠️ ⚠️ ⚠️

The project is no longer actively maintained! Might still work for you though.

If you started a successful fork of this repository that has been maintained over a longer period of time, feel free to contact me. I'll then point to your fork :).

⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

Features

A handy bot which enables to download files from telegram chats to your server.

It features a full backup of all files posted in a chat and a continuous backup of incoming new media. A 7z archive can then be created and downloaded from the Telegram chat with a single command at any time.

For instance, this is great to collect images and videos from the members of your last holiday trip or to simply push backups or interesting files from your telegram chats to your server.

To send multiple uncompressed pictures and videos with your phone:

  1. Click the share button
  2. Select File
  3. Select Gallery (To send images without compression)

WARNING: This is a hobby side project of mine. It has been developed for use on Linux, but might work on windows as well. There might be some bugs, but I didn't find them yet. I'm happy about any PR's, feel free to help out!

Features

  • Zip all files and post it into the chat with the simple /zip command.
  • Clear all files from the server with a simple /clear_history command.
  • Scan the whole chat with scan_chat (Bot needs to be logged in as a normal user for this feature).
  • Specify your accepted media types.
  • Set a custom name for a chat for easier server file management and naming of the zip file.
  • Automatic sorting of files by chat and user. sort_by_user can be disabled.
  • Properly handles forwarded messages (If sort_by_user is enabled, the original sender will be used).
  • Verbose option for notifying users of duplicates or compressed images.

Stuff that's not working

  • I don't handle all media files yet. Feel free to create a pull request for this.

Installation and starting

This bot is developed for Linux. Windows isn't tested, but it shouldn't be too hard to make it compatible. Feel free to create a PR.

Dependencies:

  • poetry to setup a virtualenv and run everything conveniently. (If you don't want poetry, you need to install the dependencies defined in pyproject.toml by hand.)
  • Just for convience.
  • 7zip if you want to use the zip feature
  • Sqlite
  1. Clone the repository:

    git clone [email protected]:nukesor/archivebot && cd archivebot
  2. Run just setup to setup the project

  3. Run just initdb to initialize the database

  4. Run just run to create a default config ~/.config/archivebot.toml

  5. Adjust the configuration

  6. Start the bot via just run

Configuration

You can choose to run archivebot as a bot with a telegram bot token. If run as a normal telegram bot, archivebot is unable to scan the whole chat history. Thereby /scan_chat doesn't work as well as the /zip command, since normal bots can't upload files larger than 20MB. Userbots on the other hand can upload files up to 1.5GB.

If you run the bot as a normal Telegram bot, disable the privacy mode for your bot via the BotFather menu! Telegram bots can't read group messages by default.

In case you decide to run it as a userbot to access all features, set the userbot flag to true and add your phone number to the configuration. You will receive a login code, which has to be entered on the first start and every time your session expires (which happens pretty much never).

Commands

In group chats the bot expects a command in combination with its username. (In userbot mode that's your own username) E.g. /start@some_bot_name or /start@Nukesor

/start Start the bot
/stop Stop the bot
/clear_history Clear all files from the server.
/zip Create a zip file of all files on the server
/set_name Set the name for this chat. This also determines the name of the target folder on the server.
/scan_chat Scan the whole chat history for files to back up.
/accept ['document', 'photo'] Specify the accepted media Example: '/accept document photo'
/verbose ['true', 'false'] The bot will complain if there are duplicate files or uncompressed images are sent, whilst not being accepted.
/sort_by_user ['true', 'false'] Incoming files will be sorted by user in the server directory for this chat.
/allow_duplicates ['true', 'false'] Allow to save files with duplicate names.
/info Show current settings.
/help Show this text

Botfather commands

These are the command descriptions formatted for the botfather, in case you want to host your own bot

start - Start archiving Files for this chat
stop - Stop archiving Files for this chat
clear_history - Clear all files from the server.
zip - Create a zip file of all files on the server.
set_name - Set the name for this chat. This also determines the name of the target folder on the server.
scan_chat - Scan the whole chat history for files to back up.
accept - ['document', 'photo'] Specify the allowed media types. Example: `/accept document photo`
sort_by_user - ['true', 'false'] Incoming files will be sorted by user in the server directory for this chat.
verbose - ['true', 'false'] The bot will complain if there are duplicate files or uncompressed images are sent, whilst not being accepted.
allow_duplicates - ['true', 'false'] Allow to save files with duplicate names.
info - Show current settings.
help - Show the help text.

archivebot's People

Contributors

nukesor avatar sutra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

archivebot's Issues

doesn't start after upgrade

Today I've git pulled the latest version and now archivebot isn't starting.
After the git pullcommand, I ran makeand it upgraded some dependencies

The error is

poetry run ./main.py
Traceback (most recent call last):
File "./main.py", line 3, in <module>
from archivebot.archivebot import main
File "/data/scripts/telegram/archivebot/archivebot/archivebot.py", line 8, in <module>
from archivebot.config import config
File "/data/scripts/telegram/archivebot/archivebot/config.py", line 38, in <module>
if option not in config[key]:
KeyError: 'zip'

Any ideas?

Installation error

Hi,
I have a problem during the installation.
I don't know how to solve this problem.

That's a copy of my terminal:

@DESKTOP:/mnt/c/Users/cened/Desktop/archivebot-master$ ./venv/bin/activate
@DESKTOP:/mnt/c/Users/cened/Desktop/archivebot-master$ ./initdb.py
Traceback (most recent call last):
  File "./initdb.py", line 4, in <module>
    from sqlalchemy_utils.functions import database_exists, create_database, drop_database
ImportError: No module named sqlalchemy_utils.functions

use userbot command

hello
I completed installation and got App api_id and App api_hash in my.telegram, and program run successfully(without any error) but I have one question:
In userbot mod :
how can I use commands in "userbot"?
for example in doc explain it :
In group chats the bot expects a command in combination with its username. (In userbot mode that's your own username) E.g. /start@some_bot_name or /start@Nukesor
what's the mean and how can i use command ?

tnx

Execution error?

Hi,
It's me again.

I found an error;
/archivebot/sentry.py", line 16, in init
if config.SENTRY_TOKEN is not None:
AttributeError: 'Config' object has no attribute 'SENTRY_TOKEN'
This happens because in config.py, it's called SENTRY_KEY...

Now the big question...
After i execute the command
poetry run ./main.py``

Bash is working, but without writing anything.
So I try /start on telegram. (and other command)
I can see the creation of the folder on my pc, and the generation of the .session, .db file;
but I don't get any response from the bot itself.

The only command I get answered is /scan_chat. (bot:Starting full chat scan.)
At the same time a traceback appears in the bash.

https://pastebin.com/rcjMUnag

Probably there are two different problem.

Thanks to the availability.

No Output

Im getting the following error when trying to install and later trying to run the bot:

poetry run ./main.py

[FileNotFoundError]
[Errno 2] No such file or directory: './main.py': './main.py'

It works if i do poetry run python ./main.py but i do not get any output and the bot does not answer either.

How can i fix this? Is there some sort of verbose output?

Thanks for your awesome work!

retry failed/cancelled download

Hi there!

I'm using this awesome bot to in conjunction with medusa to save and then rename and place the file into the correct path.

Sometimes, but, medusa moves the file when it didn't complete to download, so I need to re-download it again, and it seems it cannot be downloaded more than once. I have tried to /allow_duplicates and /clear_history but it seems it does nothing. (in fact, the only two commands with any output are /start@username and /stop@username commands.

Am I doing something wrong?

Allow full scan of the chat

Add an command, which scans the whole message history of this chat for files.
Duplicate files from the same message will be ignored.

Not working

I have tried to deploy de bot several times but It just doesn't work, the "just run" command just shows that poetry is running python main.py run and that's pretty much It, no errors in screen and the bot just doesn't answer to anything.
Has anyone else had this problem?

Errorno 13

Hello
when i try to run initdb.py by command poetry run ./initdb.py i get the following error:
PermissionError: [Errno 13] Permission denied
what should i do?

[Question] Can it archives just text but no images or files?

Context: I have some chats that are me writing stories with a friend. I would like to backup those and consistently do so in case something happen to my Telegram. It would be unfortunate to lose years of work in a swoop.

Question: Does this bot only backup files? Can it backup the text that is sent as well as identify who is the poster?

If Not: Is it possible to implement it?

Thank you.

installation errors

% make
% ./venv/bin/activate
% ./initdb.py
% ./main.py
installed make

/venv/bin/activate
usr@instance-4:/archivebot$ ./initdb.py
-bash: ./initdb.py: /bin/env: bad interpreter: No such file or directory
usr@instance-4:
/archivebot$ ./main.py
-bash: ./main.py: /bin/env: bad interpreter: No such file or directory
usr@instance-4:~/archivebot$

should i move them to the bin venv folder or

,ubuntu os google cloud vps installed with ubuntu ,

if any other software needed please mention them

[IDEA] Temporary directory/name

I'm using this bot to download TVShows episodes and then with PyMedusa, naming them and placing on the right place to Plex Media Server to scan the polished filename.

The problem is medusa isn't aware if the download has finished or not, and it "moves" the file when it's still downloading. Medusa can handle torrent and nbz files and it's aware when the file has finished download because it can speak with the torrent or nbz engine.

Amule has temporary filenames, finished with the .partextension and when finish the download, it renames the file so medusa grabs the proper downloaded file.

I was wondering if archivebot could do something like amule does, like put an extra extension like .part or .unfinished or whatever, so those episode managers couldn't handle the file until archivebot has finished download and renamed the file accordingly.

It can be useful as well for those who don't use those programs as with a single look, someone can know if the file was download properly or if it needs to be downloaded again.

If naming is not possible, perhaps having a temporary folder path is easier to implement, so we can have the incomplete and complete paths and those can be each on a different mountpoint.

Add option to allow duplicate files

Right now, duplicate files will be ignored.
The duplication is detected whether there already is a file with this name in the target directory.
There should be an option to disable this feature and place the new file besides any old files

Duplicate files from the same chat will still be ignored.

Working on group

Hi, today i tried to set up this bot, it work only from bot interface, if i invite the bot on a group it will not save any photo, but command still work

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.