Group name length validation increased, updated contents, readme, changelog

This commit is contained in:
miloszowi 2021-10-26 17:52:51 +02:00
parent cd0712a07b
commit 6150faeee0
19 changed files with 110 additions and 76 deletions

View File

@ -1,14 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file.
## [UNRELEASED] - 11.10.2021
## [0.2.0] - 26.10.2021
### Added
- Inline Query for `join`, `leave` & `everyone`
- Banned users
- Inline Mode for `join`, `leave` & `everyone`
- Banned users environment variable
- Buttons for `start` message
### Changed
- Code quality improvements
- `start` text
- mongodb data structure
- group name max length to 40
### Deleted
- `/silent` command
## [0.1.0] - 06.10.2021

125
README.md
View File

@ -1,26 +1,101 @@
# <p align="center"> [everyone-mention-telegram-bot](http://t.me/everyone_mention_bot)
#<p align="center"> [everyone-mention-telegram-bot](http://t.me/everyone_mention_bot)
<p align="center"> <img src="docs/logo.png" width="150"/>
<!-- Icon made by https://www.freepik.com from https://www.flaticon.com/ -->
# Contents
* [Description](#description)
* [Getting started.](#getting-started)
* [Requirements](#requirements)
* [Installation](#installation)
* [Logs](#logs)
* [Env files](#env-files)
* [Commands](#commands)
* [`/join`](#join)
* [`/leave`](#leave)
* [`/everyone`](#everyone)
* [`/groups`](#groups)
* [`/start`](#start)
* [Example command flow](#example-command-flow)
* [Inline Mode](#inline-mode)
* [Usage](#usage)
* [Getting started.](#getting-started)
* [Requirements](#requirements)
* [Installation](#installation)
* [Logs](#logs)
* [Env files](#env-files)
## Description
Everyone Mention Bot is simple, but useful telegram bot to gather group members attention.
You can create groups per chat to mention every user that joined the group by calling one command instead of mentioning them one by one.
## Commands
*Important*: `{group-name}` is not required, if not given, it will be set to `default`.
### `/join`
Joins the group (if group did not exist before, it will be created).
```
/join {group_name}
```
*Examples*
without group name
![join default command example](docs/join_default.png)
with group name
![join group command example](docs/join_group.png)
### `/leave`
Leaves the group (and deletes if no members are left).
```
/leave {group_name}
```
*Examples*
without group name
![leave default command example](docs/leave_default.png)
with group name
![leave group command example](docs/leave_group.png)
### `/everyone`
Mention everyone that joined requested group.
```
/everyone {group-name}
```
*Examples*
without group name
![everyone default command example](docs/everyone_default.png)
with group name
![everyone group command example](docs/everyone_group.png)
### `/groups`
Will display available groups for this chat as well with members count.
![groups command example](docs/groups.png)
### `/start`
Start & Help message
![start command example](docs/start.png)
### Example command flow
![example command flow](docs/flow_command.png)
## Inline Mode
Using Inline Mode is recommended because policy of bots with privacy mode enabled (https://core.telegram.org/bots/faq#what-messages-will-my-bot-get) says that command trigger is sent (without mentioning the bot) only to the last mentioned bot. So if you do have multiple bots in current chat, I might not receive your command!
### Usage
To use inline mode, type `@everyone_mention_bot` in telegram message input or click on the `Inline Mode` button from `/start` command.
![inline popup](docs/inline_mode_1.png)
Type in your group name (you can leave it blank for `default` group name), then click on one of the three following options.
![inline answer](docs/inline_mode_2.png)
## Getting started
### Requirements
- `docker-compose` in version `1.25.0`
@ -68,40 +143,4 @@ docker/logs <container>
- `MONGO_INITDB_ROOT_PASSWORD` - conf from `app.env`
- `MONGO_INITDB_DATABASE` - conf from `app.env`
- `MONGODB_DATA_DIR` - directory to store MongoDB documents (inside a container)
- `MONDODB_LOG_DIR` - path to logs storage
## Commands
### `/join`
```
/join <group_name>
```
Joins the group (and create if it did not exist before) given in message (`default` if not given)
![join command example](docs/join.png)
### `/leave`
```
/leave <group_name>
```
Leaves the group given in message (`default` if not given)
![leave command example](docs/leave.png)
### `/everyone`
```
/everyone <group_id>
```
Will mention every member of given group (`default` if not given).
If user does not have nickname, it will first try to assign his firstname, then random firstname from `names` python library
![everyone command example](docs/everyone.png)
### `/groups`
Will display available groups for this chat as well with members count.
![groups command example](docs/groups.png)
### `/start`
Start & Help message
![start command example](docs/start.png)
- `MONDODB_LOG_DIR` - path to logs storage

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
docker-compose stop
docker-compose up -d
docker logs -f $(docker-compose ps -q app) &> app.log &

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

BIN
docs/everyone_default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
docs/everyone_group.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
docs/flow_command.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 16 KiB

BIN
docs/inline_mode_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
docs/inline_mode_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

BIN
docs/join_default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
docs/join_group.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

BIN
docs/leave_default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
docs/leave_group.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -6,38 +6,36 @@ not_left = '{} did not join group `{}` before'
mention_failed = 'There are no users to mention'
no_groups = 'There are no groups for this chat'
# html python-telegram-bot specific
start_text = """
Hello!
@everyone_mention_bot here.
<b>Description</b>:
I <b>do not</b> have access to your messages!
I am here to help you with multiple user mentions.
Using <code>Inline Mode</code> is recommended because <a href="https://core.telegram.org/bots/faq#what-messages-will-my-bot-get">policy of bots with privacy mode enabled</a> says that command trigger is sent (without mentioning the bot) only to the last mentioned bot. So if you do have multiple bots in current chat, I might not receive your command!
<b>Usage</b>:
Users that joined the group by <code>/join</code> command, can be mentioned after calling <code>/everyone</code> command.
<b>Commands</b>:
<pre>/join {group-name}</pre>
Joins (or creates if group did not exist before) group.
<pre>/leave {group-name}</pre>
Leaves (or deletes if no other users are left) the group
<pre>/everyone {group-name}</pre>
Mentions everyone that joined the group.
<pre>/groups</pre>
Show all created groups in this chat.
<pre>/start</pre>
Show start & help text
Available commands:
<b>Please note</b>
<code>{group-name}</code> is not required, <code>default</code> if not given.
<b>Join</b>
Joins (or creates if group did not exist before) group.
<pre>/join {group-name}</pre>
<b>Leave</b>
Leaves (or deletes if no other users are left) the group
<pre>/leave {group-name}</pre>
<b>Everyone</b>
Mentions everyone that joined the group.
<pre>/everyone {group-name}</pre>
<b>Groups</b>
Show all created groups in this chat.
<pre>/groups</pre>
<b>Start</b>
Show start & help text
<pre>/start</pre>
Reach out to <a href="https://t.me/miloszowi">Creator</a> in case of any issues/questions regarding my usage.
If your chat does have multiple bots <b>I might not receive your command</b> according to <a href="https://core.telegram.org/bots/faq#what-messages-will-my-bot-get">policy of bots with privacy mode enabled</a> - use <code>Inline Mode</code> to avoid this.
"""

View File

@ -4,7 +4,7 @@ from exception.invalidArgumentException import InvalidArgumentException
class GroupNameValidator:
MAX_GROUP_NAME_LENGTH: int = 20
MAX_GROUP_NAME_LENGTH: int = 40
@staticmethod
def validate(group: str) -> None: