Skip to content

Telegram bot for chats administration

License

Notifications You must be signed in to change notification settings

fsharplang-ru/grinder

 
 

Repository files navigation

Grinder

Telegram bot for chats administration.

Build Status

Configuration and build

  • Install Net5 SDK

  • Open project with Rider/VS 2019 and run build

  • or use dotnet cli

dotnet build

Running

About configuration you can read below in Configuration section

Using a Docker container

You can just spawn new container with bot from keroosha/grinder repo We have x86-64 and ARM32 containers for a bot, check tag section at docker hub page

use docker env file to configure a bot

docker run -d --env-file config.env keroosha/grinder:latest

or attaching dir with predefined appsetings.json

docker run -d --mount /path/to/dir/with/appsettings:/etc/grinder keroosha/grinder:latest

Using a docker-compose

You can use already configured docker-compose.yml as example but, some action required before starting:

  1. Create a config.env file with environments or dir with appsettings.json
  2. Change data path in docker-compose.yml and attach configurations to container
  3. Setup database
  4. You are ready to go! ᕕ( ᐛ )ᕗ

Localy

Just create a launch configuration in your favorite IDE and don't forget about configuration and you will be fine :>

Configuration

You can choose two ways to configure grinder but keep in mind about configuration priorities in configuration provider:

Order of Precedence when Configuring ASP.NET Core

External appsettings.json

appsettings.json

{
    "Bot": {
        "Token": "test",
        "ChannelId": 111,
        "AdminUserId": 123,
        "Socks5Proxy": {
            "Hostname": "Hostme",
            "Port": 1337,
            "Username": "User",
            "Password": "Secrete"
        },
        "ChatsToMonitor": [
            "Sample",
            "Text"
        ],
        "AllowedUsers": [
            "Pasha",
            "Technique"
        ]
    }
}

Attaching appsettings.json

You can attach dir with customized appsettings.json to /etc/grinder/ volume

Environment Variables

Example of env file:

# Socks5Proxy - Socks5 proxy configuration
Grinder_Bot__Socks5Proxy__Port=1337
Grinder_Bot__Socks5Proxy__Hostname=Hostme
Grinder_Bot__Socks5Proxy__Password=Secrete
Grinder_Bot__Socks5Proxy__Username=User

# AllowedUsers - users, who will be able to execute commands in chats from ChatsToMonitor
Grinder_Bot__AllowedUsers__0=Pasha
Grinder_Bot__AllowedUsers__1=Technique

#ChatsToMonitor - chats where bot will read messages and replies
Grinder_Bot__ChatsToMonitor__0=Sample
Grinder_Bot__ChatsToMonitor__1=Text

#AdminUserId - telegram user id who will be able to send private messages to bot
Grinder_Bot__AdminUserId=123

# ChannelId - telegram channel id where bot will write command logs
Grinder_Bot__ChannelId=111

# Token - bot api token
Grinder_Bot__Token=test

Bot commands

  1. Ban

    While writing in any chat from ChatsToMonitor:

    @botusername @user1 @user2 ... ban <time>

    Where time can be combination of this:

    Days: <integer> day(s)

    Minutes: <integer> min(s)

    Months: <integer> month(s)

    Time fractions can appear in any order and once.

    This will ban user in all chats from ChatsToMonitor

    Examples:

    @botusername @user1 @user2 ... ban 1 month 12 minutes

    @botusername @user1 @user2 ... ban 6 minutes

    @botusername @user1 @user2 ... ban 1 month 5 minutes

  2. Unban

    While writing in any chat from ChatsToMonitor:

    @botusername @user1 @user2 ... unban

    This will unban user in all chats from ChatsToMonitor

  3. Ban on reply

    While writing a reply to user in ChatsToMonitor:

    @botusername ban

    This will permaban user in all chats from ChatsToMonitor

  4. Database update

    This can execute only user AdminUserId.

    This will update a database mapping of usernames to userid's. You have to send a file in a private message to bot.

    File structure:

    [
      {"UserId": <telegram user id> ,"Username": "username without at sign"},
      ...
    ]

    File can be generated by running a project Export tool on path src\Grinder.ExportTool\.

About

Telegram bot for chats administration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • F# 93.6%
  • C# 4.9%
  • Dockerfile 1.5%