0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Slackの過去ログを消す (slack_cleaner2)

Last updated at Posted at 2020-04-07

参考

手順

  • ubuntu 20.04 にて確認
  • Too Many Requests for url:と表示される場合、数分待つ
pip3 install slack_cleaner2
  • SlackのTOKENを取得し、以下のSECRET TOKEN箇所に記述

スクリーンショット_2020-04-07_09-15-24.png

delete.py
from slack_cleaner2 import *
s = SlackCleaner('SECRET TOKEN')

# *bot ユーザーのメッセージを全削除
for msg in s.msgs(filter(match('.*bot'), s.conversations)):
  msg.delete()
python3 delete.py

ユーザー一覧

users.py
from slack_cleaner2 import *
s = SlackCleaner('SECRET TOKEN')

for user in s.users:
    print(user)

会話一覧

conversations.py
from slack_cleaner2 import *
s = SlackCleaner('SECRET TOKEN')

for conversation in s.conversations:
    print(conversation)

general ルームの会話を全削除

from slack_cleaner2 import *
s = SlackCleaner('SECRET TOKEN')

# for msg in s.c.general.msgs():
#   msg.delete()

10件削除したら終了する

sys.exit
import sys

from slack_cleaner2 import *
s = SlackCleaner('SECRET TOKEN')

i = 0
for msg in s.c.general.msgs():
    i = i + 1
    msg.delete()
    if i > 10:
        sys.exit()
forを抜ける
from slack_cleaner2 import *
s = SlackCleaner('SECRET TOKEN')

i = 0
for msg in s.c.general.msgs():
    i = i + 1
    msg.delete()
    if i > 10:
        break
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?