Code Monkey home page Code Monkey logo

telegram-report-bot's Introduction

Report bot for Telegram

This repository contains source code of a small yet rather powerful bot for Telegram, which handles reports from users and passes them to admins. Uses aiogram framework.
The main goal is to build a bot with no external database needed. Thus, it may lack some features, but hey, it's open source!

Screenshot

Left - main group. Right - group for admins only. If you don't see this image, please check GitHub repo

Features

  • /report command to gather reports from users;
  • Reports can be sent to a dedicated chat or to dialogues with admins;
  • /ro command to set user "read-only" and /nomedia to allow text messages only;
  • [optional] Automatically remove "user joined" service messages;
  • [optional] Automatically ban channels (since December 2021 users can write on behalf of their channels);
  • If text message starts with @admin, admins are notified;
  • A simple interface for admins to choose one of actions on reported message;
  • English and Russian languages are built-in.

Requirements

  • Python 3.9 and above;
  • Tested on Linux, should work on Windows, no platform-specific code is used;
  • Systemd (you can use it to enable autostart and autorestart) or Docker.

Installation

  1. Go to @BotFather, create a new bot, write down its token, add it to your existing group and make bot an admin. You also need to give it "Delete messages" permission.
  2. Create a separate group where report messages will be sent and add all group admins there. Remember: anyone who is in that group may perform actions like "Delete", "Ban" and so on, so be careful.
  3. Use some bot like @my_id_bot to get IDs of these two groups;
  4. Clone this repo and cd into it;
  5. Copy env_dist to .env (with dot). Warning: files starting with dot may be hidden in Linux, so don't worry if you stop seeing this file, it's still here!
  6. Replace default values with your own;
  7. Now choose installation method: systemd or Docker
systemd
  1. Create a venv (virtual environment): python3.9 -m venv venv (or any other Python 3.7+ version);
  2. source venv/bin/activate && pip install -r requirements.txt;
  3. Rename reportbot.service.example to reportbot.service and move it to /etc/systemd/system;
  4. Open that file and change values for WorkingDirectory, ExecStart and EnvironmentFile providing the correct path values;
  5. Start your bot and enable its autostart: sudo systemctl enable reportbot.service --now;
    6.Check your bot's status and logs: systemctl status reportbot.service.
Docker
  1. Build and run your container: docker-compose up -d.

Alternatively, check docker-compose.yml file from this repo.

telegram-report-bot's People

Contributors

mastergroosha 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  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

telegram-report-bot's Issues

Errors with lang

Hi! I have settings docker-compose a bit different
I dont use env_file but use environment section and i think bot cant see my settings, because it sends me

Incorrect value. Must be one of: en, ru (type=value_error)
Traceback (most recent call last):
 File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
   return _run_code(code, main_globals, None,
 File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
   exec(code, run_globals)
 File "/app/bot/__main__.py", line 8, in <module>
   from bot.before_start import fetch_admins, check_rights_and_permissions
 File "/app/bot/before_start.py", line 6, in <module>
   from bot.config_reader import config
 File "/app/bot/config_reader.py", line 40, in <module>
   config = Settings()
 File "pydantic/env_settings.py", line 38, in pydantic.env_settings.BaseSettings.__init__
 File "pydantic/main.py", line 331, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Settings
lang

can u pls add heroku button in this repo ?

respected sir ,
i have loved this repo and bot . i copy this codes to my GitHub . (momskidvaava) . but , there is an problem . pls help me to solve that .
i am using my mobile to edit and make the bot . therefore , computer programs are not available on that . pls add a heroku butten for me pls .
pls support me to solve my issue .

/ro and /nm without time but with comment doesn't work

Currently bot expects /ro (or /nm) commands to either don't have any following text (restrict forever) or have restriction time with optional comment. However one case is missing:
/ro {comment} will not work, since comment will be treated as time, causing an error.

Move "config" and "lang" to bot properties instead of middleware

As noted by aiogram maintainer, one can add custom properties which are meant to be constant (like config or lang) directly to Bot instance.
Currently these two properties are pushed to every new update in middleware, which is not performance-wise.

This way, the only middleware can be easily removed, simplifying the code a bit.

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.