Code Monkey home page Code Monkey logo

telegram-uploader-bot's Introduction

telegram-uploader-bot

Build Status Release Docker Image Size Docker Pulls Docker Stars

Telegram bot written in Go that monitors directories for new files and uploads them to chats.

Features

  • Monitors specified directories for new files and uploads them to Telegram chats.
  • Supports multiple directories and chats configuration.
  • Can add custom tags to uploaded files using plain text tags, regexps, or expr language.
  • File filtering using file masks.

Prerequisites

  • Go (v1.20 or higher) installed on your Linux system.
  • A Telegram bot token obtained by creating a new bot using BotFather.

Installation

git clone https://github.com/3cky/telegram-uploader-bot.git
cd telegram-uploader-bot
make install

Configuration

The bot uses a YAML config file set by -c or --config-file flags. The default config file is "/usr/local/etc/telegram-uploader-bot.cfg".

To use a custom configuration file, run the bot with the -c flag followed by the path to your config file:

telegram-uploader-bot -c /path/to/custom_config.cfg

Example configuration:

telegram:
  token: "my-telegram-bot-token"

uploads:
  - directory: "/path/to/watch/dir"
    files:
      - "*.jpg" # file name match by the mask is case insensitive
    document: false # set to true to upload files as documents (without reencoding)
    min_size: 0 # min file size limit to upload (default is 0 - no limit)
    max_size: 50 MB # max file size limit to upload (default is 50 MB)
    chat: 1234567
    tags:
      plain:
        - "work"
        - "important"
      regexp:
        - ".*/(?P<name>.*)\\.jpg" # matched groups will be used as tags prefixed by group names
      expr:
        - "(file.Size() > 1024 * 1024) ? 'big' : ''" # tag files bigger than 1 megabyte

Docker

You can launch the telegram-uploader-bot in Docker container with the following command:

docker run -d \
    --name=telegram-uploader-bot \
    -v /path/to/config.cfg:/usr/local/etc/telegram-uploader-bot.cfg \
    -v /path/to/watch/dir:/path/to/watch/dir \
    3cky/telegram-uploader-bot

Where:

  • /path/to/config.cfg: path to telegram-uploader-bot config file in the local filesystem.
  • /path/to/watch/dir: directory to monitor by telegram-uploader-bot, must match uploads directory in config file.

Make sure config file and watched directory are readable by user nobody:nogroup. chown nobody:nogroup

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

telegram-uploader-bot is released under the Apache 2.0 license. See the LICENSE file for more info.

telegram-uploader-bot's People

Contributors

3cky avatar cevremuhendisi 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.