Skip to content

Commit

Permalink
feat: created property banned_users in core class
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii committed Apr 9, 2024
1 parent ed8307a commit a906876
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='whatsapp_wrapper',
version='0.1.2',
version='0.1.3',
author='Antonio Ventilii',
author_email='antonioventilii@gmail.com',
license='MIT',
Expand Down
15 changes: 15 additions & 0 deletions whatsapp_wrapper/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, mobile_id: str, api_token: str, version: str = LAST_API_VERSI
else:
self._db = configure_database(database_config)
self.error_handler = self._custom_error_handler_factory(error_handler or _default_error_handler)
self._banned_users = []

def _custom_error_handler_factory(self, external_error_handler):
"""Bind an external error handler to the current instance."""
Expand All @@ -55,6 +56,20 @@ def error_handler(response: Response, data: dict):
def db(self) -> WhatsAppDB:
return self._db

@property
def banned_users(self) -> list[str]:
if self.db:
db_banned_users = self.db.list_banned_user_names()
else:
db_banned_users = []
ret = self._banned_users + db_banned_users
ret = list(set(ret))
return ret

@banned_users.setter
def banned_users(self, value: list[str]):
self._banned_users = value

@property
def base_url(self):
return f'{self.BASE_URL}/{self.version}'
Expand Down

0 comments on commit a906876

Please sign in to comment.