Coder Social home page Coder Social logo

taleliyahu / bossbot Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 17.0 184 KB

@Bot_BossBot - Administrate Telegram groups like a pro. We developed rules, anti-flood, description, custom triggers help you in managing your Telegram group. BossBot has been created to help the members of a group enjoy a clean and regulated group.

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

JavaScript 100.00%
telegram telegram-bot telegram-bot-api telegram-cli telegram-group telegram-bots telegram-api telegram-channel telegram-themes telegram-desktop

bossbot's Introduction

BossBot Telegram Bot for Admins

Open-source bot that helps you to administrate Telegram groups.

Follow Us On alt text

Installing

If you are about to obtain your own copy/fork of this bot complete the following steps:

  1. Clone repo

    $ git clone https://github.com/Singapore-Tech-Entrepreneurs/telegram_bot_for_admins.git
  2. Install dependencies (you need node.js and NPM installed)

    $ cd telegram_bot_for_admins
    $ npm install
  3. Create config.json file (you have config-example.json, you can copy and edit it). Fill it with your bot api token and mongo connection string. To obtain telegram bot token you may need to use BotFather. Free mongo database you can obtain at mlab.com, for example.

    {
        "bot_token": "<tokenFromBotFather>",
        "mongo_connection": "<mongoDBConnection>",
        "test_connection": "<mongoDBConnection>"
    }
  4. Run it

    $ npm start

Using

  1. Add your bot to supergroup.
  2. Promote him to admin
  3. Activate bot by sending him any message.
  4. Configure it by typing /setting right in your group. This step is important, because you can administer more than one group, so bot needs to know, what group you want to configure right now.
  5. Bot will send you keyboard (in private message), that you can use to toggle message filters and more.

Features

You can activate and configure features in the menu, that bot sends you by typing /setting in the supergroup you want to configure. You must be admin of the supergroup.

Just push the button with function you want to toggle.

Delete "%user% joined the group" messages

If enabled, bot will delete all "%user% joined the group" and "%user% left the group" service messages. That works only for new messages that was sent when option was enabled.

Delete "%user% pinned «%message%»"

Works same as above for "pinned" service messages

Delete arabic messages

If enabled, bot will delete all mesages with any arabic character.

Delete messages with urls

If enabled, bot will delete all mesages with urls. Urls are detected by default telegram mechanism.

Delete messages with Blacklisted words

If enabled, bot will delete all mesages containing blacklisted word/Sentences. To get all blacklisted words/Sentences in group use "/blacklist" in group.

Reset blacklisted words

This will reset(remove) all the blacklisted words for a particular group.

Delete messages with commands

If enabled, bot will delete all mesages with commands, e.g. "/setting"

Restrict spam

If enabled, bot will delete messages that user sends too frequently. Rules and type of restriction will be configurable in future releases.

Hello messages for new members

If enabled, bot will wellcome new members with provided message. You can change default message with "/set_hello" command. Read "/help" for more information.

Allow admins to configure bot

If enabled, all admins of your group can use "/setting" command. If disabled, you can separately grant access to any admin in your group, using "/access" command.

Chat commands

/setting - start to configure current group.

/blacklist - Gives a list of blacklisted word for current group, if replied to a message by admin by message will be blacklisted.

/kick - removes user from chat. Need to be written in a reply to user you want to restrict.

/ban - removes and add user to blocklist. Need to be written in a reply to user you want to restrict.

/warn - warns user about unacceptable behavior. Increases "warns" counter for user. If counter reach 3 - user get banned. Need to be written in a reply to user you want to restrict.

/unwarn - clears "warns" counter. Need to be written in a reply.

Bot command

/set_hello %%% - sets hello message for new users. Message can have placeholder $name. You can call /set_hello without message to set default message for current group. To disable Hello message use configuration keyboard.

/blacklist %word% Adds the new word to blacklist, turn on Delete blacklist from configuration keyboard to delete all messages with such words.

/help - show help message.

/access - show access menu to separately configure admins that can configure bot for current group.

Contibution

You are free to help us to implement new features that described in issues. Please, make PRs into develop branch.

bossbot's People

Contributors

6gzkwt3af75q avatar alsoedit avatar ichi404gh avatar kryptome avatar nacalyator avatar ravibhushan29 avatar taleliyahu avatar zohaib545 avatar

Stargazers

 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

bossbot's Issues

Warning

Welcome/goodbye settings

• /config, then menu tab: receive in private the menu keyboard. You will find an option to enable/disable welcome/goodbye messages.
Note: goodbye messages don't work in large groups. This is a Telegram limitation that can't be avoided.

Custom welcome message:
• /welcome Welcome $name, enjoy the group!
Write after /welcome your welcome message. /goodbye works in the same way.

You can use some placeholders to include the name/username/id of the new member of the group
Placeholders:
$username: will be replaced with the username
$name: will be replaced with the name
$id: will be replaced with the id
$title: will be replaced with the group title
$surname: will be replaced by the user's last name
$rules: will be replaced by a link to the rules of the group. Please read here how to use it, or you will get an error for sure
Note: $name, $surname, and $title may not work properly within markdown markup.

GIF/sticker as welcome message
You can use a particular gif/sticker as welcome message. To set it, reply to the gif/sticker you want to set as welcome message with /welcome. Same goes for /goodbye

Whitelisting

Whitelist settings

As you may know, the bot can warn/kick/ban who sends a telegram.me link (antispam settings) or any other link (media settings).
The whitelist is a list of links that will be ignored by the bot.
If an user sends a whitelisted link, he won't be warned or kicked.

/whitelist [link(s)] or /wl [link(s)]: add one or more links to the whitelist.
/unwhitelist [link(s)] or /unwl [link(s)]: remove one or more links from the whitelist.
/whitelist or /wl: get the whitelist.
/whitelistl - or /wl -: empty the whitelist.

When the group link is saved with /setlink, it gets automatically added to the whitelist.

Why links are saved without https:// and www?
The bot auto-removes https://, http:// and www from every link to reduce the possibility of having the same link saved twice.

Settings

General group settings

/config or /settings: manage the group settings in private from an inline keyboard.
The inline keyboard has six sub-menus:

Menu: manage the most important group settings
Antiflood: turn on or off the antiflood, set its sensitivity and choose some media to ignore, if you want
Media: choose which media to forbid in your group, and set the number of times that an user will be warned before being kicked/banned
Antispam: choose which kind of spam you want to forbid (example: telegram.me links, forwarded messages from channels)
Log channel: choose which updates should be logged
Moderators: promote or demote moderators

Bonus commands:
/reportflood [number of messages]/[timeframe]: set how many times users can use the @admin command within a certain timeframe.
/leave: the bot will leave the group without deleting its data. Use this command only if you are going to add the bot to the group again
/snap: generate a backup file that can be restored with /import (send the file in the group and reply to it). /snap can be used once every three days

Reset functions

/init | to reload the bot

/backup | will send to the creator the bot folder, zipped

/stop | will stop the bot

Report

Reports settings
@admin is an useful command to let users report some messages to the group admins.
A reported message will be forwarded to the available admins.

• /config command, then menu button: here you can find a voice, "Report". If turned on, users will be able to use @admin command.
Only admins who accepted to receive reports (with /mysettings command) will be notified
• /mysettings (in private): from here, you can choose if receive reports or not

Note: admins can't use the @admin command, and users can't report admins with it.

Ban

Banhammer powers
A set of commands that let admins kick and ban people from a group, and get some information about an user.
Kicked people can join back, banned people can't. Banned users are added to the group blacklist

• /kick [by reply|username|id|text mention]: kick a user from the group.
• /ban [by reply|username|id|text mention]: ban a user from the group.
• /tempban [hours|nd nh] = ban an user for a specific amount of hours (max: one week). For now, only by reply. Short form: /tempban 1d 7h
• /unban [by reply|username|id|text mention]: unban the user from the group.
• /block: this command can be used in reply to a forwarded message (from the user you want to block), or in alterantive you can provide a list of usernames. You should block only users who are outside the group.
Blocked users are automatically banned once they join the group.
• /unblock: works in the same way of /block, but allows to remove one or more users from the list of blocked users.
• /blockedlist: get the list of blocked users.
• /user [by reply|username|id|text mention]: shows how many times the user has been banned in all the groups, and the warns received.
• /status [username|id]: show the current status of the user (member|kicked/left the chat|banned|admin/creator|never seen).
A bot can't retrieve the status of an user if that user never started it before (in this case, the never seen status is returned)

Antiflood
The "antiflood" is a system that auto-removes people that send many consecutive messages in a group.
If on, the antiflood system will kick/ban flooders.

• /config command, then antiflood button: manage the flood settings in private, with an inline keyboard. You can change the sensitivity, the action (kick/ban) to perform, and even set some exceptions.

Maximum number of chars per message

admin can enable / disable an option to delete automatically messages that are less then 3 chars and more then 120 chars. Maximum and minimum default limits 3 and 120 can be modified by the admin.

Moderators

Moderators

Moderators are normal users that can use some of the commands that are usually available only to the group administrators.

By default, moderators only have the banhammer (they can use /ban, /kick, /unban, /tempban, /warn, /nowarn, /block, /unblock, /user).
But their powers can be expanded or restricted by the administrators: there is a button in the /config menu, called "Moderators", where the permissions of the moderators can be configured.

By default, every admin can promote a new moderator, or demote an user who is already a mod.
If you are the group owner, in the "Moderators" section of the configuration menu you will be able to find a switch called "Admins can manage mods".
When disabled, the group administrators can't promote or demote new moderators, and also they won't be allowed to access the "Moderators" section of the configuration menu (so they won't be able to change the moderators permissions).

Commands
/promote [by reply|by username|by text mention|by ID]: promote an user to moderator. If used on a moderator, it will update his name in the moderators list.
/demote [by reply|by username|by text mention|by ID]: demote an moderator.
/modlist: show the list of the moderators
/modlist -: demote all the moderators (will clean the modlist)

Extra

Extra commands
#extra commands are a smart way to save your own custom commands.

• /extra [#trigger] [reply]: set a reply to be sent when someone writes the trigger.
Example : with "/extra #hello Good morning!", the bot will reply "Good morning!" each time someone writes #hello.
You can reply to a media (photo, file, vocal, video, gif, audio) with /extra #yourtrigger to save the #extra and receive that media each time you use # command
• /extra list: get the list of your custom commands.
• /extra del [#trigger]: delete the trigger and its message.

Note: the markdown is supported. If the text sent breaks the markdown, the bot will notify that something is wrong.
For a correct use of the markdown, check this post in the channel.
Now supports placeholders. Check the "welcome" tab for the list of the available placeholders

Blacklist Messages and Words with option to reset all words

You can mark messages and put them in memory of the bot to delete such message on future

Example 1:

Admin can add a sentence to the blacklist. Messages that contain exact same sentence, examples:

hi!
Hi all
how are you guys?

Example 2:

As admin you can point and mark a message that someone sends like:

"hi good to be here:

and make the bot delete all messages that the same

Commands available for every user in a group

Commands available for every user in a group:

• /dashboard: see all the informations about the group
• /rules: show the group rules
• /adminlist: show the administrators of the group
• /modlist: show the moderators of the group
• /staff: show the list of the administrators and moderators
• /help: receive the help message
• !kickme: the bot will kick you
Note: /dashboard, /adminlist, /modlist and /staffreplies always in private. If the bot is unable to reach an user, he will ask in the group to that user to be started, but just if silent mode is off.
With /rules, the bot always answer in the group for admins, but with normal users the message is sent in the group or in private according to the group settings.

• @admin (by reply): report a message to the admins of the group (the bot will forward it in prvate). This ability could be turned off from the group settings. A description of the report can be added.
Admins need to give their consense to receive reports from users, with /mysettings command

/settings

/settings | show the current settings of the group

Mongoose models

All models logic should be separated from controllers. If controller need to get access to data from DB it should call a short method from model and just send the response.

To do it all manipulations with mongoose should be encapsulated inside modules which work only with DB data. Models should be described in Schema-style: docs. That way of presentation of data will give better understanding of what fields model (table) consists of. Also it will be easier to set validators and constraints on fields when it define through model. Additionally, you can write static\dynamic methods for the model, which will give you an opportunity to encapsulate complicated interactions with data.

In the result you will have fat models modules and thin controllers. Splitting models and controllers like this will help you to test models and controllers logic independently from each other.

Report to Admins

/report off [reply] | the user won't be able to report a message/send a feedback to the admins

/report on [reply] | the user will be able to report a message/send a feedback to the admins

Flooding

/flood [number] | set the max number of messages allowed within 5 seconds before kick/ban

/flood [on/off] | turn the anti-flood on/off

/flood [kick/ban] | choose what to do when a user is flooding

Log channel informations

Log channel informations

A log channel is a (private) channel where the bot will record all the important events that will happen in your group.
If you want to use this feature, you need to pair your group with a channel with the commands described below.
All the events, by default, are not logged. Admins can choose which events to log from the /config menu -> log channel button.

To pair a channel with a group, the channel creator must add the bot to the channel administrators (otherwise it won't be able to post), and send in the channel this command:
/setlog
Then, an admin of the group must forward in the group the message ("/setlog") sent in the channel. Done!
(you can find a video-tutorial here)

A channel can be used as log by different groups.
To change your log channel, simply repeat this process with another channel.

/unsetlog: remove your current log channel
/logchannel: get some informations about your log channel, if paired

Language

Group language"
• /lang: choose the group language (can be changed in private too).

Note: translators are volunteers, so I can't ensure the correctness of all the translations. And I can't force them to translate the new strings after each update (not translated strings are in english).

Anyway, translations are open to everyone. If you want to translate the bot, see an information on GitHub.
Ask in the English /group for the .po file of your language.

Special characters

• /config command, then menu button: you will receive in private the menu keyboard.
Here you will find two particular options: Arab and RTL.

Arab: when Arab it's not allowed (🚫), everyone who will write an arab character will be kicked from the group.
Rtl: it stands for 'Righ To Left' character, and it's the responsible of the weird service messages that are written in the opposite sense.
When Rtl is not allowed (🚫), everyone that writes this character (or that has it in his name) will be kicked.

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.