# Define the event handler for channel messages
proc on_message {nick user host channel message} {
# Debugging output for received message
putquick "PRIVMSG $channel :Received message: $message"
# Define the pattern for the replacement command
if {[regexp {^s/(\S+)/(\S+)/\s*(.*)} $message match wrong_word correct_word text]} {
# Debugging output to check matched groups
putquick "PRIVMSG $channel :Pattern matched: wrong_word=$wrong_word, correct_word=$correct_word, text=$text"
# Check if the text is not empty
if {[string length $text] > 0} {
# Debugging output before replacement
putquick "PRIVMSG $channel :Text before replacement: $text"
# Replace the wrong word with the correct word in the text
set corrected_message [string map [list $wrong_word $correct_word] $text]
# Debugging output after replacement
putquick "PRIVMSG $channel :Text after replacement: $corrected_message"
# Send the corrected message back to the channel
putquick "PRIVMSG $channel :$corrected_message"
} else {
# Debugging message if text is empty
putquick "PRIVMSG $channel :No text to process after replacement."
}
} else {
# Debugging message if pattern did not match
putquick "PRIVMSG $channel :Pattern did not match. Ensure message format is: s/word1/word2 message"
}
}
putlog "Replace Words Script - Loaded"
Well, you can change "!erratum" with "s/" but you'll have to keep a space between the command and the arguments.
If you don't want to, you'll need to modify the bind and the process procedure to work with pubm and not pub.
And to change the prefix to add the nick, the proc must also been modified to use [format] on the prefix.
It's possible to do that but I've a lack of time and the creator of the script is actually no more involved in tcl (peharps he'll be back some day)