lib/ayadn/blacklist.rb in ayadn-1.5.1 vs lib/ayadn/blacklist.rb in ayadn-1.6.0

- old
+ new

@@ -3,20 +3,20 @@ class Blacklist < Thor desc "add TYPE TARGET", "Adds a mention, hashtag, client or username to your blacklist" map "create" => :add long_desc Descriptions.blacklist_add def add(*args) - Action.quit(Status.type_and_target_missing) if args.length < 2 + abort(Status.type_and_target_missing) if args.length < 2 BlacklistWorkers.new.add(args) puts Status.done end desc "remove TYPE TARGET", "Removes a mention, hashtag, client or username from your blacklist" map "delete" => :remove long_desc Descriptions.blacklist_remove def remove(*args) - Action.quit(Status.type_and_target_missing) if args.length < 2 + abort(Status.type_and_target_missing) if args.length < 2 BlacklistWorkers.new.remove(args) puts Status.done end desc "list", "List the content of your blacklist" @@ -52,10 +52,11 @@ Settings.load_config Settings.get_token Settings.init_config Logs.create_logger Databases.open_databases + @workers = Workers.new end def import(database) begin new_db = File.realpath(database) if File.exist?(new_db) @@ -93,15 +94,15 @@ def add(args) begin type = args.shift case type when 'user', 'username', 'account' - target = Workers.add_arobases_to_usernames args + target = @workers.add_arobases_to_usernames args Databases.add_user_to_blacklist(target) Logs.rec.info "Added '#{target}' to blacklist of users." when 'mention', 'mentions' - target = Workers.add_arobases_to_usernames args + target = @workers.add_arobases_to_usernames args Databases.add_mention_to_blacklist(target) Logs.rec.info "Added '#{target}' to blacklist of mentions." when 'client', 'source' Databases.add_client_to_blacklist(args) Logs.rec.info "Added '#{args}' to blacklist of clients." @@ -118,15 +119,15 @@ def remove(args) begin type = args.shift case type when 'user', 'username', 'account' - temp = Workers.add_arobases_to_usernames args + temp = @workers.add_arobases_to_usernames args target = temp.map {|u| "-#{u}"} Databases.remove_from_blacklist(target) Logs.rec.info "Removed '#{target}' from blacklist of users." when 'mention', 'mentions' - target = Workers.add_arobases_to_usernames args + target = @workers.add_arobases_to_usernames args Databases.remove_from_blacklist(target) Logs.rec.info "Removed '#{target}' from blacklist of mentions." when 'client', 'source', 'hashtag', 'tag' Databases.remove_from_blacklist(args) Logs.rec.info "Removed '#{type}:#{args}' from blacklist."