Allow you to verify the new member of the group and send some command to a user.
Develop with Lumen V7.0,
- Laravel Requirements
- SSL for Telegram Webhook method
Create Telegram bot with @BotFather
After creating the Telegram bot, you will need to disable "Group Privacy" in "Bot Settings".
You need to add Telegram bot to your Telegram group(s) as a Admin with Delete Message
and Ban Users
permission.
git clone https://github.com/parsakafi/laravel-telegram-group-management-bot.git
cd laravel-telegram-group-management-bot
composer install
Copy .env.example
file to .env
cp .env.example .env
Setup database connection in .env
file.
TELEGRAM_BOT_USERNAME=username_bot
TELEGRAM_BOT_TOKEN=bot_token
Allowed Telegram group IDs (Separated with comma)
TELEGRAM_BOT_GROUPS=-123
Add new command for reply to users (Separated with comma)
TELEGRAM_BOT_ALLOWED_COMMANDS=smart
For set reply command string, Edit language file.
TELEGRAM_BOT_REMOVE_BOTS=true
TELEGRAM_BOT_TEMP_LOCK_TIME=5
TELEGRAM_BOT_DELETE_MESSAGE_AFTER=10
TELEGRAM_BOT_MAX_WRONG_ANSWER=3
TELEGRAM_BOT_MAX_QUESTION=10
Currently Persian/Farsi language is supported
TELEGRAM_BOT_LOCALIZE_QUESTION=false
Database Migration
php artisan migrate
This command will start a development server at http://localhost:8000
:
php artisan serve
First, make sure you set the APP_URL
value in the .env
file correctly. For set webhook run this url on your web browser (Replace your domain). Debugging mode is required to be enabled.
https://your-web-bot-url.tld/set_webhook
For remove old question message from group(s). Add this url to your server cron job. (Replace your domain)
https://your-web-bot-url.tld/remove_message
To display latest Telegram request/error/result (Replace your domain). Debugging mode is required to be enabled.
https://your-web-bot-url.tld/debug
The bot sends an equation to new group member. If the user resolves the equation, Allows the user to continue group activity.
Command start with exclamation mark (!), For example !smart
If you reply a command to user, The bot get command description from language file and reply to user.
For 'Let me google that for you', users can reply to another user with this pattern:
!g word