Class: Slackup::Channels

Inherits:
Slackup show all
Defined in:
lib/slackup/channels.rb

Constant Summary

Constants inherited from Slackup

Error, RUN_ROOT, SEMAPHORE, VERSION

Instance Attribute Summary

Attributes inherited from Slackup

#client, #name

Instance Method Summary collapse

Methods inherited from Slackup

backup, configure_client, #execute, #initialize, run_root, team_token_pairs, team_token_pairs_file

Constructor Details

This class inherits a constructor from Slackup

Instance Method Details

#listObject Also known as: channels



3
4
5
# File 'lib/slackup/channels.rb', line 3

def list
  @list ||= client.channels_list["channels"]
end

#messages(channel) ⇒ Object



14
15
16
# File 'lib/slackup/channels.rb', line 14

def messages(channel)
  client.channels_history(channel: channel["id"], count: "1000")
end

#write!Object



8
9
10
11
12
# File 'lib/slackup/channels.rb', line 8

def write!
  channels.each do |channel|
    write_messages(channel)
  end
end

#write_messages(channel) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/slackup/channels.rb', line 18

def write_messages(channel)
  with_messages channel["name_normalized"], messages(channel) do |messages|
    File.open(backup_filename(channel["name"]), "w")  do |f|
      formatted_messages = format_messages(messages)
      f.write serialize(formatted_messages)
    end
  end
end