| View previous topic :: View next topic |
| Author |
Message |
ManNose Voice
Joined: 01 Sep 2012 Posts: 9
|
Posted: Sat Sep 01, 2012 2:31 am Post subject: Enlisting operators |
|
|
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  |
|
| Back to top |
|
 |
ManNose Voice
Joined: 01 Sep 2012 Posts: 9
|
Posted: Fri Sep 07, 2012 6:51 pm Post subject: |
|
|
| Please? |
|
| Back to top |
|
 |
ManNose Voice
Joined: 01 Sep 2012 Posts: 9
|
Posted: Tue Sep 18, 2012 1:06 pm Post subject: |
|
|
I've asked nicely  |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Sat Sep 22, 2012 12:09 pm Post subject: |
|
|
What when someone will write something like this:
"i was at the lalala @asdlkfj34o5irtwejf somewhere"
'@asdlkfj34o5irtwejf' will be the nickname right? |
|
| Back to top |
|
 |
ManNose Voice
Joined: 01 Sep 2012 Posts: 9
|
Posted: Sat Sep 22, 2012 12:35 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Sun Sep 23, 2012 12:46 pm Post subject: |
|
|
check this:
| Code: | # 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 ;> |
|
| Back to top |
|
 |
ManNose Voice
Joined: 01 Sep 2012 Posts: 9
|
Posted: Sun Sep 23, 2012 1:02 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Sun Sep 23, 2012 1:16 pm Post subject: |
|
|
Yes, script is working OK because you didn't mention about flood protect
check this fixed ver.:
| Code: | # 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"
|
|
|
| Back to top |
|
 |
ManNose Voice
Joined: 01 Sep 2012 Posts: 9
|
Posted: Sun Sep 23, 2012 3:03 pm Post subject: |
|
|
| It works, but it only writes to one text file, how come? |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Sun Sep 23, 2012 3:10 pm Post subject: |
|
|
I'm reading your first post and i don't get it why script should write to both files?  |
|
| Back to top |
|
 |
|