Search code examples
pythonslack-apislack

Python script to copy some messages from slack which were posted in some time range


I want to write a python script using some slack API's which will be able to copy some messages which were pasted between say 10AM to 11AM in a channel A & then paste the same messages in a different channel B.

I know that it's easy to write a message in slack via a python script, but is it also possible to pull some messages out of slack ?


Solution

  • One way would be to use Requests (or any http client you like) with this endpoint: https://api.slack.com/methods/channels.history

    This returns a list of messages for a given channel that you can filter with the oldest and latest arguments.