MCPcopy Index your code
hub / github.com/assimon/ai-anti-bot

github.com/assimon/ai-anti-bot @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
51 symbols 139 edges 19 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ai-anti-bot

Anti-spam robot for Telegram groups

English | 简体中文

license MIT Go version 1.22.3 telebot v3

Telegram is a world-renowned, very convenient and elegant anonymous communication tool.
However, due to the anonymity of the software, a lot of spam promotion information often appears in the group. We have no way to identify whether there is spam information in the group at all times.
Fortunately, Telegram provides us with a very powerful Api. Now we can use artificial intelligence to automatically help us detect user behavior.

If you are a group administrator of Telegram, you can directly deploy this project privately.

If you are a developer, you can use this project to familiarize yourself with the interactive development of Go language and Telegram, so that you can use Api to develop your own robot later!

References:

How to use

Docker Compose

# Clone the project
git clone https://github.com/assimon/ai-anti-bot.git && cd ai-anti-bot && mkdir data

# Set up your configuration
cp config.yml.example data/config.yml

# Fill in the configuration according to your needs
vi config.yml

# start up
docker compose up -d

It's very simple, right?😄

How to configure

telegram:
  proxy:
  token: ""     # Fill in your robot token
  groups: [""]  # Fill in the group id where the robot needs to take effect
  owners: [""]  # Fill in the super administrator's telegram user ID
identification_model: "chatgpt"
clean_bot_message: true # Scheduled cleaning of robot messages

# The following is the judgment strategy. For example, 
# the meaning of the following configuration item is: If you have joined the group for more than 3 days and have spoken more than 3 times or have been verified once, you do not need to verify again.
# Or the threat score must exceed a certain limit before a ban is executed
# This is to save your tokens😊
strategy:
  joined_time: 3
  number_of_speeches: 3
  verification_times: 1
  score: 80


chatgpt:
  proxy: ""   # OpenAI's proxy address, if necessary
  apikey: ""  # apikey
  model: "gpt-4o-mini"   # The detection model to be used. Please note that versions below gpt4 do not support image and file interaction.

# If your native language is not Chinese but other languages, 
# please use the translation to replace the following prompt with the language you want.
prompt:
   ...

Other commands

/start       # Survival detection: feedback will be given if the robot service is running normally

# We can also use the following command to add our own advertising button to the robot, but please be sure to configure the telegram.owners option

/add_ad     # /add_ad #Add a new ad, format: ad title|jump link|expiration time (with hours, minutes, seconds)|weight (in descending order, the larger the value, the higher the weight), for example: /add_ad Hello|https://google.com|2099-01-01 00:00:00|100

/all_ad     # View All Ads Button

/del_ad     # Delete an ad button, for example: /del_ad 1 (delete the ad with id 1)

Preview

preview.png

Extension points exported contracts — how you extend this code

IModel (Interface)
(no doc) [1 implementers]
adapter/iModel.go

Core symbols most depended-on inside this repo

IncrementVerificationTimes
called by 6
database/user_info.go
IncrementNumberOfSpeeches
called by 3
database/user_info.go
NewChatGpt
called by 3
ai/chatgpt/chatgpt.go
PreCheck
called by 3
bot/handle.go
Identifier
called by 3
bot/func.go
isManage
called by 3
bot/func.go
BanChatMember
called by 3
bot/func.go
AllAd
called by 2
bot/handle.go

Shape

Function 37
Method 6
Struct 6
Interface 1
TypeAlias 1

Languages

Go100%

Modules by API surface

bot/handle.go8 symbols
database/user_info.go6 symbols
database/advertise.go6 symbols
bot/func.go6 symbols
bot/middleware.go4 symbols
ai/chatgpt/chatgpt.go4 symbols
bot/root.go3 symbols
adapter/option.go3 symbols
adapter/iModel.go3 symbols
test/chatgpt_test.go2 symbols
pkg/os/os.go1 symbols
database/root.go1 symbols

For agents

$ claude mcp add ai-anti-bot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact