Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Let commands take unlimited params

  • Loading branch information...
commit f39ab1c47a24d1ddd0b39817c64b75d7da075100 1 parent b5dc6ac
Daniel Lamando authored
Showing with 15 additions and 7 deletions.
  1. +3 −1 bot.rb
  2. +12 −6 bots/groupserv.rb
4 bot.rb
View
@@ -15,6 +15,8 @@ def self.command names, description, *params, &blck
:min_params => min_params
}
+ data[:unlimited] = params.pop if params.last == true
+
names = [names] if names.is_a? String
@@commands[self][names.first.upcase] = data
@@ -60,7 +62,7 @@ def on_priv_message from, bot, to, message
notice from, "Insufficient parameters for ^B#{command}^B."
notice from, "Syntax: #{command} <#{info[:params].join '> <'}>"
else
- params.pop until params.size <= info[:params].size
+ params.pop until params.size <= info[:params].size unless info[:unlimited]
send "cmd_#{(@@commands[self.class][command.upcase][:alias_of] || command).downcase}", from, *params
end
18 bots/groupserv.rb
View
@@ -1,7 +1,7 @@
module BitServ
class GroupServ < ServicesBot
command 'list', 'List all registered groups.'
- command 'roles', 'Manage the roles for a certain group.', 'group'
+ command 'roles', 'Manage the roles for a certain group.', 1, 'group', 'action', true
def cmd_list origin
notice origin, "*** List of Registered Groups ***"
@@ -11,12 +11,18 @@ def cmd_list origin
notice origin, "*** End Group List ***"
end
- def cmd_roles origin, group
- notice origin, "*** Group Roles List for #{group} ***"
- Group.load(group).roles.each do |role|
- notice origin, "#{role.name.ljust 16}| (#{role.members.size}) #{role.desc}"
+ def cmd_roles origin, group, action='list', *args
+ LDAP.user_bind origin.nick, password
+
+ case action
+ when 'list'
+ notice origin, "*** Group Roles List for #{group} ***"
+ Group.load(group).roles.each do |role|
+ notice origin, "#{role.name.ljust 16}| (#{role.members.size}) #{role.desc}"
+ end
+ notice origin, "*** End Role List ***"
+
end
- notice origin, "*** End Role List ***"
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.