Metadata-Version: 2.4
Name: slackpy
Version: 3.0.0
Summary: A Simple and Human Friendly Slack Client for Logging.
Author-email: Takahiro Ikeuchi <takahiro.ikeuchi@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/iktakahiro/slackpy
Keywords: Slack,Slack Client
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: System :: Logging
Classifier: Topic :: Communications :: Chat
Requires-Python: >=3.11
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: requests>=2.32.5
Requires-Dist: certifi>=2026.10.19
Requires-Dist: retrying
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

.. image:: https://img.shields.io/pypi/v/slackpy.svg
    :target: https://pypi.python.org/pypi/slackpy

.. image:: https://img.shields.io/pypi/dm/slackpy.svg
    :target: https://pypi.python.org/pypi/slackpy

slackpy
=======

A Simple and Human Friendly `Slack`_ Client for Logging.

Use Case
--------

- Web Application
- NEW! `AWS Lambda`_
- Bash Script

Install
-------

Requires Python 3.11 or newer.

.. code:: sh

    pip install slackpy

Dependencies
------------

- requests>=2.32.5
- certifi>=2026.10.19
- retrying

Sample Code
-----------

.. code:: python

    import slackpy

    INCOMING_WEB_HOOK = 'your_web_hook_url'
    CHANNEL = '#general'
    USER_NAME = 'Logger'
    ICON_URL = 'http://lorempixel.com/48/48'

    # Create a new instance.
    logging = slackpy.SlackLogger(INCOMING_WEB_HOOK, CHANNEL, USER_NAME, ICON_URL)

    # You can set a log level. The default level is INFO.
    logging.set_log_level(slackpy.LogLv.DEBUG) # Or logging.set_log_level(10)

    ## Minimum Parameter
    ## logging = slackpy.SlackLogger(INCOMING_WEB_HOOK)

    # Simple Usage
    logging.info('INFO Message')

    # LogLevel's only required parameter is "message", all others are optional.

    # LogLevel: DEBUG
    logging.debug(message='DEBUG Message', title='DEBUG Title', fields='')

    # LogLevel: INFO
    logging.info(message='INFO Message', title='INFO Title', fields='')

    # LogLevel: WARN
    logging.warn(message='WARN Message', title='WARN Title', fields='')

    # LogLevel: ERROR
    logging.error(message='ERROR Message', title='ERROR Title', fields='')

    # LogLevel: CUSTOM
    logging.message(message='CUSTOM Message', title='CUSTOM Title', color='good',
                    fields=[{"title": "CUSTOM", "value": "test", "short": True}],
                    log_level=40)

    # Title Link (New v2.1.0)
    logging.info(message='INFO Message', title='slackpy Repository here',
                 title_link='https://github.com/iktakahiro/slackpy')


+-----------+----------------+------------------------+
| Method    | LogLevel       | Color                  |
+===========+================+========================+
| debug()   | DEBUG (10)     | #03A9F4 (Light Blue)   |
+-----------+----------------+------------------------+
| info()    | INFO (20)      | good (green)           |
+-----------+----------------+------------------------+
| warn()    | WARNING (30)   | warning (orange)       |
+-----------+----------------+------------------------+
| error()   | ERROR (40)     | danger (red)           |
+-----------+----------------+------------------------+

The definition of the log level is based on the standard library.
(https://docs.python.org/3/library/logging.html#levels)

Command line
------------

.. code:: sh

    export SLACK_INCOMING_WEB_HOOK='your_web_hook_url'

    # LogLevel: DEBUG
    slackpy -c '#your_channel' -m 'DEBUG Message' -l 10

    # LogLevel: INFO
    slackpy -c '#your_channel' -m 'INFO Message' -l 20

    # LogLevel: WARN
    slackpy -c '#your_channel' -m 'WARN Message' -l 30

    # LogLevel: ERROR
    slackpy -c '#your_channel' -m 'ERROR Message' -l 40

    # LogLevel: DEBUG (without specifying #channel)
    slackpy -m 'DEBUG Message' -l 10

    # LogLevel: INFO (with Message Title)
    slackpy -c '#your_channel' -t 'INFO Message Title' -m 'INFO Message' -l 20

For AWS Lamdba
--------------

.. code:: sh

   # First, pip install to top of project directory.
   pip install slackpy -t .

   # Second, archive your source code and dependency packages.
   zip -r src.zip lambda_function.py slackpy requests certifi charset_normalizer idna urllib3 retrying

   # Finally, upload src.zip

About Versioning
----------------

slackpy is following `Semantic Versioning 2.0.0 <http://semver.org/spec/v2.0.0.html>`_.

.. _Slack: https://slack.com

.. _AWS Lambda: https://aws.amazon.com/lambda/

