Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
Let commands take unlimited params
Browse files Browse the repository at this point in the history
  • Loading branch information
danopia committed Jan 31, 2010
1 parent b5dc6ac commit f39ab1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion bot.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
18 changes: 12 additions & 6 deletions bots/groupserv.rb
@@ -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 ***"
Expand All @@ -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

0 comments on commit f39ab1c

Please sign in to comment.