make role chooser more generic
parent
d4199cf103
commit
b450643e2f
|
@ -4,19 +4,29 @@ class Mod_RoleChooser < Vrobot4::Module::Module
|
|||
|
||||
def initialize info
|
||||
super
|
||||
register :c_setcolor, "setcolor", "Sets your color."
|
||||
register :c_listcolors, "listcolors", "Lists available color roles."
|
||||
@info.map! {|id| id.resolve_id}
|
||||
register :c_addvrole, "addvroles", "Adds another vanity role to you."
|
||||
register :c_delvrole, "delvroles", "Removes a vanity role from you."
|
||||
register :c_listvroles, "listvroles", "Lists available vanity roles."
|
||||
@info.map! do |id| id.resolve_id end
|
||||
end
|
||||
|
||||
def c_setcolor m, argv
|
||||
def get_role m, argv
|
||||
roles = m.chan.real.server.roles
|
||||
role = roles.find {|r| r.name.casecmp? argv}
|
||||
unless role and @info.any? {|id| role.id == id}
|
||||
raise ArgumentError, "Invalid color, use .listcolors for a list."
|
||||
role = roles.find do |r| r.name.casecmp(argv) == 0 end
|
||||
unless role and @info.any? do |id| role.id == id end
|
||||
raise ArgumentError, "Invalid role, use .listvroles for a list."
|
||||
end
|
||||
to_remove = roles.select {|r| @info.include? r.id and r != role}
|
||||
m.user.real.modify_roles role, to_remove
|
||||
role
|
||||
end
|
||||
|
||||
def c_addvrole m, argv
|
||||
m.user.real.add_role get_role(m, argv)
|
||||
m.reply "Successfully added you to the vanity role."
|
||||
end
|
||||
|
||||
def c_delvrole m, argv
|
||||
m.user.real.remove_role get_role(m, argv)
|
||||
m.reply "Successfully removed you from the vanity role."
|
||||
end
|
||||
|
||||
def c_listcolors m, argv
|
||||
|
|
Loading…
Reference in New Issue