Skip to content

Commit

Permalink
docs: Add docstrings (#22)
Browse files Browse the repository at this point in the history
* docs: Add docstrings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* docs: fix pre-commit

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
sumit4613 and pre-commit-ci[bot] committed Apr 23, 2022
1 parent de270e2 commit 927b632
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
rev: 1.5.0
hooks:
- id: interrogate
args: [--fail-under=100, -v]
args: [--fail-under=100, -vv]
exclude: ^(docs/conf.py|setup.py)

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
7 changes: 7 additions & 0 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Constants used in the project."""


class ErrorMessages:
"""Error messages from Telegram API"""

CHAT_ADMIN_REQUIRED: str = "CHAT_ADMIN_REQUIRED"
CAN_NOT_REMOVE_CHAT_OWNER: str = "can't remove chat owner"
USER_IS_AN_ADMIN: str = "user is an administrator of the chat"
Expand All @@ -7,5 +12,7 @@ class ErrorMessages:


class BotPermissions:
"""Bot permission names from Telegram API"""

CREATOR: str = "creator"
ADMINISTRATOR: str = "administrator"
6 changes: 5 additions & 1 deletion kick_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@bot.message_handler(func=lambda m: True)
def kick_member(message: [telebot.types.Message]):
"""
This methods kicks out members whose messages contains `aww`
This method kicks out members whose messages contain `aww`
"""
if "aww" not in message.text.lower():
return
Expand Down Expand Up @@ -91,6 +91,7 @@ def kick_member(message: [telebot.types.Message]):


def handle_chat_admin_required(chat_id, first_name, user_id):
"""Method to handle chat admin required error"""
admins: List[telebot.types.ChatMember] = bot.get_chat_administrators(chat_id)
if any(admin.user.is_bot for admin in admins):
# somehow we're getting wrong error message even if bot has admin permissions
Expand All @@ -104,20 +105,23 @@ def handle_chat_admin_required(chat_id, first_name, user_id):


def send_user_is_admin(chat_id, first_name):
"""Method to send user is admin message"""
bot.send_message(
chat_id,
f"{first_name} is an admin and admins are allowed to say forbidden words!",
)


def send_user_is_owner(chat_id, first_name):
"""Method to send user is owner message"""
bot.send_message(
chat_id=chat_id,
text=f"Sorry folks, {first_name} is owner here . I can't do anything.",
)


def send_not_enough_permissions(chat_id):
"""Method to send not enough permissions message"""
bot.send_message(
chat_id,
"Forbidden Word used but I don't have enough permissions to kick members. "
Expand Down

0 comments on commit 927b632

Please sign in to comment.