This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Tue Jul 23, 2024 2:50 am
Hi,
Does anyone have a script that does the following:
1: some text like -> 'I liek your hat'
2: then you should be able to do :
and it will write the same text as you did before but with the right word in bold like :
I have tried with help from chatGPT but it does not work
Code: Select all
# 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"
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Wed Jul 24, 2024 3:02 am
Thanks it does work. I have a small change I would like you to help me with
Instead of :
could it be done so it uses
also this :
Code: Select all
::erratum::display_output help PRIVMSG $chan "${::erratum::prefix}[::tcl::string::map {"\177\177" "" "\177" "\002"} $memorized_line]"
from what I can read it handles this :
from the erratum.cfg. could that be made so that I can do:
CrazyCat
Revered One
Posts: 1304 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Wed Jul 24, 2024 6:57 am
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)
P.S.: the official link (
https://scripts.eggdrop.fr/details-Erratum-s231.html ) is available again
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Fri Jul 26, 2024 4:54 am
Okay,
I tryed, I gave up
CrazyCat
Revered One
Posts: 1304 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Fri Jul 26, 2024 11:55 am
I promise nothing, but if I find a little time to spend on it this week-end, I'll try to do that
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Fri Jul 26, 2024 1:27 pm
CrazyCat
Revered One
Posts: 1304 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sat Jul 27, 2024 12:58 pm
Ok, I did the first part with a small hack
Replace the
user_msg_listen proc with:
proc ::erratum::user_msg_listen {nick host hand chan text} {
if {!([channel get $chan erratum])} then {
return
} elseif {([::tcl::string::match -nocase "$::erratum::erratum_cmd*" $text])} {
::erratum::process $nick $host $hand $chan [string range $text [string length $::erratum::erratum_cmd] end]
} else {
::tcl::dict::lappend ::erratum::memory $chan "<$nick> $text"
if { [llength [::tcl::dict::get $::erratum::memory $chan]] > $::erratum::max_memory } {
::tcl::dict::set ::erratum::memory $chan [lreplace [::tcl::dict::get $::erratum::memory $chan] 0 0]
}
}
}
With that, you can use the replace by two ways:
Think to change
erratum_cmd to "s/" in erratum.cfg
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Sun Jul 28, 2024 6:30 am
Thanks. It works
Small issue
Code: Select all
~Flame: s/ red/røde
Error : No match found.
Error : No match found.
It kinda works but:
Code: Select all
~Flame: s/ bar/bare
Correction : <Flame> testerbare
Correction : <Flame> testerbaree
Code: Select all
~Flame: s/bar/bare
Correction : <OldBoys> Correction : <Flame> testerbareee
CrazyCat
Revered One
Posts: 1304 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sun Jul 28, 2024 7:09 am
Did you restart the eggdrop (not rehash, restart) after having changed the script ?
Looks like a side-effect, I'll look further
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Sun Jul 28, 2024 7:14 am
Yes I did a restart
I always do when loading new scripts
CrazyCat
Revered One
Posts: 1304 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Jul 29, 2024 5:59 am
I understood the trouble:
Comment the following line at the end of the script:
bind pub $::erratum::erratum_auth $::erratum::erratum_cmd ::erratum::process
This bind made the process proc called twice
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Mon Jul 29, 2024 6:15 am
Hi,
I'll do that right away
Something did it do
Code: Select all
~Flame: tester bare lieg
~Flame: s/lieg/lige
&OldBoys: Correction : <Flame> tester bare lige
kinda missing a 'space'
Code: Select all
~Flame: tester bare lieg
~Flame: s/ lieg/lige
&OldBoys: Correction : <Flame> tester barelige
CrazyCat
Revered One
Posts: 1304 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Jul 29, 2024 6:33 am
Replace the following line
::erratum::process $nick $host $hand $chan [string range $text [string length $::erratum::erratum_cmd] end]
with
::erratum::process $nick $host $hand $chan [string trimleft [string range $text [string length $::erratum::erratum_cmd] end]]
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Mon Jul 29, 2024 6:54 am
Thanks, that did it
how hard is the format text stuff?
I mean the correction to
instead of
to
Fixed with :
From
Code: Select all
::erratum::display_output help PRIVMSG $chan "${::erratum::prefix}[::tcl::string::map {"\177\177" "" "\177" "\002"} $memorized_line]"
To
Code: Select all
::erratum::display_output help PRIVMSG $chan "$nick ${::erratum::prefix}[::tcl::string::map {"\177\177" "" "\177" "\002"} $memorized_line]"
and in the erratum.cfg
changed this line