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.

Enlisting operators

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
M
ManNose
Voice
Posts: 9
Joined: Sat Sep 01, 2012 2:24 am

Enlisting operators

Post by ManNose »

This is my first ever request so I am hoping I am doing this properly.

I need a script that when someone writes an operators nickname anywhere in a sentence it will check if the operator is written in operators.txt, if not, the script will write him to channelOperators.txt

Maybe I should add an example of an input output situation?

[2000] ManNose: hi @Mark and @Tony how are you?

If Mark and Tony have already been written before on operators.txt it won't write them to channelOperators.txt (without the @ )

Another example could be:

[2000] ManSoe: lol@Mark
OR
[2100] @Mark@Tony

That should work too... I mean check if Mark is in the list or not and add if required and add Mark and Tony if required in the second example.

When adding Mark and Tony the script will add each operator in a seperate line

@Mark
@Tony
@SomeoneElse

If anyone has any question I am here to answer, I hope I wrote this post properly and anticipate a reply, I hope :-)
M
ManNose
Voice
Posts: 9
Joined: Sat Sep 01, 2012 2:24 am

Post by ManNose »

Please?
M
ManNose
Voice
Posts: 9
Joined: Sat Sep 01, 2012 2:24 am

Post by ManNose »

I've asked nicely :(
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

What when someone will write something like this:

"i was at the lalala @asdlkfj34o5irtwejf somewhere"

'@asdlkfj34o5irtwejf' will be the nickname right?
M
ManNose
Voice
Posts: 9
Joined: Sat Sep 01, 2012 2:24 am

Post by ManNose »

Yes, exactly

but it can also be
"i was at the lalala @asdlkfj34o5irtwejf somewhere @tomekk"
and then both @tomekk and @asdlkfj34o5irtwejf will be in the list
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

check this:

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# if you want to use this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +opers
# and later .save

# min operator nickname length (ex. @, example: @mark = 4 chars)
set min_oper_nick_len 2

# oper nicks file
set oper_file "/home/user/eggdrop/operators.txt"

# new oper nicks file
set chan_oper_file "/home/user/eggdrop/channelOperators.txt"

##############################################################
bind pubm - "*" pharse_parse

setudef flag opers

set get_opers [open $oper_file r]
set all_opers [split [read $get_opers] "\n"]
close $get_opers

proc save_oper { oper } {
        global chan_oper_file

        set append_hand [open $chan_oper_file a]
        puts $append_hand $oper
        close $append_hand
}

proc pharse_parse { nick uhost hand chan arg } {
        global all_opers min_oper_nick_len

        if {![channel get $chan opers]} {
                return
        }

        regsub -all -nocase {(@)} $arg "\n@" arg

        set separate_it [split $arg "\n"]

        if {[llength $separate_it] > 1} {
                foreach word $separate_it {
                        if {[regexp -nocase {^@} $word]} {
                                set pharse_oper [string trim [lindex [split $word] 0]]

                                if {[string length $pharse_oper] > [expr $min_oper_nick_len + 1]} {
                                        regsub -nocase {@} $pharse_oper "" pharse_oper

                                        set oper_exists 0

                                        foreach [string trim operator] $all_opers {
                                                if {$operator == $pharse_oper} {
                                                        set oper_exists 1
                                                        break;
                                                }
                                        }

                                        if {$oper_exists == 0} {
                                                save_oper $pharse_oper
                                        }
                                }
                        }
                }
        }
}

putlog "operpharse.tcl ver 0.1 by tomekk loaded"
operators.txt:
nick1
nick2
etc.

channelOperators:
nick1
nick2
etc.

Without @ at the beginning.
Script will work even with "lalala @nickname;)" - i mean, there is no filter for special chars in the nicknames ;>
M
ManNose
Voice
Posts: 9
Joined: Sat Sep 01, 2012 2:24 am

Post by ManNose »

Hey tomekk, thanks for the script!

Theres a problem with the code - if I did not write operators to operators.txt, when someone writes @jackie here in the channel and he was not on operators.txt -> it writes him to channelOperators.txt, but if I wrote 10 times the same operator it will write him 10 times to channelOperators.txt

What I mean is, if @jackie was not in operators.txt, it won't write him to channelOperators AND to operators.txt, so it will write him everytime someone mentions @jackie instead of just one time
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

Yes, script is working OK because you didn't mention about flood protect ;)

check this fixed ver.:

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# if you want to use this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +opers
# and later .save

# min operator nickname length (ex. @, example: @mark = 4 chars)
set min_oper_nick_len 2

# oper nicks file
set oper_file "/home/user/eggdrop/operators.txt"

# new oper nicks file
set chan_oper_file "/home/user/eggdrop/channelOperators.txt"

##############################################################
bind pubm - "*" pharse_parse

setudef flag opers

set get_opers [open $oper_file r]
set all_opers [split [read $get_opers] "\n"]
close $get_opers

proc check_oper { oper } {
        global chan_oper_file

        set get_new_opers [open $chan_oper_file r]
        set all_new_opers [split [read $get_new_opers] "\n"]
        close $get_new_opers

        set there_is_one "no"

        foreach new_oper $all_new_opers {
                if {$new_oper == $oper} {
                        set there_is_one "yes"
                        break;
                }
        }

        return $there_is_one
}

proc save_oper { oper } {
        global chan_oper_file

        set append_hand [open $chan_oper_file a]
        puts $append_hand $oper
        close $append_hand
}

proc pharse_parse { nick uhost hand chan arg } {
        global all_opers min_oper_nick_len

        if {![channel get $chan opers]} {
                return
        }

        regsub -all -nocase {(@)} $arg "\n@" arg

        set separate_it [split $arg "\n"]

        if {[llength $separate_it] > 1} {
                foreach word $separate_it {
                        if {[regexp -nocase {^@} $word]} {
                                set pharse_oper [string trim [lindex [split $word] 0]]

                                if {[string length $pharse_oper] > [expr $min_oper_nick_len + 1]} {
                                        regsub -nocase {@} $pharse_oper "" pharse_oper

                                        set oper_exists 0

                                        foreach [string trim operator] $all_opers {
                                                if {$operator == $pharse_oper} {
                                                        set oper_exists 1
                                                        break;
                                                }
                                        }

                                        if {$oper_exists == 0} {
                                                if {[check_oper $pharse_oper] == "no"} {
                                                        save_oper $pharse_oper
                                                }
                                        }
                                }
                        }
                }
        }
}

putlog "operpharse.tcl ver 0.1 by tomekk loaded"
M
ManNose
Voice
Posts: 9
Joined: Sat Sep 01, 2012 2:24 am

Post by ManNose »

It works, but it only writes to one text file, how come?
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

I'm reading your first post and i don't get it why script should write to both files? :)
Post Reply