Skip to main content

A Slack channel message retriever. This script obtains Slack messages for all channels (public, private, direct, and group) for a specified amount of time for a Workspace.

Project description

Slackmon

Slackmon is a Slack channel message retriever. It obtains Slack messages for all channels (public, private, direct, and group) for a specified amount of time for any Workspace.

Installation

$ pip install slackmon

or from src

$ git clone git@github.com:corpseReviver/python-slackmon.git

$ python python-slackmon/setup.py install

Usage from CLI

$ slackmon [-h] [-v] [--token] [--im] [--mpim] [--private-channels] [--public-channels] [-o OUTFILE] [-f FREQUENCY]

required arguments:

** --token:** Slack API token

optional arguments:

**--help: **show this help message and exit

**--verbose: **Verbose logging of script output

** --im**: Return private IM messages

** --mpim ** :Return private group messages

** --private-channels ** : Return private channel messages

** --public-channels ** : Return public channel messages

**--outfile **: Output response to this file location

** --frequency **: Grab Slack messages from now until this set time in seconds. (Min 3600 - Max 604800) (IE - 3600 will grab the last hours worth of messages)

Usage from Python module

slackmon.get_all_messages(token, outfile=None, frequency=None, verbose=False)

slackmon.get_im_messages(token, outfile=None, frequency=None, verbose=False)

slackmon.get_mpim_messages(token, outfile=None, frequency=None, verbose=False)

slackmon.get_private_channel_messages(token, outfile=None, frequency=None, verbose=False)

slackmon.get_public_channel_messages(token, outfile=None, frequency=None, verbose=False)

These methods return messages from specified channels, im's or mpim's (group messages).

Workspace messages are tied to your Slack web API token. By entering the frequency in seconds, you can return all messages within a given timeframe. For example if you enter 3600 as your frequency (1 hour), you will return all messages within the last hour of calling this method. If left blank the default value is 1 hour. You can also output response to the console or to an outfile (JSON is only supported as of now). If you don't specify an outfile, a response will be returned to your console.

Required arguments:

`token {str} -- Slack web API token`

Keyword Arguments:

`outfile {str} -- A path to export your response to. Must be JSON. Default None.`

`frequency {int} -- Number of seconds to capture messages from starting now. Default None`

`verbose {bool} -- Prints verbose logging data to screen if set to True. Default False.`

Returns: JSON -- All queried messages formatted in a JSON string.

Example:

data = get_all_messages(token='jKdl123Akd=DA', outfile='path/data.json', frequency=3600 )

print(data)

{"status": "complete", "data": "Wrote data to path/data.json"}

Development

Want to contribute? Do it!

Questions

Email me at corpsereviver8@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slackmon-1.4.1.tar.gz (8.5 kB view details)

Uploaded Source

File details

Details for the file slackmon-1.4.1.tar.gz.

File metadata

  • Download URL: slackmon-1.4.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for slackmon-1.4.1.tar.gz
Algorithm Hash digest
SHA256 697027dd36c5ddbf0ef8cba4f2a887e9f8a75e118c02f4c6dc2ef928e44389cc
MD5 e3171db30fdea7f07d8b19ada42af83f
BLAKE2b-256 3f9a85c074b9508725960e86dda06754b85d5475d38c1ba76b5d96d1c8d890e2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page