Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Quick kludge to fix a silly bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Olson committed Apr 4, 2013
1 parent c00710d commit 1e28bfb
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions reggie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
def regex_replace(target, match, replace, replace_all, nick)
if target =~ /^\x01ACTION (.*)\x01$/
prefix = "* #{nick} "
target.replace($1)
target = $1
action = true
else
prefix = "<#{nick}> "
action = false
end

answer = if replace_all
Expand All @@ -38,7 +40,11 @@ def regex_replace(target, match, replace, replace_all, nick)
target.sub(match, replace)
end

return prefix, answer
if action
return prefix, answer, "\x01ACTION #{answer}\x01"
else
return prefix, answer, answer
end
end
end

Expand Down Expand Up @@ -115,7 +121,8 @@ def regex_replace(target, match, replace, replace_all, nick)
@channel_memory[m.channel][-1][0]
end

prefix, answer = regex_replace(target, match, replace, replace_all, nick)
prefix, answer, new_memory =
regex_replace(target, match, replace, replace_all, nick)

# If s/// doesn't change anything, it will try !s///, !!s///, etc, up
# to the maximum number of exclamation marks. If the last !!!s/// fails,
Expand Down Expand Up @@ -147,7 +154,7 @@ def regex_replace(target, match, replace, replace_all, nick)
next if target == answer

# Update the string in @ch_user_memory or @channel_memory.
target.replace(answer)
target.replace(new_memory)

m.reply(prefix + answer)
elsif m.message =~ /^#{Regexp.escape(m.bot.nick)}[:,]\s*help\s*$/
Expand Down

0 comments on commit 1e28bfb

Please sign in to comment.