1 # -*- coding: utf-8 -*-
5 # Author:: MelmothX <melmothx@gmail.com>
6 # Copyright:: No copyright
7 # License:: Public Domain
13 # create the multidimensional hash
17 # ", nella sua sbataggine, intendeva",
18 # "si รจ sbagliato. Voleva dire",
22 def help(plugin, topic="")
23 "Fix the previous sentence using regexp and a sed-like syntax. Supported delimiters are /|,! and the modifier \"g\". Grouping is supported via parens, and backreferencing is done via \\1 \\2 and so on. You don't have to directly address the bot. Examples: <nick>hello <nick>s/e/u/"
27 return unless m.public?
32 if not @amendlog.has_key?(channel)
33 @amendlog[channel] = Hash.new
35 oldstring = @amendlog[channel][source]
37 if m.message.match(/^s([\/|,!])(.*?)\1(.*?)\1(g?)/) then
38 target = Regexp.new($2)
42 newstring = oldstring.sub(target, replace_with)
44 newstring = oldstring.gsub(target, replace_with)
46 # sentence = @answers[rand(@answers.length)]
48 if (oldstring == newstring)
49 failreply = _("You did something wrong... Try s/you/me/ or tell me \"help sed\"")
50 m.reply("#{source}: #{failreply}")
53 m.reply("#{source} #{sentence}: \"#{newstring}\"", :nick => false)
56 @amendlog[channel][source] = stuff