lib/ayadn/blacklist.rb in ayadn-1.2.2 vs lib/ayadn/blacklist.rb in ayadn-1.2.3

- old
+ new

@@ -2,22 +2,22 @@ module Ayadn class Blacklist < Thor desc "add TYPE TARGET", "Adds a mention, hashtag or client to your blacklist" long_desc Descriptions.blacklist_add def add(*args) - if args.length != 2 + if args.length < 2 puts Status.type_and_target_missing end blacklist = BlacklistWorkers.new blacklist.add(args) puts Status.done end desc "remove TYPE TARGET", "Removes a mention, hashtag or client from your blacklist" long_desc Descriptions.blacklist_remove def remove(*args) - if args.length != 2 + if args.length < 2 puts Status.type_and_target_missing end blacklist = BlacklistWorkers.new blacklist.remove(args) puts Status.done @@ -78,39 +78,39 @@ Databases.close_all end end def add(args) begin - type, target = args[0], args[1] + type = args.shift case type when 'mention', 'mentions' - target = Workers.add_arobase_if_missing([target]) + 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(target) - Logs.rec.info "Added '#{target}' to blacklist of clients." + Databases.add_client_to_blacklist(args) + Logs.rec.info "Added '#{args}' to blacklist of clients." when 'hashtag', 'tag' - Databases.add_hashtag_to_blacklist(target) - Logs.rec.info "Added '#{target}' to blacklist of hashtags." + Databases.add_hashtag_to_blacklist(args) + Logs.rec.info "Added '#{args}' to blacklist of hashtags." else puts Status.wrong_arguments end ensure Databases.close_all end end def remove(args) begin - type, target = args[0], args[1] + type = args.shift case type when 'mention', 'mentions' - target = Workers.add_arobase_if_missing([target]) + 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(target) - Logs.rec.info "Removed '#{type}:#{target}' from blacklist." + Databases.remove_from_blacklist(args) + Logs.rec.info "Removed '#{type}:#{args}' from blacklist." else puts Status.wrong_arguments end ensure Databases.close_all