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