use dev roles instead of notify role
parent
0803334db1
commit
3f0c9d186a
|
@ -10,26 +10,27 @@ class Mod_DTL < Vrobot4::Module::Module
|
|||
register :c_listnotify, "listnotify", "Lists available notification groups."
|
||||
register :c_notify, "notify", "Notifies a notification group."
|
||||
|
||||
@info.map! do |id| id.resolve_id end
|
||||
|
||||
@notify_id = 462143279618850826.resolve_id
|
||||
@member_id = 388350737308188684.resolve_id
|
||||
@server_id = 273581213510402058.resolve_id
|
||||
@member_id = @info[:member_id].resolve_id
|
||||
@group_ids = @info[:group_ids].map! do |ids|
|
||||
{not: ids[:not].resolve_id,
|
||||
dev: ids[:dev].resolve_id}
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_role m
|
||||
if m.chan.real.server && m.chan.real.server.id == @server_id
|
||||
if m.chan.real.server
|
||||
m.user.real.add_role @member_id unless m.user.real.role? @member_id
|
||||
end
|
||||
end
|
||||
|
||||
def get_role m, argv
|
||||
def get_notification_roles m, argv
|
||||
roles = m.chan.real.server.roles
|
||||
role = roles.find do |r| r.name.casecmp(argv) == 0 end
|
||||
unless role and @info.any? do |id| role.id == id end
|
||||
ids = @group_ids.detect do |ids| role.id == ids[:not] end if role
|
||||
unless ids
|
||||
raise ArgumentError, "Invalid notification group, use `.listnotify` for a list of available groups."
|
||||
end
|
||||
role
|
||||
ids
|
||||
end
|
||||
|
||||
def on_message m
|
||||
|
@ -44,34 +45,34 @@ class Mod_DTL < Vrobot4::Module::Module
|
|||
|
||||
def c_setnotify m, argv
|
||||
ensure_role m
|
||||
m.user.real.add_role get_role(m, argv)
|
||||
m.user.real.add_role get_notification_roles(m, argv)[:not]
|
||||
m.reply "Successfully added you to the notification group."
|
||||
end
|
||||
|
||||
def c_unsetnotify m, argv
|
||||
m.user.real.remove_role get_role(m, argv)
|
||||
m.user.real.remove_role get_notification_roles(m, argv)[:not]
|
||||
m.reply "Successfully removed you from the notification group."
|
||||
end
|
||||
|
||||
def c_listnotify m, argv
|
||||
text = ""
|
||||
for role in @info do
|
||||
for role in @group_ids do
|
||||
text << m.chan.real.server.role(role).name + ?\n
|
||||
end
|
||||
m.reply text
|
||||
end
|
||||
|
||||
def c_notify m, argv
|
||||
if m.user.real.role? @notify_id
|
||||
argv = argv.split ?,, 2
|
||||
role = get_role m, argv[0]
|
||||
role.mentionable = true
|
||||
ids = get_notification_roles m, argv[0]
|
||||
if m.user.real.role? ids[:dev]
|
||||
ids[:not].mentionable = true
|
||||
if argv[1]
|
||||
m.reply "#{role.mention} - #{argv[1].strip}"
|
||||
m.reply "#{ids[:not].mention} - #{argv[1].strip}"
|
||||
else
|
||||
m.reply role.mention
|
||||
m.reply ids[:not].mention
|
||||
end
|
||||
role.mentionable = false
|
||||
ids[:not].mentionable = false
|
||||
else
|
||||
m.reply "You don't have permission for that."
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue