Code Monkey home page Code Monkey logo

archivebot's Introduction

Archive-Bot

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 zip 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)

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.

Installation and starting:

Clone the repository:

% git clone [email protected]:nukesor/archivebot && cd archivebot

Now copy the archivebot/config.example.py to archivebot/config.py and adjust all necessary values. Finally execute following commands to install all dependencies, initialize the database and to start the bot:

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

Additionally, if you want to use the zip feature, you need to install 7zip on your system.

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. And the /zip command

In case you decide to run it as a userbot to access all features, set the bot token to None 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 channels the bot expects a command in combination with its username. E.g. /start@bot_user_name

/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

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.