项目作者: timvisee

项目描述 :
:robot: A bot to ban Binance advertising bots in public Telegram chats. https://gitlab.com/timvisee/ban-binance-bot
高级语言: Rust
项目地址: git://github.com/timvisee/ban-binance-bot.git
创建时间: 2019-09-05T21:06:05Z
项目社区:https://github.com/timvisee/ban-binance-bot

开源协议:GNU General Public License v3.0

下载


Build status on GitLab CI
Add bot on Telegram

Note: This bot is a Work in Progress, it works but it’s being tested with. The
source code will be a mess until testing is done and a first release is
published.

Ban Binance Bot for Telegram [WIP]

A Telegram bot to ban users advertising Binance promotions.

Binance spam screenshot

Public Telegram channels are infested with Binance spam these days, posted by
bots at random intervals. This bot counters this by scanning all messages with
images, files and links posted in group chats. If any illegal content (content
with Binance promotions) is posted, the user is instantly banned and their
message is removed.

How does it work?

When the bot is added to a group, all content is scanned for Binance promotions.

The bot currently scans for illegal content, including:

  • links going to Binance promotions
  • files (pictures, GIFs, stickers, …) containing a Binance promotion

When illegal content is found:

  • the user is immediately banned from the chat
  • the respective message is deleted
  • users are notified in the group chat

No configuration needed, just add the bot to your group and it works out of the
box. Remove it again when you’re done with it.

To unban a user, just manually add them to the group chat again.

Illegal messages by administrators may be deleted, but administrators are never banned.

How to use?

I host a public instance of this bot which you can use in your own groups.

  1. Directly message @banbinancebot in Telegram,
    make sure the bot responds to verify it’s still running.
  2. Add @banbinancebot to any of your Telegram
    groups.
  3. Make @banbinancebot administrator, to support
    automatic banning.
    • In normal groups; disable ‘All Members Are Admins’, mark the bot as administrator
    • In supergroups; mark the bot as administrator

You can always compile this bot yourself, to host your own instance.
In that case, please refer to this repository hosting the source code in the
description and about fields of your bot.

Build & runtime requirements

Currently, Rust beta is used for the new async/await system for asynchronous
code.

Build requirements:

  • Rust 1.39 (beta, or higher) (via rustup: rustup default beta)
  • Feature specific:
    • ocr: (default, scan images for illegal text)
      • tesseract, leptonica libraries and clang:
        • Ubuntu: sudo apt-get install libleptonica-dev libtesseract-dev clang

Runtime requirements:

  • A Telegram bot token
  • Feature specific:
    • ffmpeg: (default, scan videos)
      • ffmpeg:
        • Ubuntu: sudo apt-get install ffmpeg
    • ocr: (default, scan images for illegal text)
      • tesseract data for English language:
        • Ubuntu: sudo apt-get install tesseract-ocr-eng
  1. # Clone repository
  2. git clone git@github.com:timvisee/ban-binance-bot.git
  3. cd ban-binance-bot
  4. # Use Rust beta in current directory
  5. rustup override set beta
  6. # Install build and runtime dependencies
  7. sudo apt-get install libleptonica-dev libtesseract-dev tesseract-ocr-eng clang ffmpeg
  8. # Build release
  9. cargo build --release
  10. # Configure .env
  11. cp .env.example .env
  12. nano .env
  13. # Run the bot
  14. ./target/release/ban-binance-bot

To build the bot without some features, so you don’t have to install extra
packages, use:

  1. cargo build --release --no-default-features

The bot currently panics (crashes) for hard errors, such as connection errors to
the Telegram API. Properly handling these situations in code will be worked on
in the future. I therefore recommend running this bot with supervisor or in a
simple loop:

  1. while true; do
  2. echo Starting bot...
  3. ./target/release/ban-binance-bot
  4. sleep 5
  5. done

Privacy notice

Once added to a group, this bot scans all following user messages to determine
whether illegal content is posted. All links are visited to determine whether
it links to any illegal content. All files (photos, GIFs, …) are downloaded
and scanned for illegal content. All content is immediately deleted from the
machine the bot is running on after scanning. This is an automated process
with no user intervention.

Depending on runtime configuration for the bot, messages detected as spam may
be forwarded to a logging chat, including any false-positive detections, to
collect and monitor all spam. These messages will stay until the logging chat,
or the specific forwarded message, is deleted. Messages audited as safe are
never forwarded by this bot.

License

This project is licensed under the GNU GPL-3.0 license.
Check out the LICENSE file for more information.