Class: Slackup::Ims
Defined Under Namespace
Classes: Im
Constant Summary
Constants inherited from Slackup
Error, RUN_ROOT, SEMAPHORE, VERSION
Instance Attribute Summary
Attributes inherited from Slackup
Instance Method Summary collapse
- #format_username(user) ⇒ Object
- #ims_dir ⇒ Object
-
#list ⇒ Hash
(also: #ims)
{ “ok”=>true, “ims”=>[ “is_im”=>true, “user”=>“USLACKBOT”, “created”=>1372105335, “is_user_deleted”=>false, ] }.
-
#messages(im_id) ⇒ Hash
{ “ok”: true, “latest”: “1358547726.000003”, “messages”: [ { “type”: “message”, “ts”: “1358546515.000008”, “user”: “U2147483896”, “text”: “<@U0453RHGQ> has some thoughts on that kind of stuff” }, ] “has_more”: false.
- #write! ⇒ Object
- #write_messages(im) ⇒ Object
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
#format_username(user) ⇒ Object
57 58 59 |
# File 'lib/slackup/ims.rb', line 57 def format_username(user) user_name(user).downcase.gsub(/\s+/, "-") end |
#ims_dir ⇒ Object
61 62 63 64 65 |
# File 'lib/slackup/ims.rb', line 61 def ims_dir @ims_dir ||= "ims" FileUtils.mkdir_p(@ims_dir) @ims_dir end |
#list ⇒ Hash Also known as: ims
"ok"=>true,
"ims"=>[
{"id"=>"D1234567890", "is_im"=>true, "user"=>"USLACKBOT", "created"=>1372105335, "is_user_deleted"=>false,
]
}
15 16 17 |
# File 'lib/slackup/ims.rb', line 15 def list @list ||= client.im_list["ims"].map { |im| Im.new(im) } end |
#messages(im_id) ⇒ Hash
{
"ok": true,
"latest": "1358547726.000003",
"messages": [
{
"type": "message",
"ts": "1358546515.000008",
"user": "U2147483896",
"text": "<@U0453RHGQ> has some thoughts on that kind of stuff"
},
]
"has_more": false
43 44 45 |
# File 'lib/slackup/ims.rb', line 43 def (im_id) client.im_history(channel: im_id) end |
#write! ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/slackup/ims.rb', line 20 def write! Dir.chdir(ims_dir) do ims.each do |im| (im) end end end |
#write_messages(im) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/slackup/ims.rb', line 47 def (im) im_username = format_username(im.user) im_username, (im.id) do || = () File.open(backup_filename(im_username), "w") do |f| f.write serialize() end unless .empty? end end |