Telegram bot for chats administration.
-
Install Net5 SDK
-
Open project with Rider/VS 2019 and run build
-
or use dotnet cli
dotnet build
About configuration you can read below in Configuration section
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
You can use already configured docker-compose.yml as example but, some action required before starting:
- Create a config.env file with environments or dir with appsettings.json
- Change data path in docker-compose.yml and attach configurations to container
- Setup database
- You are ready to go! ᕕ( ᐛ )ᕗ
Just create a launch configuration in your favorite IDE and don't forget about configuration and you will be fine :>
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
{
"Bot": {
"Token": "test",
"ChannelId": 111,
"AdminUserId": 123,
"Socks5Proxy": {
"Hostname": "Hostme",
"Port": 1337,
"Username": "User",
"Password": "Secrete"
},
"ChatsToMonitor": [
"Sample",
"Text"
],
"AllowedUsers": [
"Pasha",
"Technique"
]
}
}
You can attach dir with customized appsettings.json to /etc/grinder/ volume
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
-
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
-
Unban
While writing in any chat from
ChatsToMonitor
:@botusername @user1 @user2 ... unban
This will unban user in all chats from
ChatsToMonitor
-
Ban on reply
While writing a reply to user in
ChatsToMonitor
:@botusername ban
This will permaban user in all chats from
ChatsToMonitor
-
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 pathsrc\Grinder.ExportTool\
.