clification
This commit is contained in:
parent
e7135a4689
commit
48100cd9d5
4 changed files with 39 additions and 20 deletions
9
lib/rocketchat/room.rb
Normal file
9
lib/rocketchat/room.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require 'yaml'
|
||||
|
||||
module RocketChat
|
||||
class Room
|
||||
def show
|
||||
data.to_yaml
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
$:.unshift File.dirname(__FILE__) unless $:.include? File.dirname(__FILE__)
|
||||
|
||||
require 'yaml'
|
||||
require 'rocketchat'
|
||||
require 'rocketchat/channel'
|
||||
|
||||
$:.unshift File.dirname(__FILE__) unless $:.include? File.dirname(__FILE__)
|
||||
require 'rocketchat/room'
|
||||
require 'rocketchat/messages/channel'
|
||||
require 'rocketweekly/connect'
|
41
run.rb
41
run.rb
|
@ -1,21 +1,30 @@
|
|||
require 'yaml'
|
||||
require_relative './lib/rocketweekly'
|
||||
|
||||
rocket = RocketWeekly::Connect.new
|
||||
|
||||
output = {}
|
||||
rocket.channels_list.each do |channel|
|
||||
output[channel.name] = {
|
||||
'id' => channel.id,
|
||||
'owner' => channel.owner ? channel.owner['username'] : '----'
|
||||
}
|
||||
puts '--------------'
|
||||
puts channel.name
|
||||
rocket.channel_history(channel.id).each do |m|
|
||||
printf "%s %-20s\n", m['u']['username'], m['msg']
|
||||
case ARGV[0]
|
||||
when 'list'
|
||||
rocket = RocketWeekly::Connect.new
|
||||
list = rocket.channels_list
|
||||
puts rocket.channels_list.map &:show
|
||||
puts '---------------------'
|
||||
puts "total: #{list.count} canaux"
|
||||
when 'history'
|
||||
rocket = RocketWeekly::Connect.new
|
||||
week = ARGV[1]
|
||||
channel = ARGV[2]
|
||||
puts channel
|
||||
else
|
||||
puts "Usage: #{ARGV[0]} <command> [<argument>]"
|
||||
puts
|
||||
end
|
||||
break
|
||||
puts " possible commands:"
|
||||
puts " list - list all channels information"
|
||||
puts " history <week> <channel> - give messages for the given week"
|
||||
end
|
||||
|
||||
puts '--------------'
|
||||
# puts '--------------'
|
||||
# puts channel.show
|
||||
# # rocket.channel_history(channel.id).each do |m|
|
||||
# # printf "%s %-20s\n", m['u']['username'], m['msg']
|
||||
# # puts
|
||||
# # end
|
||||
# end
|
||||
|
||||
|
|
Loading…
Reference in a new issue