%global _empty_manifest_terminate_build 0 Name: python-az-messaging Version: 1.3.0 Release: 1 Summary: Messaging for django License: BSD License URL: https://github.com/ali-zahedi/az-messaging Source0: https://mirrors.aliyun.com/pypi/web/packages/08/89/2c3bd1ae7c928269468fb8aea875646a64b060c7c9d98e62291e18262998/az-messaging-1.3.0.tar.gz BuildArch: noarch Requires: python3-six Requires: python3-Django Requires: python3-phonenumberslite Requires: python3-boto3 Requires: python3-twilio %description ![GitHub](https://img.shields.io/github/license/ali-zahedi/az-messaging) ![GitHub](https://img.shields.io/pypi/pyversions/az-messaging.svg?maxAge=2592000) ![GitHub](https://img.shields.io/pypi/v/az-messaging.svg?maxAge=2592000) # AZ Messaging config [[_TOC_]] ## Install with `pip` ```shell script pip install az-messaging ``` ### settings.py ``` python INSTALLED_APPS = [ # .... 'azmessaging', # ... ] AZ_MESSAGING = { 'SETTING_VALUE_READER_CLASS': 'azmessaging.readers.DefaultReader', 'CLASS': { 'SMS': 'azmessaging.channels.SMSNotificationChannel', 'TELEGRAM': 'azmessaging.channels.TelegramNotificationChannel', 'PUSH': 'azmessaging.channels.PushNotificationChannel', }, 'TELEGRAM': { 'SERVICE_PROVIDER': { 'DEFAULT': { 'CLASS': 'azmessaging.telegram.TELEGRAMAPIDefaultAPI', 'api_key': os.environ.get('TELEGRAM_DEFAULT_API_KEY', None), 'api_server': os.environ.get('TELEGRAM_DEFAULT_API_SERVER', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'DEFAULT', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'DEFAULT', ], }, 'SMS': { 'SERVICE_PROVIDER': { 'SNS': { 'CLASS': 'azmessaging.sms.SMSAPISNSAmazon', 'ROUTING': [ { 'countries': 'UK, US', 'region_name': 'eu-west-1' }, { 'continents': 'EUROPE, AFRICA', 'region_name': 'eu-west-2' } ], 'key_id': os.environ.get('AWS_ACCESS_KEY_ID', None), 'access_key': os.environ.get('AWS_SECRET_ACCESS_KEY', None), 'region_name': os.environ.get('AWS_SNS_DEFAULT_REGION', None), }, 'TWILIO': { 'CLASS': 'azmessaging.sms.SMSAPITwilio', 'ROUTING': [ { 'countries': 'DE, EE', 'sender': os.environ.get('TWILIO_EE_SENDER', None), }, { 'continents': 'ASIA', 'sender': os.environ.get('TWILIO_ASIA_SENDER', None), } ], 'account_sid': os.environ.get('TWILIO_ACCOUNT_SID', None), 'auth_token': os.environ.get('TWILIO_AUTH_TOKEN', None), 'sender': os.environ.get('TWILIO_DEFAULT_SENDER', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'SNS', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'TWILIO', 'SNS', ], 'WHITE_LIST': '__all__', # EXAMPLE = 'COUNTRY_CODE_1, COUNTRY_CODE_2' 'BLACK_LIST': '__none__', # EXAMPLE = '__all__' OR 'COUNTRY_CODE_3, COUNTRY_CODE_4' }, 'PUSH': { 'SERVICE_PROVIDER': { 'FCMDJANGO': { 'CLASS': 'azmessaging.pushnotifications.fcmdjango.FCMDjangoAPI', 'api_key': os.environ.get('FCM_SERVER_KEY', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'FCMDJANGO', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'FCMDJANGO', ], }, } ``` ### Migrate ``` python manage.py migrate ``` ### SMS #### Support 1. [SNS AWS](https://aws.amazon.com/sns/) 1. [Twilio](https://www.twilio.com/sms) #### How to use it? Base on sample config, two sms send from `twilio` with `TWILIO_EE_SENDER` number and one of them from `AWS-SNS` and region is `eu-west-1`. ```python from azmessaging import default_settings as settings from azmessaging.models import SMSNotificationType identifier = 'what ever you want' message = 'Your code is: 1222' sms_type = SMSNotificationType.TRANSACTIONAL klass = settings.READER.klass('sms', identifier) sms = klass(identifier=identifier, message=message, sms_type=sms_type) sms.set_receivers(['+16503331111', '+37211123450', '+37211123451']) sms.notify() ``` ### Telegram #### How to use it? ```python from azmessaging import default_settings as settings identifier = 'what ever you want' message = 'Your code is: 1222' klass = settings.READER.klass('telegram', identifier) telegram = klass(identifier=identifier, message=message) telegram.set_receivers(['user_a', 'user_b', ]) telegram.notify() ``` ### Push notification #### How to use it? ```python from azmessaging import default_settings as settings identifier = 'what ever you want' message = 'Your code is: 1222' title = 'OTP' image_url = 'https://example.com/1.png' klass = settings.READER.klass('push', identifier) push_notification = klass(identifier=identifier, message=message, title=title, image_url=image_url, payload_data={}) push_notification.set_receivers(['user_a', 'user_b', ]) push_notification.notify() ``` # TODO - [ ] Documentation - [x] Support multiple provider - [X] SMS Support - [X] SMS Support SNS AWS - [X] SMS Support Twilio - [X] SMS Routing Base on country/continents - [x] SMS Support every provider you want. - [X] SMS Batch - [X] Push notification - [ ] Console - [ ] Websocket - [X] Telegram ## Develop ## License The MIT License (MIT). Please see [License File](LICENSE) for more information. %package -n python3-az-messaging Summary: Messaging for django Provides: python-az-messaging BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-az-messaging ![GitHub](https://img.shields.io/github/license/ali-zahedi/az-messaging) ![GitHub](https://img.shields.io/pypi/pyversions/az-messaging.svg?maxAge=2592000) ![GitHub](https://img.shields.io/pypi/v/az-messaging.svg?maxAge=2592000) # AZ Messaging config [[_TOC_]] ## Install with `pip` ```shell script pip install az-messaging ``` ### settings.py ``` python INSTALLED_APPS = [ # .... 'azmessaging', # ... ] AZ_MESSAGING = { 'SETTING_VALUE_READER_CLASS': 'azmessaging.readers.DefaultReader', 'CLASS': { 'SMS': 'azmessaging.channels.SMSNotificationChannel', 'TELEGRAM': 'azmessaging.channels.TelegramNotificationChannel', 'PUSH': 'azmessaging.channels.PushNotificationChannel', }, 'TELEGRAM': { 'SERVICE_PROVIDER': { 'DEFAULT': { 'CLASS': 'azmessaging.telegram.TELEGRAMAPIDefaultAPI', 'api_key': os.environ.get('TELEGRAM_DEFAULT_API_KEY', None), 'api_server': os.environ.get('TELEGRAM_DEFAULT_API_SERVER', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'DEFAULT', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'DEFAULT', ], }, 'SMS': { 'SERVICE_PROVIDER': { 'SNS': { 'CLASS': 'azmessaging.sms.SMSAPISNSAmazon', 'ROUTING': [ { 'countries': 'UK, US', 'region_name': 'eu-west-1' }, { 'continents': 'EUROPE, AFRICA', 'region_name': 'eu-west-2' } ], 'key_id': os.environ.get('AWS_ACCESS_KEY_ID', None), 'access_key': os.environ.get('AWS_SECRET_ACCESS_KEY', None), 'region_name': os.environ.get('AWS_SNS_DEFAULT_REGION', None), }, 'TWILIO': { 'CLASS': 'azmessaging.sms.SMSAPITwilio', 'ROUTING': [ { 'countries': 'DE, EE', 'sender': os.environ.get('TWILIO_EE_SENDER', None), }, { 'continents': 'ASIA', 'sender': os.environ.get('TWILIO_ASIA_SENDER', None), } ], 'account_sid': os.environ.get('TWILIO_ACCOUNT_SID', None), 'auth_token': os.environ.get('TWILIO_AUTH_TOKEN', None), 'sender': os.environ.get('TWILIO_DEFAULT_SENDER', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'SNS', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'TWILIO', 'SNS', ], 'WHITE_LIST': '__all__', # EXAMPLE = 'COUNTRY_CODE_1, COUNTRY_CODE_2' 'BLACK_LIST': '__none__', # EXAMPLE = '__all__' OR 'COUNTRY_CODE_3, COUNTRY_CODE_4' }, 'PUSH': { 'SERVICE_PROVIDER': { 'FCMDJANGO': { 'CLASS': 'azmessaging.pushnotifications.fcmdjango.FCMDjangoAPI', 'api_key': os.environ.get('FCM_SERVER_KEY', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'FCMDJANGO', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'FCMDJANGO', ], }, } ``` ### Migrate ``` python manage.py migrate ``` ### SMS #### Support 1. [SNS AWS](https://aws.amazon.com/sns/) 1. [Twilio](https://www.twilio.com/sms) #### How to use it? Base on sample config, two sms send from `twilio` with `TWILIO_EE_SENDER` number and one of them from `AWS-SNS` and region is `eu-west-1`. ```python from azmessaging import default_settings as settings from azmessaging.models import SMSNotificationType identifier = 'what ever you want' message = 'Your code is: 1222' sms_type = SMSNotificationType.TRANSACTIONAL klass = settings.READER.klass('sms', identifier) sms = klass(identifier=identifier, message=message, sms_type=sms_type) sms.set_receivers(['+16503331111', '+37211123450', '+37211123451']) sms.notify() ``` ### Telegram #### How to use it? ```python from azmessaging import default_settings as settings identifier = 'what ever you want' message = 'Your code is: 1222' klass = settings.READER.klass('telegram', identifier) telegram = klass(identifier=identifier, message=message) telegram.set_receivers(['user_a', 'user_b', ]) telegram.notify() ``` ### Push notification #### How to use it? ```python from azmessaging import default_settings as settings identifier = 'what ever you want' message = 'Your code is: 1222' title = 'OTP' image_url = 'https://example.com/1.png' klass = settings.READER.klass('push', identifier) push_notification = klass(identifier=identifier, message=message, title=title, image_url=image_url, payload_data={}) push_notification.set_receivers(['user_a', 'user_b', ]) push_notification.notify() ``` # TODO - [ ] Documentation - [x] Support multiple provider - [X] SMS Support - [X] SMS Support SNS AWS - [X] SMS Support Twilio - [X] SMS Routing Base on country/continents - [x] SMS Support every provider you want. - [X] SMS Batch - [X] Push notification - [ ] Console - [ ] Websocket - [X] Telegram ## Develop ## License The MIT License (MIT). Please see [License File](LICENSE) for more information. %package help Summary: Development documents and examples for az-messaging Provides: python3-az-messaging-doc %description help ![GitHub](https://img.shields.io/github/license/ali-zahedi/az-messaging) ![GitHub](https://img.shields.io/pypi/pyversions/az-messaging.svg?maxAge=2592000) ![GitHub](https://img.shields.io/pypi/v/az-messaging.svg?maxAge=2592000) # AZ Messaging config [[_TOC_]] ## Install with `pip` ```shell script pip install az-messaging ``` ### settings.py ``` python INSTALLED_APPS = [ # .... 'azmessaging', # ... ] AZ_MESSAGING = { 'SETTING_VALUE_READER_CLASS': 'azmessaging.readers.DefaultReader', 'CLASS': { 'SMS': 'azmessaging.channels.SMSNotificationChannel', 'TELEGRAM': 'azmessaging.channels.TelegramNotificationChannel', 'PUSH': 'azmessaging.channels.PushNotificationChannel', }, 'TELEGRAM': { 'SERVICE_PROVIDER': { 'DEFAULT': { 'CLASS': 'azmessaging.telegram.TELEGRAMAPIDefaultAPI', 'api_key': os.environ.get('TELEGRAM_DEFAULT_API_KEY', None), 'api_server': os.environ.get('TELEGRAM_DEFAULT_API_SERVER', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'DEFAULT', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'DEFAULT', ], }, 'SMS': { 'SERVICE_PROVIDER': { 'SNS': { 'CLASS': 'azmessaging.sms.SMSAPISNSAmazon', 'ROUTING': [ { 'countries': 'UK, US', 'region_name': 'eu-west-1' }, { 'continents': 'EUROPE, AFRICA', 'region_name': 'eu-west-2' } ], 'key_id': os.environ.get('AWS_ACCESS_KEY_ID', None), 'access_key': os.environ.get('AWS_SECRET_ACCESS_KEY', None), 'region_name': os.environ.get('AWS_SNS_DEFAULT_REGION', None), }, 'TWILIO': { 'CLASS': 'azmessaging.sms.SMSAPITwilio', 'ROUTING': [ { 'countries': 'DE, EE', 'sender': os.environ.get('TWILIO_EE_SENDER', None), }, { 'continents': 'ASIA', 'sender': os.environ.get('TWILIO_ASIA_SENDER', None), } ], 'account_sid': os.environ.get('TWILIO_ACCOUNT_SID', None), 'auth_token': os.environ.get('TWILIO_AUTH_TOKEN', None), 'sender': os.environ.get('TWILIO_DEFAULT_SENDER', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'SNS', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'TWILIO', 'SNS', ], 'WHITE_LIST': '__all__', # EXAMPLE = 'COUNTRY_CODE_1, COUNTRY_CODE_2' 'BLACK_LIST': '__none__', # EXAMPLE = '__all__' OR 'COUNTRY_CODE_3, COUNTRY_CODE_4' }, 'PUSH': { 'SERVICE_PROVIDER': { 'FCMDJANGO': { 'CLASS': 'azmessaging.pushnotifications.fcmdjango.FCMDjangoAPI', 'api_key': os.environ.get('FCM_SERVER_KEY', None), }, }, 'DEFAULT_SERVICE_PROVIDER': 'FCMDJANGO', # REQUIRED 'PRIORITY_SERVICE_PROVIDER': [ # REQUIRED 'FCMDJANGO', ], }, } ``` ### Migrate ``` python manage.py migrate ``` ### SMS #### Support 1. [SNS AWS](https://aws.amazon.com/sns/) 1. [Twilio](https://www.twilio.com/sms) #### How to use it? Base on sample config, two sms send from `twilio` with `TWILIO_EE_SENDER` number and one of them from `AWS-SNS` and region is `eu-west-1`. ```python from azmessaging import default_settings as settings from azmessaging.models import SMSNotificationType identifier = 'what ever you want' message = 'Your code is: 1222' sms_type = SMSNotificationType.TRANSACTIONAL klass = settings.READER.klass('sms', identifier) sms = klass(identifier=identifier, message=message, sms_type=sms_type) sms.set_receivers(['+16503331111', '+37211123450', '+37211123451']) sms.notify() ``` ### Telegram #### How to use it? ```python from azmessaging import default_settings as settings identifier = 'what ever you want' message = 'Your code is: 1222' klass = settings.READER.klass('telegram', identifier) telegram = klass(identifier=identifier, message=message) telegram.set_receivers(['user_a', 'user_b', ]) telegram.notify() ``` ### Push notification #### How to use it? ```python from azmessaging import default_settings as settings identifier = 'what ever you want' message = 'Your code is: 1222' title = 'OTP' image_url = 'https://example.com/1.png' klass = settings.READER.klass('push', identifier) push_notification = klass(identifier=identifier, message=message, title=title, image_url=image_url, payload_data={}) push_notification.set_receivers(['user_a', 'user_b', ]) push_notification.notify() ``` # TODO - [ ] Documentation - [x] Support multiple provider - [X] SMS Support - [X] SMS Support SNS AWS - [X] SMS Support Twilio - [X] SMS Routing Base on country/continents - [x] SMS Support every provider you want. - [X] SMS Batch - [X] Push notification - [ ] Console - [ ] Websocket - [X] Telegram ## Develop ## License The MIT License (MIT). Please see [License File](LICENSE) for more information. %prep %autosetup -n az-messaging-1.3.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-az-messaging -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Thu Jun 08 2023 Python_Bot - 1.3.0-1 - Package Spec generated