class SlackSmartBot
def suggest_command(user, dest, dchannel, specific, rules_file)
save_stats(__method__)
dont_suggest = []
help_message = get_help(rules_file, dest, user, specific, true, descriptions: false, only_normal_user: true)
commands = help_message.gsub(/====+/,'-'*30).split(/^\s*-------*$/).flatten
commands.reject!{|c| c.match?(/These are specific commands for this bot on this/i) || c.match?(/\A\s*\z/)}
dont_suggest.each do |ds|
commands.reject!{|c| c.match?(/:#{ds}\s*$/i)}
end
@last_suggested_commands ||= []
@last_suggested_commands.shift if @last_suggested_commands.size >=5
command = ''
begin
command = commands.sample
end until !@last_suggested_commands.include?(command) or commands.size <= 5
@last_suggested_commands << command
command.gsub!(/^\s*command_id:\s+:\w+\s*$/,'')
command.gsub!(/^\s*>.+$/,'')
message = "*Command suggestion*:\n#{command}"
respond message, dest, unfurl_links: false, unfurl_media: false
end
end