GithubHelp home page GithubHelp logo

group-butler / groupbutler Goto Github PK

View Code? Open in Web Editor NEW
443.0 41.0 295.0 5.41 MB

This bot can help you in managing your group with rules, anti-flood, description, custom triggers, and much more!

Home Page: https://t.me/GroupButler_bot

License: GNU General Public License v2.0

Lua 97.38% Shell 0.84% Makefile 0.52% Dockerfile 0.31% Go 0.07% PLpgSQL 0.31% PLSQL 0.57%
telegram bot chat lua redis telegram-api telegram-bot docker group-butler hacktoberfest

groupbutler's Introduction

Group Butler

Build Status Coverage Status Localization Status

Short introduction

Group Butler helps people administrate their groups, and includes many other useful tools.

Group Butler was born as an otouto v3.1 (@mokubot), but it has since been turned into an administration bot.

Group Butler on Telegram:


Setup

First of all, take a look at your bot settings

  • Make sure privacy is disabled (more info can be found by heading to the official Bots FAQ page). Send /setprivacy to @BotFather to check the current status of this setting.

Create a plain text file named .env with the following:

  • Set TG_TOKEN to the authentication token that you received from @BotFather.

  • Set SUPERADMINS as a JSON array containing your numerical Telegram ID. Other superadmins can be added too. It is important that you insert the numerical ID and NOT a string.

  • Set LOG_CHAT (the ID of the chat where the bot will send all the bad requests received from Telegram) and your LOG_ADMIN (the ID of the user that will receive execution errors).

Your .env file should now look somewhat like this:

TG_TOKEN=123456789:ABCDefGhw3gUmZOq36-D_46_AMwGBsfefbcQ
SUPERADMINS=[12345678]
LOG_CHAT=12345678
LOG_ADMIN=12345678

Setup (using Docker)

Requirements:

  • docker 18.02.0-ce
  • docker-compose 1.21.0
  • Optional: Docker Swarm cluster for deployment

Running (dev mode)

Run make dev_polling. Docker will pull and build the required images, so the first time you run this command should take a little while. After that, the bot should be up and running.

Code is mounted on the bot container, so you can make changes and restart the bot as you normally would.

Redis default port is mounted to host, just in case you want to debug something using tools available at the host.

The redis container is set to not persist data while in dev mode.

Running (production mode)

There’s a number of ways you can use docker for deploying into production.

Files named docker-compose.*.yml are gitignored, just in case you feel the need to override docker-compose.yml or write something else entirely.

The bot also supports reading Docker Secrets (may work with other vaults too). Check lua/config.lua to see which variables can be read from secrets.

Compose Example

You can deploy Group Butler by running:

make easy_deploy

Swarm Example

Assuming you have deployed redis into, for instance staging (docker stack deploy … or docker service create …) and exported the required environment variables (like $TG_TOKEN…), you could deploy Group Butler by running:

docker stack deploy staging -c docker-compose.yml

Setup (without using Docker)

List of required packages:

  • libreadline-dev
  • redis-server
  • lua5.1
  • liblua5.1dev
  • libssl-dev
  • git
  • make
  • unzip
  • curl
  • libcurl4-gnutls-dev

You will need some other Lua modules too, which can be (and should be) installed through the Lua package manager LuaRocks.

Installation

You can easily install Group Butler by running the following commands:

# Tested on Ubuntu 16.04

$ wget https://raw.githubusercontent.com/group-butler/GroupButler/master/install.sh
$ bash install.sh

or

# Tested on Ubuntu 14.04, 15.04 and 16.04, Debian 7, Linux Mint 17.2

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install libreadline-dev libssl-dev lua5.1 liblua5.1-dev git make unzip redis-server curl libcurl4-gnutls-dev

# We are going now to install LuaRocks and the required Lua modules

$ wget http://luarocks.org/releases/luarocks-2.2.2.tar.gz
$ tar zxpf luarocks-2.2.2.tar.gz
$ cd luarocks-2.2.2
$ ./configure; sudo make bootstrap
$ sudo luarocks install luasec
$ sudo luarocks install luasocket
$ sudo luarocks install redis-lua
$ sudo luarocks install lua-term
$ sudo luarocks install serpent
$ sudo luarocks install lua-cjson
$ sudo luarocks install Lua-cURL
$ cd ..

# Clone the repository and give the launch script permissions to be executed
# If you want to clone the beta branch, use git clone with the [-b beta] option

$ git clone https://github.com/group-butler/GroupButler.git
$ cd GroupButler
$ sudo chmod +x launch.sh

Before you start the bot, you have to start the Redis process.

# Start Redis

$ sudo service redis-server start

Starting the process

To start the bot, run ./launch.sh. To stop the bot, press Control CTRL+C twice.

You may also start the bot with ./polling.lua, however it will not restart automatically. You will also need to find another way to export the required environment variables.


Something that you should known before run the bot

  • You can change some settings of the bot. All the settings are placed in config.lua, in the bot_settings table
    • cache_time.adminlist: the permanence in seconds of the adminlist in the cache. The bot caches the adminlist to avoid to hit Telegram limits
    • notify_bug: if true, the bot will send a message that notifies that a bug has occurred to the current user, when a plugin is executed and an error happens
    • log_api_errors: if true, the bot will send in the LOG_CHAT all the relevant errors returned by an api request toward Telegram
    • stream_commands: if true, when an update triggers a plugin, the match will be printed on the console
  • There are some other useful fields that can be added to .env you can find in config.lua, for instance
    • REDIS_DB: the selected Redis database (if you are running Redis with the default config, the available databases are 16). The database will be selected on each start/reload. Default: 0
  • Other things that may be useful
    • Administrators commands start for $. They are not documented, look at the triggers of plugins/admin.lua plugin for the whole list
    • If the main function of a plugin returns true, the bot will continue to try to match the message text with the missing triggers of the plugins table
    • You can send yourself a backup of the zipped bot folder with the $backup command
    • The Telegram Bot API has some undocumented "weird behaviours" that you may notice while using this bot
      • In supergroups, the kickChatMember method returns always a positive response if the user_id has been part of the group at least once, it doesn't matter if the user is not in the group when you use this method
      • In supergroups, the unbanChatMember method returns always a positive response if the user_id has been part of the group at least once, it doesn't matter if the user is not in the group or is not in the group blacklist

Some notes about the database

Everything is stored on Redis, and the fastest way to edit your database is via the Redis CLI.

You can find a backup of your Redis database in /etc/redis/dump.rdb. The name of this file and the frequency of saves are dependent on your redis configuration file.


Translators

If you want to help translate the bot, follow the instructions below. Parts of Group Butler use tools from gettext. However we don't use binary format *.mo for the sake of simplicity. The bot parses the *.po files in the locales directory at runtime.

We recommend contributing translations to our Crowdin project.

Note for developers: update the POT file whenever you change a string, and don't forget to use the i18n() function so it's translatable. In order to update the POT file you will need to install gettext and then run:

make pot

Credits

Topkecleon, for the original otouto

Iman Daneshi and Tiago Danin, for Jack-telegram-bot

Cosmonawt, for his Lua library for the Bot API

Yago Pérez for his telegram-bot

The Werewolf guys, for aiding the spread of the bot

Lucas Montuano, for helping me a lot in the debugging of the bot

All the Admins of our discussion groups about Group Butler

All the people who reported bugs and suggested new stuff

Le Laide

groupbutler's People

Contributors

ahmetcetin avatar allen0099 avatar benjarobbi avatar caiodias avatar catchingknives avatar fathurhoho avatar flyingfisch avatar hellscre4m avatar itspey avatar jaksz avatar josepdal avatar kamikazechaser avatar mymedia2 avatar notafile avatar nyancrimew avatar qwerty-space avatar remembertheair avatar riskey95 avatar synk0 avatar tiagodanin avatar vdragon avatar wrxck avatar xeniun avatar yangm97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

groupbutler's Issues

Warning sent twice

1 - Sending a photo with a telegram.me link in the caption or forwarding a photo from a channel result in a double warn, if telegram.me links or messages from channels (antispam) and photos (media) are both forbidden in the chat.


2 - Also, if a message is forwarded from a channel and has a telegram.me link in the caption, msg.spam will contain "links" string. Could be a possible issue if in a group only forwards from channels are forbidden: a message like that will trigger only the telegram.me links block

Gban dont work

Gban dont work and if user not is in group for reply or dont have username so how can gban it>?

Issue with Multipurpose Plugins

hello all i listed my custom plugins in config.lua in line containing

multipurpose_plugins = {
'example.lua',
}

and add the files to folder plugins/multipurpose/
but the bot don't load the plugins,
if i put the plugins on the main folder (plugins) and add to

plugins = {
'example.lua',
}

and start bot, i receive the message with not found error

Non-latin symbols in links in the whitelist break the bot

The bot is frozen when it tries to send the full whitelist of links if this list contains links with non-latin characters

Steps to reproduce:

  • Add the bot to a supergroup
  • Send the next command /whitelist пример.рф
  • Try to get the list of white links via simply /whitelist command
  • The bot is frozen and doesn't answer anymore

The bot version is 4.2.0 rev.b41a10f

stupid bugs

1- bot owner or admins can block Themselves !
2- admins can block bot owner!
and cant unblock they, unless Other admins or owner unblock blocked admins.

I have problem with start launch.sh

lua: bot.lua:2: module 'socket.url' not found:
no field package.preload['socket.url']
no file '/usr/local/share/lua/5.2/socket/url.lua'
no file '/usr/local/share/lua/5.2/socket/url/init.lua'
no file '/usr/local/lib/lua/5.2/socket/url.lua'
no file '/usr/local/lib/lua/5.2/socket/url/init.lua'
no file '/usr/share/lua/5.2/socket/url.lua'
no file '/usr/share/lua/5.2/socket/url/init.lua'
no file './socket/url.lua'
no file '/usr/local/lib/lua/5.2/socket/url.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.2/socket/url.so'
no file '/usr/lib/lua/5.2/socket/url.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket/url.so'
no file '/usr/local/lib/lua/5.2/socket.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.2/socket.so'
no file '/usr/lib/lua/5.2/socket.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket.so'
stack traceback:
[C]: in function 'require'
bot.lua:2: in main chunk
[C]: in ?

can you help me? sorry i beginner programmer :(

Multipurpose Plugins

how i can activate the multipurpose plugins ?
i set the following line:

	multipurpose_plugins = {
	'test',
	},

and create and folder nammed "multipurpose" inside the plugins folder and upload the plugin "test" to inside, but i start the bot but nothing happens

Italiano translation

This media is forbidden" message should be translated
"Questo tipo di media non è consentito in questo gruppo." in italian and not this (currently): "Questo tipo di media non è consentito in questo gruppo."

The problem is "è" character

Stats and other admin commands

How to use the admin commands like /stats?
I've configured a log channel (I've also tried with a group) but nothing happens

I'm set as superadmin and admin

Add local time support

Right now the bot is programmed to output UTC timestamps whenever date is needed. But we should add support for timezones in order to allow further expansion of GB feature set.

  • Save/read chat timezone on database

no file error

Could someone help me to fix the error?

    no file '/usr/local/share/lua/5.2/socket/url.lua'
    no file '/usr/local/share/lua/5.2/socket/url/init.lua'
    no file '/usr/local/lib/lua/5.2/socket/url.lua'
    no file '/usr/local/lib/lua/5.2/socket/url/init.lua'
    no file '/usr/share/lua/5.2/socket/url.lua'
    no file '/usr/share/lua/5.2/socket/url/init.lua'
    no file './socket/url.lua'
    no file '/usr/local/lib/lua/5.2/socket/url.so'
    no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/socket/url.so'
    no file '/usr/lib/lua/5.2/socket/url.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './socket/url.so'
    no file '/usr/local/lib/lua/5.2/socket.so'
    no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/socket.so'
    no file '/usr/lib/lua/5.2/socket.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './socket.so'

Deleting spam links

Is there option to delete spam links, as I think api now allows it, or any chance for it to be addied?

Bot halts after initiating chat with him

So, I've installed your bot, added it to supergroup, wrote "help", he said "Write to me first", I didn't do this, pressed "/help" again in supergroup, bot got Error : 400 : PEER_ID_INVALID in logs and stopped responding to everybody.

Only after I restarted it, he became working again. Could you confirm this?

languages.lua [fix banhammer]

cheek banhammer en lang with other lang.
I do not know which one is correct otherwise fixed and marge it.
Is your work :)

Problem with new version

Hello guys.
I cloned new version of group butler. Then I created .env.
Now I want launch bot, but I can't!
Error:

lua: /usr/local/share/lua/5.2/redis.lua:380: redis error: ERR invalid DB index
stack traceback:
        [C]: in function 'error'
        /usr/local/share/lua/5.2/redis.lua:802: in function </usr/local/share/lua/5.2/redis.lua:801>
        (...tail calls...)
        /usr/local/share/lua/5.2/redis.lua:380: in function 'select'
        ./lua/bot.lua:15: in function 'bot_init'
        ./lua/bot.lua:369: in main chunk
        [C]: in function 'require'
        ./polling.lua:4: in main chunk
        [C]: in ?

This is text of line 15 in bot.lua:

db:select(config.redis.db) --select the redis db

What's the problem?

Question about flood control

Hello!
There's a problem, with spammers and I want to consult you.

So one person uses many (200+ account) to enter public group, send one message and leave (and repeats it many times). Will flood control react if 5 people will send one message each within X seconds.

Feature request 1: Enable flood control for all users at once, so if 10 people write 10 messages (1 for each) within X seconds, bot starts kicking.

Feature request 2: If users joins channel, delete all messages from him for an hour (quarantine time)

How to set a group link?

I don't understand how to use accurately the "/setlink" command. What should I type next to it in order to set a link for the group?

Improve logging

Bot always expects at least two admins

assert(#config.superadmins > 1, clr.red..'Insert your Telegram ID in config.lua -> superadmins'..clr.reset)

shouldn't this be

    assert(#config.superadmins >= 1, clr.red..'Insert your Telegram ID in config.lua -> superadmins'..clr.reset)

or

assert(#config.superadmins > 0, clr.red..'Insert your Telegram ID in config.lua -> superadmins'..clr.reset)

Default Language

Hello, I change the line to pt_br but the bot don't start on pt_BR only in english

languages.lua:62
locale.language = 'pt_BR' -- default language

Avoid temporary files in /snap etc.

Currently groupbutler writes and reads a temporary file whenever it wants to send files. However, this is not necessary since lua-cURL supports uploading files from strings.

I'm not sure what the reason for the three day limit of /snap is but this might remove it.

help

hi when i update to v4 bot dont answer me commands so i can get use /restore

Change bot language

How to change bot language for a group?
Because I'm trying to execute the command /lang, I select Spanish but nothing happens

Removing of Commands

I would really like the bot to be "invisible" in the group, this can be achieved by removing all the commands. Thus meaning when an Admin sends a trigger the bot responds, or when a user sends a trigger (like custom commands) the bot also responds. I would really like this feature. All functions will remain as it was but only removing commands thus making it possible for no group commands. Or if anyone is running a clone that has no command please don't hesitate to PM with its username on my telegram @sirmarita , otherwise thanks again for good job. The bot is pretty

Change in spam detection

Could you please make it so the part of your bot responsible for spam detection wouldn't detect forwarded messages? Because in my group people forward a lot of messages and get kicked after this.

spam and mute

hi
is there a way to implement these features:
1- mute: disable posting anything into group by users
2- remove posts containing some keywords ?
thanks for your nice work

[Feature request] Add a /mute command to silence certain users

Would it be possible to add a /mute command (and an /unmute) that would would prevent certain users from talking in the group? I don't want to mute the group nor kick said user, I just want to mute them for a little while.

I haven't seen any other issues relevant to this issue so I decided to make this one myself. If I missed it, please let me known.

rapporteer 'n probleem :(

hallo my vriend.
When add robot in the new group, bot does not welcoming to new member!
GroupButler welcoming to my old group but in new group does not welcoming
(in /config welcome is on but....)

Sterkte!

Feature request: Automatic delete

I don't know if this is already in action so I'll ask for it anyway.

  1. If a user spams, shouldn't the flood messages be deleted by default? Does the bot do it now?
  2. If a user share a restricted media (set to not be sent by the /media command), does the bot delete it automatically?

Thanks for your answers and sorry for my bad English

Request for feature

Is it possible to implement a warning system for writing arab messages? And on the second or tired time ban them?
Thank you for your work and the really practical bot

Adrian

Wrong command

The install is missing in the command you use: sudo luarocks install Lua-cURL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.