lib/cinch/plugins/octospy/recording.rb in octospy-0.0.8 vs lib/cinch/plugins/octospy/recording.rb in octospy-0.1.0
- old
+ new
@@ -6,10 +6,11 @@
base.class_eval do
match(/watch ([\w\-\.]+)\/([\w\-\.]+)$/, method: :watch_repository)
match(/unwatch ([\w\-\.]+)\/([\w\-\.]+)$/, method: :unwatch_repository)
match(/watch ([\w\-\.]+)$/, method: :watch_repositories)
match(/unwatch ([\w\-\.]+)$/, method: :unwatch_repositories)
+ match(/clear watched( repos(itories)?)?/, method: :clear_watched_repositories)
match(/show watched( repos(itories)?)?/, method: :show_watched_repositories)
end
end
def watch_repository(m, owner, project)
@@ -35,15 +36,16 @@
return
end
::Octospy::Recordable.add_channel m.channel.name
method = "#{'org_' if user.type == 'Organization'}repos".to_sym
- repos = ::Octokit.send(method, owner).map { |repo|
- ::Octospy::Recordable.channel(m.channel.name).add_repo(repo.full_name)
+ repos = ::Octokit.send(method, owner, per_page: 100).map { |repo|
repo.full_name
}
+ ::Octospy::Recordable.channel(m.channel.name).add_repos(repos)
+
if repos.count > 0
m.reply "started to watch events of #{repos.count} repositories"
restart(m)
end
end
@@ -62,15 +64,15 @@
m.reply "stopped to watch the #{repo} events"
end
def unwatch_repositories(m, owner)
repos = ::Octospy::Recordable.channel(m.channel.name).repos.each_with_object([]) do |repo, obj|
- next unless repo.split('/').first == owner
- ::Octospy::Recordable.channel(m.channel.name).remove_repo(repo)
- opj << repo
+ obj << repo if repo.to_s.split('/').first == owner
end
+ ::Octospy::Recordable.channel(m.channel.name).remove_repos(repos)
+
if repos.count > 0
if ::Octospy::Recordable.channel(m.channel.name).repos.count > 0
m.reply "stopped to watch events of #{repos.count} repositories"
restart(m)
else
@@ -78,11 +80,12 @@
stop(m)
end
end
end
- def unwatch_all(m)
+ def clear_watched_repositories(m)
::Octospy::Recordable.remove_channel(m.channel.name)
+ m.reply 'cleared'
end
def show_watched_repositories(m)
channel = ::Octospy::Recordable.channel(m.channel.name)