How to use the apprise.URLBase.PrivacyMode function in apprise

To help you get started, we’ve selected a few apprise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github caronc / apprise / apprise / plugins / NotifyEmail.py View on Github external
args['cc'] = ','.join(self.cc)

        if len(self.bcc) > 0:
            # Handle our Blind Carbon Copy Addresses
            args['bcc'] = ','.join(self.bcc)

        # pull email suffix from username (if present)
        user = self.user.split('@')[0]

        # Determine Authentication
        auth = ''
        if self.user and self.password:
            auth = '{user}:{password}@'.format(
                user=NotifyEmail.quote(user, safe=''),
                password=self.pprint(
                    self.password, privacy, mode=PrivacyMode.Secret, safe=''),
            )
        else:
            # user url
            auth = '{user}@'.format(
                user=NotifyEmail.quote(user, safe=''),
            )

        # Default Port setup
        default_port = \
            self.default_secure_port if self.secure else self.default_port

        # a simple boolean check as to whether we display our target emails
        # or not
        has_targets = \
            not (len(self.targets) == 1 and self.targets[0] == self.from_addr)
github caronc / apprise / apprise / plugins / NotifyTwilio.py View on Github external
def url(self, privacy=False, *args, **kwargs):
        """
        Returns the URL built dynamically based on specified arguments.
        """

        # Define any arguments set
        args = {
            'format': self.notify_format,
            'overflow': self.overflow_mode,
            'verify': 'yes' if self.verify_certificate else 'no',
        }

        return '{schema}://{sid}:{token}@{source}/{targets}/?{args}'.format(
            schema=self.secure_protocol,
            sid=self.pprint(
                self.account_sid, privacy, mode=PrivacyMode.Tail, safe=''),
            token=self.pprint(self.auth_token, privacy, safe=''),
            source=NotifyTwilio.quote(self.source, safe=''),
            targets='/'.join(
                [NotifyTwilio.quote(x, safe='') for x in self.targets]),
            args=NotifyTwilio.urlencode(args))
github caronc / apprise / apprise / URLBase.py View on Github external
    def pprint(content, privacy=True, mode=PrivacyMode.Outer,
               # privacy print; quoting is ignored when privacy is set to True
               quote=True, safe='/', encoding=None, errors=None):
        """
        Privacy Print is used to mainpulate the string before passing it into
        part of the URL.  It is used to mask/hide private details such as
        tokens, passwords, apikeys, etc from on-lookers.  If the privacy=False
        is set, then the quote variable is the next flag checked.

        Quoting is never done if the privacy flag is set to true to avoid
        skewing the expected output.
        """

        if not privacy:
            if quote:
                # Return quoted string if specified to do so
                return URLBase.quote(
github caronc / apprise / apprise / plugins / NotifyPushed.py View on Github external
"""
        Returns the URL built dynamically based on specified arguments.
        """

        # Define any arguments set
        args = {
            'format': self.notify_format,
            'overflow': self.overflow_mode,
            'verify': 'yes' if self.verify_certificate else 'no',
        }

        return '{schema}://{app_key}/{app_secret}/{targets}/?{args}'.format(
            schema=self.secure_protocol,
            app_key=self.pprint(self.app_key, privacy, safe=''),
            app_secret=self.pprint(
                self.app_secret, privacy, mode=PrivacyMode.Secret, safe=''),
            targets='/'.join(
                [NotifyPushed.quote(x) for x in chain(
                    # Channels are prefixed with a pound/hashtag symbol
                    ['#{}'.format(x) for x in self.channels],
                    # Users are prefixed with an @ symbol
                    ['@{}'.format(x) for x in self.users],
                )]),
            args=NotifyPushed.urlencode(args))
github caronc / apprise / apprise / plugins / NotifyBoxcar.py View on Github external
Returns the URL built dynamically based on specified arguments.
        """

        # Define any arguments set
        args = {
            'format': self.notify_format,
            'overflow': self.overflow_mode,
            'image': 'yes' if self.include_image else 'no',
            'verify': 'yes' if self.verify_certificate else 'no',
        }

        return '{schema}://{access}/{secret}/{targets}?{args}'.format(
            schema=self.secure_protocol,
            access=self.pprint(self.access, privacy, safe=''),
            secret=self.pprint(
                self.secret, privacy, mode=PrivacyMode.Secret, safe=''),
            targets='/'.join([
                NotifyBoxcar.quote(x, safe='') for x in chain(
                    self.tags, self.device_tokens) if x != DEFAULT_TAG]),
            args=NotifyBoxcar.urlencode(args),
        )
github caronc / apprise / apprise / plugins / NotifyNotica.py View on Github external
)

        # If we reach here then we are assembling a self hosted URL

        # Append our headers into our args
        args.update({'+{}'.format(k): v for k, v in self.headers.items()})

        # Authorization can be used for self-hosted sollutions
        auth = ''

        # Determine Authentication
        if self.user and self.password:
            auth = '{user}:{password}@'.format(
                user=NotifyNotica.quote(self.user, safe=''),
                password=self.pprint(
                    self.password, privacy, mode=PrivacyMode.Secret, safe=''),
            )
        elif self.user:
            auth = '{user}@'.format(
                user=NotifyNotica.quote(self.user, safe=''),
            )

        default_port = 443 if self.secure else 80

        return '{schema}://{auth}{hostname}{port}{fullpath}{token}/?{args}' \
               .format(
                   schema=self.secure_protocol
                   if self.secure else self.protocol,
                   auth=auth,
                   hostname=NotifyNotica.quote(self.host, safe=''),
                   port='' if self.port is None or self.port == default_port
                        else ':{}'.format(self.port),
github caronc / apprise / apprise / plugins / NotifyNexmo.py View on Github external
Returns the URL built dynamically based on specified arguments.
        """

        # Define any arguments set
        args = {
            'format': self.notify_format,
            'overflow': self.overflow_mode,
            'verify': 'yes' if self.verify_certificate else 'no',
            'ttl': str(self.ttl),
        }

        return '{schema}://{key}:{secret}@{source}/{targets}/?{args}'.format(
            schema=self.secure_protocol,
            key=self.pprint(self.apikey, privacy, safe=''),
            secret=self.pprint(
                self.secret, privacy, mode=PrivacyMode.Secret, safe=''),
            source=NotifyNexmo.quote(self.source, safe=''),
            targets='/'.join(
                [NotifyNexmo.quote(x, safe='') for x in self.targets]),
            args=NotifyNexmo.urlencode(args))
github caronc / apprise / apprise / plugins / NotifyXML.py View on Github external
args = {
            'format': self.notify_format,
            'overflow': self.overflow_mode,
            'verify': 'yes' if self.verify_certificate else 'no',
        }

        # Append our headers into our args
        args.update({'+{}'.format(k): v for k, v in self.headers.items()})

        # Determine Authentication
        auth = ''
        if self.user and self.password:
            auth = '{user}:{password}@'.format(
                user=NotifyXML.quote(self.user, safe=''),
                password=self.pprint(
                    self.password, privacy, mode=PrivacyMode.Secret, safe=''),
            )
        elif self.user:
            auth = '{user}@'.format(
                user=NotifyXML.quote(self.user, safe=''),
            )

        default_port = 443 if self.secure else 80

        return '{schema}://{auth}{hostname}{port}{fullpath}/?{args}'.format(
            schema=self.secure_protocol if self.secure else self.protocol,
            auth=auth,
            hostname=NotifyXML.quote(self.host, safe=''),
            port='' if self.port is None or self.port == default_port
                 else ':{}'.format(self.port),
            fullpath=NotifyXML.quote(self.fullpath, safe='/'),
            args=NotifyXML.urlencode(args),
github caronc / apprise / apprise / plugins / NotifySimplePush.py View on Github external
'format': self.notify_format,
            'overflow': self.overflow_mode,
            'verify': 'yes' if self.verify_certificate else 'no',
        }

        if self.event:
            args['event'] = self.event

        # Determine Authentication
        auth = ''
        if self.user and self.password:
            auth = '{salt}:{password}@'.format(
                salt=self.pprint(
                    self.user, privacy, mode=PrivacyMode.Secret, safe=''),
                password=self.pprint(
                    self.password, privacy, mode=PrivacyMode.Secret, safe=''),
            )

        return '{schema}://{auth}{apikey}/?{args}'.format(
            schema=self.secure_protocol,
            auth=auth,
            apikey=self.pprint(self.apikey, privacy, safe=''),
            args=NotifySimplePush.urlencode(args),
        )
github caronc / apprise / apprise / plugins / NotifyJSON.py View on Github external
args = {
            'format': self.notify_format,
            'overflow': self.overflow_mode,
            'verify': 'yes' if self.verify_certificate else 'no',
        }

        # Append our headers into our args
        args.update({'+{}'.format(k): v for k, v in self.headers.items()})

        # Determine Authentication
        auth = ''
        if self.user and self.password:
            auth = '{user}:{password}@'.format(
                user=NotifyJSON.quote(self.user, safe=''),
                password=self.pprint(
                    self.password, privacy, mode=PrivacyMode.Secret, safe=''),
            )
        elif self.user:
            auth = '{user}@'.format(
                user=NotifyJSON.quote(self.user, safe=''),
            )

        default_port = 443 if self.secure else 80

        return '{schema}://{auth}{hostname}{port}{fullpath}/?{args}'.format(
            schema=self.secure_protocol if self.secure else self.protocol,
            auth=auth,
            hostname=NotifyJSON.quote(self.host, safe=''),
            port='' if self.port is None or self.port == default_port
                 else ':{}'.format(self.port),
            fullpath=NotifyJSON.quote(self.fullpath, safe='/'),
            args=NotifyJSON.urlencode(args),