Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- require "slack"
- require "date"
- Slack.configure { |config|
- config.token = "token"
- }
- target_channel = "target_channel"
- bot_id = "bot_id"
- time_stamp_list = []
- groups = Slack.channels_list()["groups"]
- groups.each { |group|
- if group["name"] == target_channel then
- messages = Slack.groups_history(channel: group["id"])["messages"]
- messages.each { |message|
- if message["bot_id"] == bot_id then
- ts = message["ts"]
- puts DateTime.strptime(ts, "%s")
- time_stamp_list << ts
- end
- }
- end
- }
- loop {
- groups = Slack.groups_list()["groups"]
- groups.each { |group|
- if group["name"] == target_channel then
- group_id = group["id"]
- messages = Slack.groups_history(channel: group_id)["messages"]
- messages.each { |message|
- ts = message["ts"]
- if message["bot_id"] == bot_id and not time_stamp_list.include? ts then
- puts DateTime.strptime(ts, "%s")
- time_stamp_list << ts
- Slack.pins_add(channel: group_id, timestamp: ts)
- end
- }
- end
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement