clification

This commit is contained in:
mose 2018-07-09 08:30:21 +08:00
parent e7135a4689
commit 48100cd9d5
4 changed files with 39 additions and 20 deletions

9
lib/rocketchat/room.rb Normal file
View file

@ -0,0 +1,9 @@
require 'yaml'
module RocketChat
class Room
def show
data.to_yaml
end
end
end

View file

@ -1,6 +1,7 @@
$:.unshift File.dirname(__FILE__) unless $:.include? File.dirname(__FILE__) require 'yaml'
require 'rocketchat' require 'rocketchat'
require 'rocketchat/channel'
$:.unshift File.dirname(__FILE__) unless $:.include? File.dirname(__FILE__)
require 'rocketchat/room'
require 'rocketchat/messages/channel'
require 'rocketweekly/connect' require 'rocketweekly/connect'

43
run.rb
View file

@ -1,21 +1,30 @@
require 'yaml'
require_relative './lib/rocketweekly' require_relative './lib/rocketweekly'
rocket = RocketWeekly::Connect.new case ARGV[0]
when 'list'
output = {} rocket = RocketWeekly::Connect.new
rocket.channels_list.each do |channel| list = rocket.channels_list
output[channel.name] = { puts rocket.channels_list.map &:show
'id' => channel.id, puts '---------------------'
'owner' => channel.owner ? channel.owner['username'] : '----' puts "total: #{list.count} canaux"
} when 'history'
puts '--------------' rocket = RocketWeekly::Connect.new
puts channel.name week = ARGV[1]
rocket.channel_history(channel.id).each do |m| channel = ARGV[2]
printf "%s %-20s\n", m['u']['username'], m['msg'] puts channel
puts else
end puts "Usage: #{ARGV[0]} <command> [<argument>]"
break puts
puts " possible commands:"
puts " list - list all channels information"
puts " history <week> <channel> - give messages for the given week"
end 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