lib/ayadn/blacklist.rb in ayadn-2.0.10 vs lib/ayadn/blacklist.rb in ayadn-2.0.11
- old
+ new
@@ -1,9 +1,9 @@
# encoding: utf-8
module Ayadn
class Blacklist < Thor
- desc "add TYPE TARGET", "Adds a mention, hashtag, client or username to your blacklist"
+ desc "add TYPE TARGET", "Adds a mention, hashtag, client, username or keyword to your blacklist"
map "create" => :add
long_desc Descriptions.blacklist_add
def add(*args)
if args.length < 2
Status.new.type_and_target_missing
@@ -11,11 +11,11 @@
end
BlacklistWorkers.new.add(args)
Status.new.done
end
- desc "remove TYPE TARGET", "Removes a mention, hashtag, client or username from your blacklist"
+ desc "remove TYPE TARGET", "Removes a mention, hashtag, client, username or keyword from your blacklist"
map "delete" => :remove
long_desc Descriptions.blacklist_remove
def remove(*args)
if args.length < 2
Status.new.type_and_target_missing
@@ -99,10 +99,14 @@
Databases.add_to_blacklist('client', args)
Logs.rec.info "Added '#{args}' to blacklist of clients."
when 'hashtag', 'tag'
Databases.add_to_blacklist('hashtag', args)
Logs.rec.info "Added '#{args}' to blacklist of hashtags."
+ when 'word', 'keyword'
+ args = args.map { |w| w.gsub(/[~:-;,?!\'&`^=+<>*%()\/"“”’°£$€.…]/, "") }
+ Databases.add_to_blacklist('word', args)
+ Logs.rec.info "Added '#{args}' to blacklist of words."
else
Status.new.wrong_arguments
end
end
end
@@ -121,9 +125,13 @@
when 'client', 'source'
Databases.remove_from_blacklist('client', args)
Logs.rec.info "Removed '#{type}:#{args}' from blacklist."
when 'hashtag', 'tag'
Databases.remove_from_blacklist('hashtag', args)
+ Logs.rec.info "Removed '#{type}:#{args}' from blacklist."
+ when 'word', 'keyword'
+ args = args.map { |w| w.gsub(/[~:-;,?!\'&`^=+<>*%()\/"“”’°£$€.…]/, "") }
+ Databases.remove_from_blacklist('word', args)
Logs.rec.info "Removed '#{type}:#{args}' from blacklist."
else
Status.new.wrong_arguments
end
end